opencv c++膨胀与腐蚀

#include
#include
#include

using namespace cv;
using namespace std;
Mat src, dst, gblur;
int element_size = 3;
int max_size = 21;
char out_title[] = "out_title";

int main()
{
	
	void CallBack_demo(int,void*);
	src = imread("C:/Users/asus/Desktop/tupian/1.jpg");
	if (!src.data)
	{
		printf("could not load image\n");
		return -1;
	}
	char input_title[] = "input title";
	namedWindow(input_title, WINDOW_AUTOSIZE);
	namedWindow(out_title, WINDOW_AUTOSIZE);
	imshow(input_title, src);
	createTrackbar("element size", out_title,&element_size, max_size, CallBack_demo);
	CallBack_demo(0, 0);

	waitKey(0);
	return 0;

}
void CallBack_demo(int, void*)
{
	int z = element_size * 2 + 1;
	Mat structureElement = getStructuringElement(MORPH_RECT, Size(z, z), Point(-1, -1));
	//dilate(src, dst, structureElement, Point(-1, -1), 1);
	erode(src, dst, structureElement, Point(-1, -1), 1);
	imshow(out_title, dst);

}

你可能感兴趣的:(opencv,c++,opencv,c++)