Mean Filtering in CSharp by asif

Brief Description

Mean filtering is a simple, intuitive and easy to implement method of smoothing images, i.e. reducing the amount of intensity variation between one pixel and the next.

How It Works

The idea of mean filtering is simply to replace each pixel value in an image with the mean (`average’) value of its neighbors, including itself. This has the effect of eliminating pixel values which are unrepresentative of their surroundings. Mean filtering is usually thought of as a convolution filter. Like other convolutions it is based around a kernel, which represents the shape and size of the neighborhood to be sampled when calculating the mean. Often a 3×3 square kernel is used, as shown in Figure 1, although larger kernels (e.g. 5×5 squares) can be used for more severe smoothing. (Note that a small kernel can be applied more than once in order to produce a similar but not identical effect as a single pass with a large kernel.)

Figure 1 3×3 averaging kernel often used in mean filtering

Computing the straightforward convolution of an image with this kernel carries out the mean filtering process.

Common Variants

Variations on the mean smoothing filter discussed here include Threshold Averaging wherein smoothing is applied subject to the condition that the center pixel value is changed only if the difference between its original value and the average value is greater than a preset threshold. This has the effect that noise is smoothed with a less dramatic loss in image detail.

Other convolution filters that do not calculate the mean of a neighborhood are also often used for smoothing. One of the most common of these is the Gaussian smoothing filter.

Basic Working:

The effect of a mean Filter on the Image:

The result after convolution is as:

Sample Project:

The GUI of the whole Project is as:

The project is a part of the series of the image processing articles written just for the prosperity and help for the students searching for Image Processing free stuff.


R. Boyle and R. Thomas Computer Vision: A First Course, Blackwell Scientific Publications, 1988, pp 32 – 34.

E. Davies Machine Vision: Theory, Algorithms and Practicalities, Academic Press, 1990, Chap. 3.

D. Vernon Machine Vision, Prentice-Hall, 1991, Chap. 4.

It is often used to reduce noise in images. It is the most common of all the filtering techniques.