OpenCV膨胀和腐蚀示例代码
#include<cv.h>
#include<highgui.h>
int main(int argc, char** argv)
{
IplImage* img = cvLoadImage(argv[1]);
IplImage* img1 = cvLoadImage(argv[1]);
IplImage* img2 = cvLoadImage(argv[1]);
cvErode(img, img1);
cvDilate(img, img2);
cvNamedWindow("原图", CV_WINDOW_AUTOSIZE);
cvNamedWindow("膨胀", CV_WINDOW_AUTOSIZE);
cvNamedWindow("腐蚀", CV_WINDOW_AUTOSIZE);
cvShowImage("原图", img);
cvShowImage("膨胀", img1);
cvShowImage("腐蚀", img2);
cvWaitKey(0);
cvReleaseImage(&img);
cvReleaseImage(&img1);
cvReleaseImage(&img2);
cvDestroyWindow("原图");
cvDestroyWindow("膨胀");
cvDestroyWindow("腐蚀");
}
结果图: