#include "cv.h"
#include "highgui.h"
int main(int argc,char ** argv){
IplImage *img= cvLoadImage(argv[1]);//读取图片
cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE);
cvNamedWindow("Example2",CV_WINDOW_AUTOSIZE);
cvNamedWindow("Example3",CV_WINDOW_AUTOSIZE);
cvShowImage("Example1",img);//在Example1显示图片
// cvCopy(img,temp);
IplImage* temp=cvCreateImage( //创建一个size为image,三通道8位的彩色图
cvGetSize(img),
IPL_DEPTH_8U,3
);
IplConvKernel * myModel;
myModel=cvCreateStructuringElementEx( //自定义5*5,参考点(3,3)的矩形模板
5,5,2,2,CV_SHAPE_RECT
);
cvErode(img,temp,myModel,1);
cvShowImage("Example2",temp);
cvDilate(img,temp,myModel,1);
cvShowImage("Example3",temp);
cvWaitKey(0);//暂停用于显示图片
cvReleaseStructuringElement(&myModel);
cvReleaseImage(&img);//释放img所指向的内存空间并且
cvDestroyWindow("Example1");
cvDestroyWindow("Example2");
cvDestroyWindow("Example3");
#include "highgui.h"
int main(int argc,char ** argv){
IplImage *img= cvLoadImage(argv[1]);//读取图片
cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE);
cvNamedWindow("Example2",CV_WINDOW_AUTOSIZE);
cvNamedWindow("Example3",CV_WINDOW_AUTOSIZE);
cvShowImage("Example1",img);//在Example1显示图片
// cvCopy(img,temp);
IplImage* temp=cvCreateImage( //创建一个size为image,三通道8位的彩色图
cvGetSize(img),
IPL_DEPTH_8U,3
);
IplConvKernel * myModel;
myModel=cvCreateStructuringElementEx( //自定义5*5,参考点(3,3)的矩形模板
5,5,2,2,CV_SHAPE_RECT
);
cvErode(img,temp,myModel,1);
cvShowImage("Example2",temp);
cvDilate(img,temp,myModel,1);
cvShowImage("Example3",temp);
cvWaitKey(0);//暂停用于显示图片
cvReleaseStructuringElement(&myModel);
cvReleaseImage(&img);//释放img所指向的内存空间并且
cvDestroyWindow("Example1");
cvDestroyWindow("Example2");
cvDestroyWindow("Example3");
return 0;
}