二值化图像处理 形态学操作 OPENCV C+ 6

#include 
#include 
#include 

using namespace cv;
int main(int argc, char** argv) {
	Mat src, dst;
	src = imread("D:/vcprojects/images/bin2.png");
	if (!src.data) {
		printf("could not load image...\n");
	}
	namedWindow("input image", CV_WINDOW_AUTOSIZE);
	imshow("input image", src);
	char output_title[] = "morphology demo";
	namedWindow(output_title, CV_WINDOW_AUTOSIZE);

	Mat kernel = getStructuringElement(MORPH_RECT, Size(11, 11), Point(-1, -1));
	//morphologyEx(src, dst, CV_MOP_BLACKHAT, kernel);顶帽
	//morphologyEx(src, dst, CV_MOP_CLOSE, kernel);闭操作
	morphologyEx(src, dst, CV_MOP_OPEN, kernel);//开操作


	imshow(output_title, dst);

	waitKey(0);
	return 0;
}

你可能感兴趣的:(OPENCV,C++)