Hello, everyone,
I am now do some image processing based dm6467.
I want to do the sobel edge detection over the captured buffer from capture.c, but after the processing, I only got the black image.
the buffer format is YUV422Psemi, first I grayed the image ( set the U,V componet to 0x80 ), then I do the sobel detection over the Y component, but only got a black image.
My sobel source codes are as follows:
the size of GrayArray is 720 x 480 x 2 ( YUV422Psemi ).
unsigned char *Sobel( unsigned char *GrayArray, unsigned char *SobelArray )
{
int width = 720;
int height = 480;
int i;
int j;
int k;
int RowMove = width;
int SobelResult;
int lSobelResult;
int VerticalPlate[9]={2,1,0,-1,-2,-1,0,1,0};
int neighbourx[9]={1,1,0,-1,-1,-1,0,1,0};
int neighboury[9]={0,-1,-1,-1,0,1,1,1,0};
static unsigned char *copy_inbuffer = NULL;
int n;
copy_inbuffer = (unsigned char*) Memory_contigAlloc( width * height, Memory_DEFAULTALIGNMENT);
for ( n = 0; n < width * height; n++ )
{
*copy_inbuffer = *GrayArray;
GrayArray++;
copy_inbuffer++;
}
for ( i = 1; i < height -2; i++ )
{
for ( j = 1; j < width -2; j++ )
{
SobelResult=0;
for ( k=0;k<9;k++ )
{
SobelResult=SobelResult+ copy_inbuffer[RowMove+neighboury[k]*width+j+neighbourx[k]]*VerticalPlate[k];
}
lSobelResult=(int)(SobelResult);
GT_1trace(curTrace, GT_ENTER, "TTTTTTTTTTTTTTTTTTTTTTTTTTT(0x%d)\n",SobelResult );
if(lSobelResult>255)
{
lSobelResult=255;
}
if(lSobelResult<0)
{
lSobelResult=0;
}
SobelArray[RowMove+j]= lSobelResult;
}
RowMove+=width;
}
return SobelArray;
}
could anyone help me?
thank you!
zhiqiang