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 …