The box filter has a strong blurring effect that has exactly the size of the kernel and you will see its effect increasing with the radius. Directly proportional. Changing the coefficients will indeed lower the blur but this will become noticeable for very skewed distributions (like the Binomial 1 6 15 20 15 6 1, which approximates a Gaussian).

The running time of the uniform filter, when implemented this way, is proportional to the radius. This can get slow for large radii. You can do better by means of the integral image trick (http://en.wikipedia.org/wiki/Summed_area_table[^]).

**About the tests**

I disagree with the fact that they are identical for the two passes and I see a problem in the second pass: nothing prevents

`index-(pitch*3)`

to be negative, among others.My solution would be to convert the index to the pair of coordinates

`((index%pitch)/4, index/pitch)`

, and check if they remain in their respective range `[0..pitch/4[`

and `[0..length/pitch[`

after offsets are added. This leads to the following conditions, for the `2r+1 x 2r+1`

filter:First pass:

`index%4 == 3 || (index%pitch)/4 - r < 0 || (index%pitch)/4 + r >= pitch/4`

Second pass:

index%4 == 3 || index/pitch - r < 0 || index/pitch + r >= length/pitch