Image Processing
Ch4:
Filtering in frequency domain
part2
1
Ch4, lesson 7: summary of properties
Usefulness of FT Concepts:
FT concepts are essential for understanding
the spectral (FD) properties of signals and
systems and have very wide applications such
as filtering, image compression, image
feature representation etc.
16/08/2020 2
Frequency Domain Filtering & Spatial
Domain Filtering
Similar jobs can be done in the spatial and
frequency domains
Filtering in the spatial domain can be easier
to understand
Filtering in the frequency domain can be
much faster – especially for large images
Frequency Domain Filtering
4
Ch4, lesson 8: The basics of filtering in the Frequency Domain (FD)
introduction
It consists of modifying the FT of an input image and
then finding the IFT to get the output image.
Mathematically its given by:
G(u,v)= H(u,v)F(u,v)
5
Ch4, lesson 8: The basics of filtering in the Frequency Domain (FD)
Steps of frequency domain filter
Multiply the input image by (-1)x+y
2. Compute F(u,v)
3. Multiply F(u,v) by a filter function
H(u,v)
4. Compute the inverse DFT
6
6. Multiply by (-1)x+y
Ch4, lesson 9: correspondence between FD & SD filters
Correspondence between FD and SD filtering:
SD: filtering is given by discrete convolution
FD: Discrete convolution in FD is equivalent to
multiplication
Filtering can be done in either domain.
7
Ch4, lesson 10: low pass & high pass filters in FD
Low pass & High pass filters in FD
Low-pass filter: A filter that attenuates high frequencies while
passing low frequencies.- used for blurring (smoothing)
High-pass filter: A filter that attenuates low frequencies while
passing high frequencies. used for sharpening
8
Ch4, lesson 10: low pass & high pass filters in FD
Low pass & High pass filters in FD
1) Low pass - Smoothing filters
1.1) Ideal lowpass filters (very sharp) More smooth
in the edge of
1.2) Butterworth lowpass filters cut-off
1.3) Gaussian lowpass filters (very smooth) frequency
Butterworth filter parameter: filter order
High values: filter has the form of the ideal filter.
Low values: filter has the form of the Gaussian filter.
2) High pass- Sharpening filters
2.1) Ideal highpass filters
2.2) Butterworth highpass filters
2.3) Gaussian highpass filters 9
Ch4, lesson 10: low pass & high pass filters in FD
1) Low pass – image smoothing
Low-pass filter: A filter that attenuates high frequencies while passing
low frequencies.- used for blurring (smoothing)
Image smoothing using FD filters
Noise is usually high frequency.
Image details and edges have high frequency characteristics.
Hence noise and details removal is usually termed smoothing or
blurring.
Smoothing is achieved by lowpass filters (LPFs).
3 types of LPFs will be studied i.e. Ideal LPF, Butterworth LPF and
Gaussian LPF.
10
Ch4, lesson 10: low pass filters
1) Low pass - image Smoothing
Smoothing filters:
1.1) Ideal low pass filters (ILPF)
1 if D(u, v) D0
H (u, v)
0 if D(u, v) D0
1.2) Butterworth low pass filters (BLPF)
1
H (u, v)
1 [ D(u, v) / D0 ]2 n
1.3) Gaussian low pass filters (GLPF)
D 2 ( u ,v ) / 2 D0 2
H (u, v) e
Ch4, lesson 11: ILPF
1.1) 2-D Ideal low pass filter ILPF
The simplest lowpass filter is ILPF, it (cuts off) all high
frequency components that are at distance greater
than a specified distance: D0 from the center
1 if D(u, v) D0
H (u, v)
0 if D(u, v) D0
Where
D(u,v) is the distance from (u,v) to the center of the frequency rectangle
Image size: MxN
Center of the frequency rectangle: (u,v) = (M/2, N/2)
Distance to the center: D(u,v) = [(u – M/2)2 + (v – N/2)2]1/2
12
H(u,v)
Example on 2-D Ideal
low pass filter ILPF
D(u,v)
D0
1 if D(u, v) D0
H (u, v)
(u,v)
0 if D(u, v) D0
1 2 3 4 5 6 7 8 9
1
Center of the frequency rectangle:
2
(M/2, N/2) = (5,5)
3
Suppose D0 = 3
4 The value of H1 = [(5-5)2 + (5-7)2]1/2
5
H1
= 2<3 then H1 = 1
6
7 The value of H2 = [(5-9)2 + (5-2)2]1/2
8 = 5>3 then H2 = 0
9
H2
13
Ch4, lesson 11: ILPF
?How does ILPF function works
•نضرب قيم هذا الماسك ) H(u,vبالقيم المكافئة لها بالصورة ) .F(u,vفنحصل فقط على ال frequenciesداخل
الدائرة
•دائما منتصف الصورة تحمل اهم المعلومات عنها ( اي معظم معلومات الصورة) ,بينما تتوزع التفاصيل
•كل ما14كبر نصف قطر الدائرة (اي ,)D0كل ما حصلنا على صورة اقرب لالصل (.انظر الشريحة التالية)
Ch4, lesson 11: ILPF
كل ما كبر نصف قطر الدائرة (اي ,)D0
كل ما حصلنا على صورة اقرب لالصل
Radius total image power % دائما منتصف الصورة تحمل اهم
5 92.0 المعلومات عنها ( اي معظم معلومات
15 94.6 الصورة) ,بينما تتوزع التفاصيل
30 96.4
80 98
230 pixels 99.5
15
ILPF: example
original Freq.
94.6
92
96.4
98
99.5
16
Ch4, lesson 11: ILPF
Ideal Low Pass Filter results
Result of filtering
Original with ideal low
image pass filter of
Ringing is a characteristics of radius 5
ideal Filter
Result of filtering
Result of filtering with ideal low
with ideal low pass filter of
pass filter of radius 30
radius 15
Result of filtering Result of filtering
with ideal low with ideal low
pass filter of pass filter of
radius 80 radius 230
17
Ideal lowpass filtering is not very practical but they can be implemented on a computer to study
their behavior.
Ringing
effect
18
Ch4, lesson 11: ILPF
Blurring and ringing feature of ILPFs:
The ILPF has sharp cutoffs or discontinuities which cause ringing.
The center of lobe is the cause for blurring but the outer smaller lobes
cause ringing.
We want to achieve blurring with little ringing.
ILPF: Freq.
blurring
ILPF: spatial
F-1
19
ringing
Ch4, lesson 12: BLPF
1.2) Butterworth low pass filter - BLPF:
ILPF transfer function has sharp discontinuities.
BLPF transfer function does not have sharp discontinuities in order
to reduce ringing.
The transfer function of a Butterworth lowpass filter of order n with
cutoff frequency at distance D0 from the origin is defined as:
1
H (u, v)
1 [ D(u, v) / D0 ]2 n
20
Ch4, lesson 12: BLPF
Butterworth low pass filter - BLPF:
1
H (u, v)
1 [ D(u, v) / D0 ]2 n
21
Ch4, lesson 12: BLPF
Butterworth Lowpass Filter (cont…)
Result of
Original filtering with
image Butterworth
filter of order 2
Ringing is not visible in and cutoff radius
any of these images.
5
Result of filtering Result of
with Butterworth filtering with
filter of order 2 Butterworth
and cutoff radius filter of order 2
15 and cutoff
radius 30
Result of
Result of filtering
filtering with
with Butterworth
Butterworth
filter of order 2
filter of order 2
and cutoff radius
and cutoff radius
80
Ch4, lesson 12: BLPF
Ringing increases with filter order (n) as
seen in SD
Ch4, lesson 13: GLPF
1.3) Gaussian Lowpass Filters -GLPF
The transfer function of a Gaussian
lowpass filter is defined as
D ( u ,v ) / 2 D0 2
2
H (u, v) e
Ch4, lesson 12: BLPF
Gaussian low pass filter - GLPF:
25
Ch4, lesson 13: GLPF
Gaussian Lowpass Filters (cont…)
Result of
Original filtering with
image Gaussian filter
No ringing with cutoff
radius 5
Result of Result of
filtering with filtering with
Gaussian filter Gaussian filter
with cutoff with cutoff
radius 15 radius 30
Result of Result of
filtering with filtering with
Gaussian Gaussian filter
filter with with cutoff
cutoff radius radius 230
Lowpass Filters Compared
Result of
Result of
filtering with
filtering with
Butterworth
ideal low pass
filter of order
filter of radius
2 and cutoff
15
radius 15
Result of
filtering with
Gaussian filter
with cutoff
radius 15
Practical applications
A lowpass Gaussian filter is used to connect
broken text
Machine recognition systems have
difficulty in reading broken characters. GLPF with D0 = 80
Practical applications:
Different Lowpass Gaussian filters used
to remove blemishes in a photograph
GLPF, D0=80
1028x732
GLPF, D0=100
Practical applications:
Scan line
588x600 GLPF, D0=30 GLPF, D0=10
30
2)High pass - image Sharpening
Low-pass filter
High-pass filter
High
High
freq.
freq.
Low Low
freq. freq.
High High
freq. freq.
31
Ch4, lesson 14: high pass
2)High pass - image Sharpening
Blurring (smoothing) is achieved by attenuating
التخلصthe HF(high frequency) components of DFT of an
image. (low pass filters)
Sharpening is achieved by attenuating the LF (low
frequency) components of DFT of an image. Where
Edges and fine detail in images are associated with
high frequency components (high pass filters)
High pass filters – only pass the high frequencies,
drop the low ones. High pass frequencies are precisely
the reverse of low pass filters, so:
Hhp(u, v) = 1 – Hlp(u, v)
Ch4, lesson 14: high pass
2)High pass - image Sharpening
Sharpening filters:
2.1) Ideal high pass filters (IHPF)
0 if D(u, v) D0
H (u, v)
1 if D(u, v) D0
2.2) Butterworth high pass filters (BHPF)
1
H (u, v)
1 [ D0 / D(u, v)]2 n
2.3) Gaussian high pass filters (GHPF)
D 2 ( u ,v ) / 2 D0 2
H (u, v) 1 e
Ch4, lesson 15: IHPF
2.1) Ideal High Pass Filters
The ideal high pass filter is given as:
0 if D(u, v) D0
H (u, v)
1 if D(u, v) D0
where D0 is the cut off distance as before
Ch4, lesson 15: IHPF
Ideal High Pass Filters (cont…)
Results of ideal Results of ideal Results of ideal
high pass filtering high pass filtering high pass filtering
with D0 = 15 with D0 = 30 with D0 = 80
Ch4, lesson 16: BHPF
Butterworth High Pass Filters
The Butterworth high pass filter is given as:
1
H (u, v)
1 [ D0 / D(u, v)]2 n
where n is the order and D0 is the cut off
distance as before
Ch4, lesson 16: BHPF
Butterworth High Pass Filters (cont…)
Results of Results of
Butterworth Butterworth
high pass high pass
filtering of filtering of
order 2 with order 2 with
D0 = 15 D0 = 80
Results of Butterworth high pass
filtering of order 2 with D0 = 30
Ch4, lesson 17: GHPF
Gaussian High Pass Filters
The Gaussian high pass filter is given as:
D 2 ( u ,v ) / 2 D0 2
H (u, v) 1 e
where D0 is the cut off distance as before
Ch4, lesson 17: GHPF
Gaussian High Pass Filters (cont…)
Results of Results of
Gaussian Gaussian
high pass high pass
filtering with filtering with
D0 = 15 D0 = 80
Results of Gaussian high
pass filtering with D0 = 30
Highpass Filter Comparison
BF represents a transition
between the sharpness
of the IF and the
smoothness of the GF
GF وIF مرحلة وسطية بينBF يعني يعتبر
GF حاد للغاية بينما يمتازIF حيث يعتبر
بنعومته
Highpass Filter Comparison
Results of ideal Results of Butterworth Results of Gaussian
high pass filtering high pass filtering of high pass filtering with
with D0 = 15 order 2 with D0 = 15 D0 = 15
The 3 HPF SD representation
Periodic Noise
Noise components
Periodic noise can be reduced in
via frequency domain
Are generated due to electrical or electromechanical interference during image
43
acquisition
noisy spectrum
filtered
16/08/2020 44
44
bandreject
45
46
Horizontal
Scan lines
Notch
DFT pass
Notch Notch
47
47
pass reject