Guassian Smoothing in Csharp by asif

Brief Description

The Gaussian smoothing operator is a 2-D convolution operator that is used to `blur’ images and remove detail and noise.

How It Works

The Gaussian distribution in 1-D has the form:

Eqn:eqngaus1

where Eqn:eqnsigma is the standard deviation of the distribution. We have also assumed that the distribution has a mean of zero (i.e. it is centered on the line x=0). The distribution is illustrated in following diagram.


In 2-D, an isotropic (i.e. circularly symmetric) Gaussian has the form:

Eqn:eqngaus2

This distribution is shown in Figure 2.


Figure 2 2-D Gaussian distribution with mean (0,0) and Eqn:eqnsigma=1
The idea of Gaussian smoothing is to use this 2-D distribution as a `point-spread’ function, and this is achieved by convolution. Since the image is stored as a collection of discrete pixels we need to produce a discrete approximation to the Gaussian function before we can perform the convolution. In theory, the Gaussian distribution is non-zero everywhere, which would require an infinitely large convolution kernel, but in practice it is effectively zero more than about three standard deviations from the mean, and so we can truncate the kernel at this point. Figure 3 shows a suitable integer-valued convolution kernel that approximates a Gaussian with a Eqn:eqnsigma of 1.0.

Figure 3 Discrete approximation to Gaussian function with Eqn:eqnsigma=1.0

Once a suitable kernel has been calculated, then the Gaussian smoothing can be performed using standard convolution methods. The convolution can in fact be performed fairly quickly since the equation for the 2-D isotropic Gaussian shown above is separable into x and y components. Thus the 2-D convolution can be performed by first convolving with a 1-D Gaussian in the x direction, and then convolving with another 1-D Gaussian in the y direction. (The Gaussian is in fact theonly completely circularly symmetric operator which can be decomposed in such a way.) Figure 4 shows the 1-D xcomponent kernel that would be used to produce the full kernel shown in Figure 3 (after scaling by 273, rounding and truncating one row of pixels around the boundary because they mostly have the value 0. This reduces the 7×7 matrix to the 5×5 shown above.). The y component is exactly the same but is oriented vertically.

Figure 4 One of the pair of 1-D convolution kernels used to calculate the full kernel shown in Figure 3 more quickly.
A further way to compute a Gaussian smoothing with a large standard deviation is to convolve an image several times with a smaller Gaussian. While this is computationally complex, it can have applicability if the processing is carried out using a hardware pipeline.

The Gaussian filter not only has utility in engineering applications. It is also attracting attention from computational biologists because it has been attributed with some amount of biological plausibility, e.g. some cells in the visual pathways of the brain often have an approximately Gaussian response.

Basic Working:

The effect of a Gaussian Smoothing 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.

References:

E. Davies Machine Vision: Theory, Algorithms and Practicalities, Academic Press, 1990, pp 42 – 44.

R. Gonzalez and R. Woods Digital Image Processing, Addison-Wesley Publishing Company, 1992, p 191.

R. Haralick and L. Shapiro Computer and Robot Vision, Addison-Wesley Publishing Company, 1992, Vol. 1, Chap. 7.

B. Horn Robot Vision, MIT Press, 1986, Chap. 8.

D. Vernon Machine Vision, Prentice-Hall, 1991, pp 59 – 61, 214.


In this sense it is similar to the mean filter, but it uses a different kernel that represents the shape of a Gaussian (`bell-shaped’) hump. This kernel has some special properties which are detailed below.