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("腐蚀");

}

结果图:
这里写图片描述

posted @ 2016-05-23 19:04  huahai  阅读(309)  评论(0编辑  收藏  举报