03.DIP. Filtering
03.DIP. Filtering
Fundamentals
Thanh-Hai Tran
2020 2
Histogram revision
2020 3
Histogram implementation
2020 4
Introduction
2020 5
The mechanics of spatial filter
n A spatial filter
u Neighborhood: small rectangle
u Pre-defined operation: linear and non-linear
n Filtering creates a new pixel
u with coordinates equal to the coordinates of the center of the
neighborhood,
u and whose value is the result of the filtering operation
n A processed (filtered) image is generated as the
center of the filter visits each pixel in the input image
2020 6
The mechanics of spatial filter
n Notation:
u f(x,y) is the original image
u w(x,y) is a filter mask
u g(x,y) is the filtered image
n At any point (x, y) in the image, the response, g(x, y) is
the sum of products of the filter coefficients and the
image pixels encompassed by the filter
2020 7
The mechanics of spatial filter
2020 8
Spatial correlation and convolution
2020 9
2020 10
Vector representation of linear filtering
n When m = n = 3
2020 11
Generating Spatial Filter Masks
2020 12
Generating Spatial Filter Masks
n Solution:
u We sample it about its center
u w1 = h(-1, -1), w2 = h(-1, 0), .. , w9 = h(1, 1)
2020 13
Designing Gaussian Filters
!𝟐 #$𝟐
! 𝟐
n 𝒈 i, j = c e 𝟐𝝈
n c is a normalizing constant
n 𝝈𝟐 = 2, n = 7
2020
Example of other Gaussian Filters
2020
Smoothing Spatial Filters
n Idea:
u Replacing the value of every pixel in an image by the
average of the intensity values in th neighborhood defined
by mask center
u It resuls in an image with reduced sharp transition
n Smoothing Spatial Filters are used for blurring or noise
reduction
n These filters are called averaging filters / lowpass filters
n Side effect: edges are blurred too.
2020 16
Smoothing Spatial Filters
2020 17
Example
2020 18
Example
2020
Order-statistic (non-linear) filters
2020 20
Order-statistic (non-linear) filters
2020 21
Order-statistic (non-linear) filters
2020 22
Example
2020 23
Sharpening Spatial Filters
2020 24
First and second derivatives
2020
The Laplacian for Image Sharpening
n Laplacian:
2020 26
The Laplacian – Mask 3x3
2020
Example
Original image
2020
Unsharp masking and Highboost Filtering
2020 29
Unsharp masking
2020 30
Unsharp masking
2020 31
First order derivative for sharpening
2020 32
gradient operators
n Roberts cross
n Sobel operators
2020 33
Gradient for image enhancement
2020 35
Assigment 1 (week 1-2-3)
2020 36