Lecture5 Fundamental of Spatial Filtering
Lecture5 Fundamental of Spatial Filtering
Processing
Lecture 5
Fundamental of Spatial Filtering
Fundamentals of Spatial Filtering
• The term filter is borrowed from frequency domain processing
• accepting or rejecting certain frequency components
• They can also be used for non-linear filtering that cannot be done in
frequency domain filter
• Spatial filters
• masks
• kernels
• templates
• windows
Mechanics of Spatial Filtering
• Spatial filter consist of
• A neighborhood (typically a small rectangle)
• A predefined operation involving the neighborhood
• Filtering creates a new pixel at the same location as of original image
but in the new image.
• A filtered (processed) image is generated as the filter visits each pixel
in the input image.
Mechanics of
Spatial Filtering
Mechanics of Spatial Filtering
• At any point x,y in the image the response g(x,y) of the filter is
g(x,y)=w(-1,-1)f(x-1,y-1) + w(-1,0)f(x-1,y) +w(-1,1)f(x-1,y+1)
+w(0,-1)f(x,y-1) + w(0,0)f(x,y) + w(0,1)f(x,y+1)
+w(1,-1)f(x+1,y-1) + w(1,0)f(x+1,y) + w(1,1)f(x+1,y+1)
Spatial Correlation
and Convolution
1-D illustration
Spatial Correlation
and Convolution
2-D illustration
Filters Brief Classification in the book
• Spatial Filters
• Smoothing Spatial Filters
• Smoothing Linear Filters
• Order-Statistic Filters (Non-Linear)
• Sharpening Spatial Filters
• Unsharp Masking and Highboost Filtering
Smoothing Spatial Filters
• Smoothing spatial filters are used for blurring and noise reduction in a
digital image.
• Blurring is used in preprocessing tasks such as removal of small details
from an image prior to object (large details) extraction.
• Two further types
• Smoothing Linear Filters
• Order-Statistic Filters (Non-Linear)
Smoothing Linear Filters
Smoothing Linear Filters
Smoothing Linear Filters
Order-Statistic Filters (Non-Linear)
• Response is based on ordering (ranking) the pixels contained in the
image area along the filter and then determine the value of the
center pixel with the value determined by the ranking result.
• Best known filter in this category is the median filter, which replaces the value
of a pixel by the median of the intensity values in the neighborhood of that
pixel.
Median Filters
• Median filters are quite popular because, for certain types of random
noise, they provide excellent noise-reduction capabilities, with
considerably less blurring than linear smoothing filters of similar size.
• They are particularly effective in the presence of impulse noise, also
called salt-and-pepper noise.
Median Filters
Median
• How median is calculated ?
• Assignment: Write a function in MATLAB that apply median filter on
the input image. Do not use built-in commands.
Sharpening Spatial Filter
• Unsharp Masking:
1. Blur the original
image (using LPF)
2. Subtract the blurred
image from the
original ( the resulting
difference is called the
mask)
3. Add the mask to the
original.
Unsharp Masking and Highboost Filtering