Spatial filtering fundamentals
by Gleb V. Tcheslavski: gleb@ee.lamar.edu http://ee.lamar.edu/gleb/dip/index.htm
Spring 2008 ELEN 4304/5365 DIP 1
Mechanics of spatial filtering
Considering frequency domain filtering, the effect of LPF applied to an image is to blur (smooth) it. Similar smoothing effect can be achieved by using spatial filters (spatial masks, kernels, templates, or windows). We discussed that a spatial filter consists of a neighborhood and a pre-defined operation performed on the image pixels defining the neighborhood. The result of filtering – a new pixel with coordinated of the neighborhood’s center and the value defined by the operation. g y p If the operation is linear, the filter is said to be a linear spatial filter.
Spring 2008
ELEN 4304/5365 DIP
2
1
4/28/2008
Mechanics of spatial filtering
Assuming a 3 x 3 neighborhood, at any point (x,y) in the image, the response of the spatial filter is
g ( x, y ) = w(−1, −1) f ( x − 1, y − 1) + w(−1, 0) f ( x − 1, y ) + ... + w(0, 0) f ( x, y ) + ... + w(1,1) f ( x + 1, y + 1)
Filter coefficient Pixel intensity
In general:
g ( x, y ) =
s =− a t =− b
∑ ∑ w(s, t ) f ( x + s, y + t )
a
b
Spring 2008
ELEN 4304/5365 DIP
3
Mechanics of spatial filtering
Here a mask size is m x n.
m = 2a + 1 n = 2b + 1
Where a and b are some integers.
For a 3 x 3 mask
Spring 2008
ELEN 4304/5365 DIP
4
2
4/28/2008
Spatial correlation and convolution
Correlation is a process of moving the filter mask over the image and computing the sum of products at each location as previously described. Convolution is the same except that the filter is first rotated by 1800. For a 1D case, we first zeropad f by m-1 zeros on each size. We compute a sum of products in both cases…
Spring 2008 ELEN 4304/5365 DIP 5
Spatial correlation and convolution
Correlation is a function of displacement of the filter. A function containing a single 1 with