Spatial Filtering (Chapter 3) : Cs6632 DR Imren Dinc
Spatial Filtering (Chapter 3) : Cs6632 DR Imren Dinc
output image
output image
output image
A filtered image
is generated as the
center of the mask
moves to every
pixel in the input
image.
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 (i, j=
) w(i, j ) f (i, j=
)
K /2
K /2
w( s, t ) f (i + s, j + t )
s=
K /2 t =
K /2
Correlation (contd)
Often used in applications where
we need to measure the similarity
between images or parts of images
(e.g., template matching).
Convolution
Similar to correlation except that the mask is first flipped both
horizontally and vertically.
g (i, j=
) w(i, j ) f (i, j=
)
K /2
K /2
w( s, t ) f (i s, j t )
s=
K /2 t =
K /2
Example
Correlation:
Convolution:
Gaussian
1st derivative
of Gaussian
2nd derivative
of Gaussian
Filters
We will mainly focus on two types of filters:
Smoothing (low-pass)
Sharpening (high-pass)
Gaussian
smoothed image
1st derivative
of Gaussian
2nd derivative
of Gaussian
input image
sharpened image
Smoothing Filters
Averaging
Gaussian
Median filtering (non-linear)
3x3
15x15
5x5
25x25
7x7
image thresholding
= 1.4
mask size is
a function of :
=3
Averaging
Gaussian
averaging
median
filtering
Sharpening Filters
Unsharp masking
High Boost filter
Gradient (1st derivative)
Laplacian (2nd derivative)
=
(after contrast
enhancement)
(A-1)
A=1.4
A=1.9
Gradient
The gradient is a vector which has magnitude and direction:
(approximation)
f
f
|+|
|
or |
x
y
Gradient (contd)
Gradient magnitude: provides information about edge strength.
Gradient direction: perpendicular to the direction of the edge.
f
x
f
y
Prewitt
Sobel
f
x
f
y
(isotropic)
Laplacian
The Laplacian (2nd derivative) is defined as:
(dot product)
Approximate
2nd derivatives:
Laplacian (contd)
Laplacian Mask
Laplacian
Sobel