views:

73

answers:

2
+1  Q: 

mean image filter

Starting to learn image filtering and stumped on a question found on website: Applying a 3×3 mean filter twice does not produce quite the same result as applying a 5×5 mean filter once. However, a 5×5 convolution kernel can be constructed which is equivalent. What does this kernel look like?

Would appreciate help so that I can understand the subject better. Thanks.

+1  A: 

3x3 mean:

[1 1 1]
[1 1 1] * 1/9
[1 1 1]

3x3 mean twice:

[1 2 3 2 1]
[2 4 6 4 2]
[3 6 9 6 3] * 1/27
[2 4 6 4 2]
[1 2 3 2 1]

How? Each cell contributes indirectly via one or more intermediate 3x3 windows. Consider the set of stage 1 windows that contribute to a given stage 2 computation. The number of such 3x3 windows that contain a given source cell determines the contribution by that cell. The middle cell, for instance, is contained in all nine windows, so its contribution is 9 * 1/9 * 1/9. I don't know if I've explained it that well, so I hope it makes sense to you.

Marcelo Cantos
Yup thanks Marcelo Carlos, just thought it up - another way to look at it I guess is direct crunching. Suppose G is the 3x3 filter, then the 5x5 filter would be G(G(f)), with f being the filter. By the way, 27 was supposed to be 81, yes?
turmoil
A: 

Marcelo's answer is right. Another way of seeing it (more easy to think it first in one dimension) : we know that the mean filter is equivalent to a convolution with a rectangular window. And we know that the convolution is a linear operation, which is also associative.

Now, applying a mean filter M to a signal X can be written as

Y = M * X

where * denotes convolution. Appying the filter twice would then give

Y = M * (M * X) = (M * M) * X  = M2 * X

This says that filtering twice a signal with a mean filter is the same as filtering it once with an equivalent filter given by M2 = M * M. Now, this consists of applying the mean filter to itself, what gives a more soft filter (a triangular filter in this case). The process can be repeated, (see first graph here) and it can be shown that the equivalent filter for many repetitions of a mean filter (N convolutions of the rectangular filter with itself) tends to a gaussian filter. Further, it can be shown that the gaussian filter has that property you didn't found in the rectangular (mean) filter: two passes of a gaussian filter are equivalent to another gaussian filter.

leonbloy