opencv 的开闭,腐蚀膨胀运算的例子。

来源:互联网 发布:手机小说阅读软件 编辑:程序博客网 时间:2024/05/23 21:19

我自己写的使用opencv进行开运算和腐蚀运算的例子。写的很简单。

#include<opencv\cv.h>#include<opencv\highgui.h>void main(){IplImage *img = cvLoadImage("hello.jpg",0);int array_cross[] ={0,0xff,0,0xff,0xff,0xff,0   ,0xff,0};int num = 0;cvShowImage("img",img);IplConvKernel * rectCross= cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_CROSS,array_cross);//cvErode(img,img,rectCross,num);//形态学被腐蚀运算。cvMorphologyEx(img,img,NULL,rectCross,CV_MOP_OPEN,num);//形态学开运算。cvShowImage("腐蚀",img);cvWaitKey();//释放内存。cvReleaseStructuringElement(&rectCross);cvReleaseImage(&img);}


原创粉丝点击