Hello Everyone!

I am wondering about the thory behind the box blur. I have an assignment, and I wrote a program implementing the box blur the way it was described in my assignment which is "When centered on a pixel, its values are multiplied with each corresponding surrounding pixel values, and then divided by the sum of the matrix values" and then it gave a 3 by 3 matrix of all ones.

The code I have works with the r, g and b values separately for an image for both the sum and the product portion of the formula, which I interpreted as (product of one color channel in every element in the matrix)/ (sum of those color channels). This does execute, however an all black image is created. I am wondering where I am going wrong. I did some sample calculations using one color stream just to see it if works, but it is way off. for example (100*100*160*50) / (100+100+160+50) = 80000000/ 410, which is definitely greater than the 255 max for the color value. If I could get some clarification then it would be much appreciated.

Thank you for your time and help