# Sobel Filter Don't understand a little thing in the SDK example

I feel I’m going to say something stupid but hey, I’ll say it anyway. In the example of the Sobel filter in the SDK, the function device applying the convolution is the following:

``````__device__ unsigned char

ComputeSobel(unsigned char ul, // upper left

unsigned char um, // upper middle

unsigned char ur, // upper right

unsigned char ml, // middle left

unsigned char mm, // middle (unused)

unsigned char mr, // middle right

unsigned char ll, // lower left

unsigned char lm, // lower middle

unsigned char lr, // lower right

float fScale )

{

short Horz = ur + 2*mr + lr - ul - 2*ml - ll;

short Vert = ul + 2*um + ur - ll - 2*lm - lr;

short Sum = (short) (fScale*(abs(Horz)+abs(Vert)));

if ( Sum < 0 ) return 0; else if ( Sum > 0xff ) return 0xff;

return (unsigned char) Sum;

}
``````

I agree with Horz which gives the following horizontal operator : (-1, 0, -1, -2, 0, 2, -1, 0, 1).

But Vert gives the operator (1, 2, 1, 0, 0, 0, -1, -2, -1). It seemed to me that the vertical operator was : (-1, - 2, -1, 0, 0, 0, 1, 2, 1).

There must be something I did not understand …

I think it is just a matter of how your Y axis is oriented.

When processing raw bitmaps, Y often points downwards (top left coordinate is 0,0), but in many printed illustrations the Y coordinate is defined as pointing upwards. Maybe that explains the discrepancy.

I think it is just a matter of how your Y axis is oriented.

When processing raw bitmaps, Y often points downwards (top left coordinate is 0,0), but in many printed illustrations the Y coordinate is defined as pointing upwards. Maybe that explains the discrepancy.

Hi everyone,

I have a problem with the results of image processing …
I try to implement the edge detection with Sobel, but as you can see, unwanted lines appear in the picture.
Does maybe someone knows why this is so?

The program is similar to the CUDA SDK, but I process about 1000 images with 3- way overlap and therefore can not use texture memory.

Thank you very much

Hi everyone,

I have a problem with the results of image processing …
I try to implement the edge detection with Sobel, but as you can see, unwanted lines appear in the picture.
Does maybe someone knows why this is so?

The program is similar to the CUDA SDK, but I process about 1000 images with 3- way overlap and therefore can not use texture memory.

Thank you very much