Convolution Kernel Questions

Started by
1 comment, last by cadjunkie 10 years, 4 months ago

Hi guys,

Some convolution kernels I see are integer based. If my colour intensities are float based [0...1] how should I scale the convolution output.

Do I add up the kernel integers then divide each kernel entry by that sum ? That works with a basic average:


1 1 1
1 1 1
1 1 1
 
becomes
 
1.0f/9.0f ...
...
...

...but what about a Sobel that sums to zero ?


1 0 -1
2 0 -2
1 0 -1

Thanks

Advertisement

You don't divide with a Sobel. Presumably the matrix with all 1 entries really means they should be all 1/9 anyway? A probable rule of thumb would be if the sum isn't zero divide by the sum of the weights and if it is zero don't do that?

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

It really depends on if you want to keep your convolved image in the [0...1] range. If all of the pixels were 1 under the positive side of the Sobel kernel and 0 on the negative side, the value for the center pixel would be 4. If this were flipped, the value would be -4. If you want to normalize, divide all terms by 4. If you don't care about the range, then I wouldn't worry about normalizing.

This topic is closed to new replies.

Advertisement