I see nothing wrong with this code (except the rejection tests - see below). It does implement a separable 7x7 box filter on an RGBA image (components stored in this order).
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
to be negative, among others.
My solution would be to convert the index to the pair of coordinates
, and check if they remain in their respective range
after offsets are added. This leads to the following conditions, for the
2r+1 x 2r+1
index%4 == 3 || (index%pitch)/4 - r < 0 || (index%pitch)/4 + r >= pitch/4
index%4 == 3 || index/pitch - r < 0 || index/pitch + r >= length/pitch