Spatial Filtering (Chapter 3) : CS474/674 - Prof. Bebis
Spatial Filtering (Chapter 3) : CS474/674 - Prof. Bebis
Spatial Filtering (Chapter 3) : CS474/674 - Prof. Bebis
output image
Spatial Filtering
The word filtering has been borrowed from the frequency
domain.
Filters are classified as:
output image
w(s, t ) f ( x s, y t )
s 1 t 1
for a K x K mask:
g ( x, y )
K /2
K /2
s K /2 t K /2
w( s, t ) f ( x s, y t )
output image
0 0 0 .0
or
Linear vs Non-Linear
Spatial Filtering Methods
A filtering method is linear when the output is a weighted sum
of the input pixels.
Methods that do not satisfy the above property are called nonlinear.
e.g.,
Correlation
w(i,j)
g(i,j)
Output
Image
f(i,j)
g ( x, y ) w( x, y ) f ( x, y )
K /2
K /2
s K /2 t K /2
w( s, t ) f ( x s, y t )
Correlation (contd)
Often used in applications where
we need to measure the similarity
between images or parts of images
(e.g., pattern matching).
Convolution
Similar to correlation except that the mask is first flipped
both horizontally and vertically.
g ( x, y ) w( x, y ) f ( x, y )
K /2
K /2
w( s, t ) f ( x s, y t )
s K / 2 t K / 2
Example
Correlation:
Convolution:
Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
Filters
Smoothing (i.e., low-pass filters)
Reduce noise and small details.
The elements of the mask must be positive.
Sum of mask elements is 1
Gaussian
Filters
Sharpening (i.e., high-pass filters)
Highlight fine detail or enhance detail that has been blurred.
The elements of the mask contain both positive and negative
weights.
Sum of the mask weights is 0
1st derivative
of Gaussian
2nd derivative
of Gaussian
3x3
15x15
5x5
25x25
7x7
image thresholding
= 1.4
mask size:
=3
Averaging
Gaussian
averaging
median
filtering
sharpened images
(A-1)
A=1.4
A=1.9
f
f
|| |
or |
x
y
(approximation)
Example
f
x
f
y
and
good approximation
at (x+1/2,y)
(x,y+1/2)
*
*
good approximation
at (x,y+1/2)
We can implement
and
Other approximations
Sobel
Example
f
x
f
y
(dot product)
Approximate
derivatives:
detect zero-crossings
Laplacian
Sobel