A Filtering Method Is When The Output Is A Weighted Sum of The Input Pixels
A Filtering Method Is When The Output Is A Weighted Sum of The Input Pixels
Spatial Filtering
A filtering method is linear when the output is a weighted
sum of the input pixels.
10/28/21 1
Example
10 5 3 0 0 0
4 6 1 0 0.5 0 8
1 1 8 0 1 0.5
Local image mask Modified image data
neighborhood
10/28/21 2
Example
10/28/21 3
Linear Spatial Filtering
– Correlation
– Convolution
10/28/21 4
Correlation
w(i,j)
f(i,j)
K /2 K /2
g ( x, y ) w( x, y ) f ( x, y )
s K /2 t K /2
w( s, t ) f ( x s, y t )
10/28/21 5
Correlation
10/28/21 6
Correlation
mask
10/28/21 7
Normalized Correlation
10/28/21 8
Correlation (cont’d)
• size
• orientation
• shape (e.g., deformable objects).
10/28/21 9
Convolution
Similar to correlation except that the mask is first flipped
both horizontally and vertically.
K /2 K /2
g ( x, y ) w( x, y ) f ( x, y )
s K /2 t K /2
w( s, t ) f ( x s, y t )
10/28/21 10
Convolution Vs Correlation
Correlation:
Convolution:
10/28/21 11
How do we choose the elements of a mask ?
Typically, by sampling certain functions
10/28/21 12
Gaussian Smoothing
Note: weight
values decrease
with distance
from mask
center!
10/28/21 13
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
10/28/21 14
Averaging Filters
10/28/21 15
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
10/28/21 16
Averaging Filters
Mask size determines the degree of smoothing and loss
of detail
15x15 25x25
10/28/21 17
Averaging vs Gaussian Smoothing
Averaging
Gaussian
10/28/21 18
Averaging Filters
Example: extract, largest, brightest objects
10/28/21 19
Spatial Operations - Neighborhood Operations
10/28/21 20
Smoothing Filters (Non-Linear) (Median)
Very effective for removing “salt and pepper” noise (i.e.,
random occurrences of black and white pixels).
10/28/21 21
Smoothing Filters (Non-Linear) (Median)
Replace each pixel by the median in a neighborhood
around the pixel
10/28/21 22
Sharpening Filters (High Pass filtering)
Useful for emphasizing transitions in image intensity
(e.g., edges).
10/28/21 23
Sharpening Filters (High Pass filtering)
Note that the response of high-pass filtering might be
negative.
Values must be re-mapped to [0, 255]
10/28/21 24