// 5_7.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cv.h>
#include <cvcam.h>
#include <cxcore.h>
#include <highgui.h>
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"cvcam.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"highgui.lib")
int main(int argc, char* argv[])
{
//载入图像
IplImage *pSourceImage = cvLoadImage(argv[1]);
assert(pSourceImage != NULL);
IplImage *pDestionImage = cvCreateImage(cvGetSize(pSourceImage),pSourceImage->depth,pSourceImage->nChannels);
assert(pDestionImage != NULL);
//自定义核
IplConvKernel *pConKernel = cvCreateStructuringElementEx(
5,
5,
2,
2,
CV_SHAPE_RECT);
//执行腐蚀操作
cvErode(pSourceImage,pDestionImage,pConKernel);
//显示结果
cvNamedWindow("Show_Source");
cvNamedWindow("Show_Destion");
cvShowImage("Show_Source",pSourceImage);
cvShowImage("Show_Destion",pDestionImage);
cvWaitKey();
//释放资源
cvReleaseImage(&pSourceImage);
cvReleaseImage(&pDestionImage);
cvDestroyAllWindows();
return 0;
}