BUG in cvCreateStructuringElementEx()?

asked 2014-03-07 00:59:42 -0500

opencv version 2.3.1

computer platform: win7 32-bit,visual stdio 2008

My code is here :

int _tmain(int argc, _TCHAR* argv[]) { IplImage src,blade,*src_3; src = cvLoadImage("src_2.jpg",0); blade = cvLoadImage("g_blade.jpg",0); src_3 = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U,1);

int *value,i,j;
value = (int *)malloc(sizeof(int)*blade->width*blade->height);
memset(value,0,sizeof(int)*blade->width*blade->height);

for (i=0;i<blade->height;i++)
{
    for (j=0;j<blade->width;j++)
    {
        if ((unsigned char)blade->imageData[i*blade->width+j] == 255)
        {
            value[i*blade->width+j] = 1;
        }
    }
}

printf("%d",count);
IplConvKernel *and;
and = cvCreateStructuringElementEx(blade->width,blade->height,0,0,CV_SHAPE_CUSTOM,value);
cvDilate(src,src_3,and);

cvShowImage("test",src_3);
cvNamedWindow("test",0);
cvWaitKey(0);

return 0;

} src_2.jpg: C:\fakepath\src_2.jpg g_blade.jpg: C:\fakepath\g_blade.jpg but the result is absurd. C:\fakepath\src3.jpg I can't understand. Can anyone help me ? :)

edit retag flag offensive close merge delete