opencv9-膨胀和腐蚀
生活随笔
收集整理的這篇文章主要介紹了
opencv9-膨胀和腐蚀
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
膨脹是求最大值。即白色增多
腐蝕是求最小值,即黑色增多
#include<opencv2\opencv.hpp> #include<opencv2\highgui\highgui.hpp> #include<iostream> #include<math.h> using namespace std; using namespace cv; //模糊原理 Mat src; Mat dst_dilate, dst_erode; int element_size = 3; int max_size = 21; char output_title[] = "output Image"; void CallBack_Demo(int, void*); int main() {src = imread("E:\\vs2015\\opencvstudy\\3.jpg", 1);if (src.empty()){cout << "could not load the src image!" << endl;return -1;}char *input_title = "input Image";imshow(input_title, src);namedWindow(output_title, 1);createTrackbar("Size:", output_title, &element_size, max_size, CallBack_Demo);CallBack_Demo(0, 0);waitKey(0);return 0; } void CallBack_Demo(int, void*) {int s = element_size * 2 + 1;Mat structureElement = getStructuringElement(MORPH_RECT, Size(s,s), Point(-1, -1));dilate(src, dst_dilate, structureElement, Point(-1, -1),1);//erode(src, dst_erode, structureElement, Point(-1, -1), 1);imshow(output_title, dst_dilate);/*imshow(output_title, dst_erode);*/return;}?
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的opencv9-膨胀和腐蚀的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++基础12-类和对象之操作符重载-s
- 下一篇: unittest-读取yaml文件