Side note: First draft on Mar 18 2011. Everything popular tends to become a verb. “Let’s Google it.”, “Did you tweet today?”… Well, Gaussian deserves to be a verb also.

1. 1-D Gaussian Filter

1-D Gaussian filter can be created according to the normal distribution function below,

image

The sample matlab code is given below,

image

A plot of the GUASS will give you the graph below,

image

2. 2-D Gaussian Filter

2-D Gaussian Filter can be created based on the following formula,

image

The sample matlab code is given below,

image

The surfc function gives the plot below,

image

2. fspeical and imfilter: 2-D Gaussian Filter

fspecial is used to create several kinds of predefined 2-D filter in matlab, including “gaussian”. imfilter can be used to apply the created filter to multidimensional images.

fspecial takes three input parameters, with the syntax h = fspecial(‘gaussian’, hsize, sigma). hsize can be a vector specifying the number of rows and cols in the generated filter h, or a scalar indicating equal size for height and width. Sigma is the standard deviation marking the thiness of the gaussian.

imfilter takes at least two input parameters, with the syntax B = imfilter(A, H, …), where A is the input matrix, H is the filter. The common options include following,

  • Output Size Options:
    1. ‘same’: output is the same size as input. Default behavior if not specified
    2. ‘full’: output is full filtered result, which is larger than input.
  • Correlation and Convolution Options:
    1. ‘corr’: use correlation operations for filtering. Default behavior if not specified.
    2. ‘conv’: use convolution operations for filtering.

This predefined Gaussian filter use the formula below to create the filter,

image

Sample matlab code is given as below,

image

The surfc(h) gives the following plot,

image

References:

1. http://www.mathworks.com/help/toolbox/images/ref/fspecial.html

2. http://www.mathworks.com/help/toolbox/images/ref/imfilter.html

 

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.