it's me again )
I managed to convert my image to gray level and I applied the Sobel filter for edge detection and I haven't got good result .I send you the original_picture , sobel_picture and the code of my fonction and try to help me please
thanks
Code:
int ConvY[3][3]={1,2,1,0,0,0,-1,-2,-1};
int ConvX[3][3]={1,0,-1,2,0,-2,1,0,-1};
double mX,mY,x,y;
int i,j,k,l;
double moy,g;
for(i=(pImage->height)-2;i>=1;i--)
for(j=(pImage->width)-2;j>=1;j--)
{
mX=0;
mY=0;
for( k=-1;k<=1;k++)
{
for(l=-1;l<=1;l++)
{
mX+=(double)pImage->imageData[(i+k)*pImage->widthStep+(j+l)*pImage->nChannels]*ConvX[k+1][l+1];
mY+=(double)pImage->imageData[(i+k)*pImage->widthStep+(j+l)*pImage->nChannels]*ConvY[k+1][l+1];
}
moy=sqrt((double)mX*mX+mY*mY);
if(moy>255) {moy=255;}
pImage->imageData[i*pImage->widthStep+j*pImage->nChannels]=moy;
pImage->imageData[i*pImage->widthStep+j*pImage->nChannels+2]=pImage->imageData[i*pImage->widthStep+j*pImage->nChannels];
pImage->imageData[i*pImage->widthStep+j*pImage->nChannels+1]=pImage->imageData[i*pImage->widthStep+j*pImage->nChannels];
}
}
}
this is the original_picture Image : original_picture.jpg
and the sobel_picture Image : sobel_picture.jpg
thanks