Monday, October 14, 2013

Image Filtering : Gaussian Filter

First things first, what is Gaussian filter?

Gaussian filter is a kernel based on the values obtained by plotting Gaussian function.

In my previous post we have seen how to use filter2D function provided by opencv to perform correlation on the images with given kernel.

We also discussed an example of blur operator. This operator assigns equal weight to every element in the neighborhood. But it is quite natural to think that the pixels which are close to target pixel in image should have more weight assigned to them. This is exactly what we try to achieve using Gaussian filter.

Gaussian function is given by,

 The plot of this function looks like this,

Values of Gaussian function have been used to construct this kernel.
As you can see the center pixel has maximum weight of 0.159 and weight values decreases as the distance from center pixel increases. All the pixels which are at same distance from the center pixel have same weight value, are also known as contours.

Following image is formed using Gaussian kernel.

Lets compare results of blur operator in the previous post and

Original Image

Blur Operator

Gaussian Smoothing
As it is evident from the result that features of image are well preserved in case of Gaussian kernel than that of the blur operator.

Sample code for Gaussian Blurring:

No comments:

Post a Comment