opencv之图像膨胀

时间:2022-06-04 05:23:26
#include <cv.h>
#include <highgui.h> void main()
{
IplImage* src;
IplImage*dst;
src=cvLoadImage("../../lena.jpg");
dst=cvCreateImage(cvGetSize(src),,); cvNamedWindow("dst");
cvShowImage("dst",src); printf("SRC:\n"); int x,y;
for (y=;y<;y++)
{
for (x=;x<;x++)
{
CvScalar values=cvGet2D(src,y,x);
printf("%3d ",(int)values.val[] );
}
printf("\n");
}
printf("---------------------------------------------\n"); int values[]={,,,,
,,,,
,,,,
,,,
} ;
IplConvKernel*element=;
int cols=,rows=,ancher_x=,ancher_y=;
element=cvCreateStructuringElementEx(cols,rows,ancher_x,ancher_y,CV_SHAPE_CUSTOM,values);
cvDilate(src,dst,element,);
printf("DST:\n");
printf("-------------------膨胀后的结果---------------------\n");
for (y=;y<;y++)
{
for (x=;x<;x++)
{
CvScalar values=cvGet2D(dst,y,x);
printf("%3d ",(int)values.val[] );
}
printf("\n");
}
cvWaitKey();
//system("pause"); }