# Convolution Kernel Questions

This topic is 1862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites

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?

##### Share on other sites

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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634066
• Total Posts
3015315
×