Gaussian Filters
A common tool for filtering images is the Gaussian Filter.
This is a filter that uses a
Gaussian function to create a two-dimensional filter kernel.
But, instead of leaping right
into a 2D filter, we’ll start by examining the use of a Gaussian filter in only one
dimension.
The one-dimensional Gaussian is defined as:
2
2
2
/
2
1
σ
π
i
i
e
h
−
=
1
The parameter sigma determines the amount of smoothing the filter will perform.
A
larger value will cause greater smoothing.
We can do a Gaussian filter on the rows of an
image using a one-dimensional filter.
Example 1 – A
=2 row filter
Suppose you want to create a Gaussian filter on the rows of an image with
σ
=2.
We have
to decide how big we want that filter to be.
A good rule thumb is that
σ
should be about
70% of the size of the filter neighborhood, the range to the left and right of the pixel we
are looking at.
So, we want a neighborhood n such that
σ
=0.7n.
n=2.8, but
neighborhoods are always integers, and need to contain the range, so I’ll round this
number up to 3.
This means the filter kernel size needs to be 7.
One (1) for the pixel
itself and three (3) on each size.
I can compute the filter coefficients using Equation 1:
064
.
0
,
121
.
0
,
176
.
0
,
199
.
0
,
176
.
0
,
121
.
0
,
064
.
0
3
2
1
0
1
2
3
=
=
=
=
=
=
=
−
−
−
h
h
h
h
h
h
h
We can express this as a matrix:
H=[0.064 0.121 0.176 0.199 0.176 0.121 0.064].
Now
we can consider the indices into this matrix as -3, -2, -1, 0, 1, 2, 3, but that’s not really
what a compiler will like, so we’ll consider the matrix to start at zero.
So, h
-3
is location
0.
Any h
k
will be location k+3 in the matrix.
To compute the color at pixel r,c in our
image, we compute the following equation:
∑
∞