OpenCV/第5章 图像形态梯度、礼帽、黑帽

                                              OpenCV/第5章 图像形态梯度、礼帽、黑帽

//author: rorger

//time:2010-10-21 22:23:17

延续上次的图像操作

  #include "cv.h" #include "highgui.h" #include "highgui.h" int main(int argc, char ** argv) { cvNamedWindow("image"); IplImage * src = cvLoadImage(argv[1], 0); IplImage * temp = cvCreateImage(cvGetSize(src), 8,1); IplImage * img=cvCreateImage(cvGetSize(src), 8, 1); cvCopyImage(src,temp); cvCopyImage(src, img); //形态梯度 cvMorphologyEx( src, img, temp, NULL, //default 3*3 CV_MOP_GRADIENT, 1); cvShowImage("image", img); cvWaitKey(0); //"礼帽" cvMorphologyEx( src, img, temp, NULL, //default 3*3 CV_MOP_TOPHAT, 1); cvShowImage("image", img); cvWaitKey(0); //“黑帽” cvMorphologyEx( src, img, temp, NULL, //default 3*3 CV_MOP_BLACKHAT, 1); cvShowImage("image", img); cvWaitKey(0); cvReleaseImage(&temp); cvReleaseImage(&src); cvReleaseImage(&img); cvDestroyAllWindows(); return 0; }

 

 

OpenCV/第5章 图像形态梯度、礼帽、黑帽_第1张图片

你可能感兴趣的:(image,null,2010)