Average (or mean) filtering is a method of smoothing images by reducing the amount of intensity variation between neighboring pixels. In this post, we learn the Average Filter in Image Processing.
Mean or Average Filter in Image Processing
The average filter works by moving through the image pixel by pixel, replacing each value with the average value of neighboring pixels, including itself.
There are some potential problems:
- A single pixel with a very unrepresentative value can significantly affect the average value of all the pixels in its neighborhood.
- When the filter neighborhood straddles an edge, the filter will interpolate new values for pixels on the edge and so will blur that edge. This may be a problem if sharp edges are required in the output.
The following example shows the application of an average filter to a simple one-dimensional signal.
A window size of three is used, with one entry immediately preceding and following each entry and following each entry. For y[1] and y[9], extend the left-most or right-most value outside the boundaries of the image Also Read: Sobel Filter in Image Processing
Example: 3 by 3 Mean or Average Filter in Image Processing
- Consider the following 3 by 3 average filter:
- We can write it mathematically as
2D Average filtering example using a 3 x 3 sampling window: Keeping border values unchanged
Extending border values outside with values at boundary
Extending border values outside with 0s (Zero-padding)
On the left is an image containing a significant amount of salt and pepper noise. On the right is the same image after processing with an Average filter an Average filter.