Chapter 4: Filtering in The Frequency Domain
Chapter 4: Filtering in The Frequency Domain
Frequency Domain
Outline
► Fourier Transform
4/7/2019 2
Fourier Series and Fourier Transform: History
► Jean Baptiste Joseph Fourier, French mathematician and physicist
(03/21/1768-05/16/1830) http://en.wikipedia.org/wiki/Joseph_Fourier
Permanent
Orphaned: at nine
Secretary of the
French Academy of
Egyptian expedition Sciences: 1822
with Napoleon I:
1798 Théorie analytique
Governor of Lower de la chaleur :
Egypt 1822
(The Analytic
Theory of Heat)
4/7/2019 3
Fourier Series and Fourier Transform: History
► Fourier Series
Any periodic function can be expressed as the sum of sines
and /or cosines of different frequencies, each multiplied by
a different coefficients
► Fourier Transform
Any function that is not periodic can be expressed as the
integral of sines and /or cosines multiplied by a weighing
function
4/7/2019 4
Fourier Series: Example
4/7/2019 5
Preliminary Concepts
| C |= R 2 + I 2 and = arctan( I / R )
C =| C | (cos + j sin )
Using Euler's formula,
C =| C | e j
4/7/2019 6
Fourier Series
ce
j t
f (t ) = n
T
n =−
where
2 n
1 T /2 −j t
cn = f (t )e T
dt for n = 0, 1, 2,...
T −T /2
4/7/2019 7
Impulses and the Sifting Property (1)
A unit impulse of a continuous variable t located
at t =0, denoted (t ), defined as
if t = 0
(t ) =
0 if t 0
and is constrained also to satisfy the identity
−
(t )dt = 1
( x) = 1
x =−
The sifting property
x =−
f ( x) ( x − x0 ) = f ( x0 )
x =−
f ( x) ( x) = f (0)
4/7/2019 9
Impulses and the Sifting Property (3)
4/7/2019 10
Fourier Transform: One Continuous Variable
4/7/2019 11
Fourier Transform: One Continuous Variable
W /2
F ( ) = f (t )e − j 2 t
dt = Ae − j 2t dt
− −W /2
−A − j 2 t W /2 A
= e = e jW − e − jW
j 2 −W /2 j 2 W
sin(W )
= AW
(W )
4/7/2019 12
Fourier Transform: Impulses
= e − j 2 0
=1
The Fourier transform of a unit impulse located at t = t0 :
F ( ) = (t − t0 )e − j 2t dt
−
= e − j 2t0
=cos(2 t0 ) − j sin (2 t0 )
4/7/2019 13
Fourier Transform: Impulse Trains
Impulse train sT (t ), sT (t ) = (t − nT )
n =−
c
j t
sT (t ) = n e T
n =−
where
2 n
1 T /2 −j t
cn =
T −T /2
sT (t )e T
dt
4/7/2019 14
Fourier Transform: Impulse Trains
1 0 1
= e = n )t
− j 2 ( −
T TT n
= e dt = ( − )
− T
2 n n
2 n n
( j −T t ) 1= ( j − t )e j 2t du
−
1
sT (t ) = c n e T= −
e T T
n =−2 nt T n =−
j
= e T
4/7/2019 15
Fourier Transform: Impulse Trains
Let S ( ) denote the Fourier transform of the
periodic impulse train S T (t )
2 n
1
S ( ) = S T (t ) = e
j t
T
T n =−
1 j 2Tn t
= e
T n =−
1 n
=
T n =−
( −
T
)
4/7/2019 16
Fourier Transform and Convolution
The convolution of two functions is denoted
by the operator
f (t ) h(t ) = f ( ) h(t − ) d
−
f ( ) h (t − )e − j 2t dt d
=
− −
= f ( ) H ( )e − j 2 d
−
=H ( ) f ( )e − j 2 d
−
=H ( ) F ( )
4/7/2019 17
Fourier Transform and Convolution
f (t ) h(t ) H ( ) F ( )
f (t )h(t ) H ( ) F ( )
4/7/2019 18
Fourier Transform of Sampled Functions
f (t ) = f (t ) sT (t )
=
n =−
f (t ) (t − nT )
4/7/2019 19
Fourier Transform of Sampled Functions
F ( ) = f (t ) = f (t ) sT (t ) = F ( ) ? S ( )
F ( ) = F1( ) S ( ) = n F ( ) S ( − )d
S ( ) =
1T n =−
( −
T
−
)
n
= F ( ) ( − − )d
T −
n =− T
1 n
=
T
n =−
−
F ( ) ( − −
T
) d
1 n
=
T
n =−
F ( −
T
)
4/7/2019 20
Question
1. Continuous
2. Discrete
4/7/2019 21
Fourier Transform of Sampled Functions
► A bandlimited signal is a signal whose Fourier transform
is zero above a certain finite frequency. In other words, if
the Fourier transform has finite support then the signal is
said to be bandlimited.
x(t ) = sin(2 ft + )
4/7/2019 22
Fourier Transform of Sampled Functions
− max max
Over-sampling
1
2 max
F ( ) = T
1 n
T
n =−
F ( −
T
) Critically-sampling
1
= 2 max
T
under-sampling
1
2 max
4/7/2019 T 23
Nyquist–Shannon sampling theorem
1
► Sufficient separation is guaranteed if 2max
T
Sampling theorem: A continuous, band-limited function
can be recovered completely from a set of its samples if
the samples are acquired at a rate exceeding twice the
highest frequency content of the function
4/7/2019 24
Nyquist–Shannon sampling theorem
?
f (t ) = F ( )e j 2t d
−
4/7/2019 25
Aliasing
4/7/2019 26
Aliasing
4/7/2019 27
Aliasing
4/7/2019 28
Function Reconstruction from Sampled Data
F ( ) = H ( ) F ( )
f (t ) = −1
F ( )
= −1
H ( ) F ( )
= h (t ) f ( t )
f (t ) = f (nT )sinc (t − nT ) / nT
n =−
4/7/2019 29
The Discrete Fourier Transform (DFT) of One
Variable
M −1
F ( ) = f ( x)e − j 2 x / M , =0,1,..., M − 1
x =0
M −1
1
f ( x) =
M
F
=0
( ) e j 2 x / M
, x = 0,1, 2,..., M − 1
4/7/2019 30
2-D Impulse and Sifting Property: Continuous
if t = z = 0
The impulse (t , z ), (t , z ) =
0 otherwise
and − −
(t , z )dtdz = 1
4/7/2019 31
2-D Impulse and Sifting Property: Discrete
1 if x = y = 0
The impulse ( x, y), ( x, y ) =
0 otherwise
x =− y =−
f ( x, y ) ( x, y ) = f (0, 0)
and
x =− y =−
f ( x, y ) ( x − x0 , y − y0 ) = f ( x0 , y0 )
4/7/2019 32
2-D Fourier Transform: Continuous
F ( , ) = f (t , z )e − j 2 ( t + z )
dtdz
− −
and
f (t , z ) = f ( , )e j 2 ( t + z )
d d
− −
4/7/2019 33
2-D Fourier Transform: Continuous
F ( , ) = f (t , z )e − j 2 ( t + z ) dtdz
− −
T /2 Z /2
= Ae − j 2 ( t + z ) dtdz
−T /2 − Z /2
sin(T ) sin( T )
= ATZ T
T
4/7/2019 34
2-D Sampling and 2-D Sampling Theorem
2 − D impulse train:
sT Z (t , z ) = (t − mT , z − nZ )
m =− n =−
4/7/2019 35
2-D Sampling and 2-D Sampling Theorem
4/7/2019 37
Aliasing in Images: Example
In an image system, the
number of samples is fixed at
96x96 pixels. If we use this
system to digitize checkerboard
patterns …
Under-sampling
4/7/2019 38
Aliasing in Images: Example
Re-sampling
4/7/2019 39
Aliasing in Images: Example
Re-sampling
4/7/2019 40
Moiré patterns
http://en.wikipedia.org/wiki/Moiré_pattern
4/7/2019 41
Moiré patterns
4/7/2019 42
Moiré patterns
4/7/2019 43
Moiré patterns
A moiré pattern
formed by
incorrectly down-
sampling the
former image
4/7/2019 44
2-D Discrete Fourier Transform and Its
Inverse
DFT:
M −1 N −1 − j 2 ( x / M + y / N )
F ( , ) = f ( x, y )e
x =0 y =0
IDFT:
M −1 N −1 j 2 ( x / M + y / N )
1
f ( x, y ) =
MN
F ( , )e
x =0 y =0
4/7/2019 45
Properties of the 2-D DFT
relationships between spatial and frequency intervals
4/7/2019 46
Properties of the 2-D DFT
translation and rotation
f ( x, y )e j 2 ( 0 x / M + 0 y / N ) F ( − 0 , − 0 )
and
− j 2 ( x0 / M + y0 / N )
f ( x - x0 , y - y0 ) F ( , )e
f ( x, y ) = f ( x + k1M , y ) = f ( x, y + k2 N ) = f ( x + k1M , y + k 2 N )
f ( x)e j 2 ( 0 x / M ) F ( − 0 )
0 = M / 2, f ( x)(−1) x F ( − M / 2)
f ( x, y )(−1) x + y F ( − M / 2, − N / 2)
4/7/2019 48
Properties of the 2-D DFT
periodicity
4/7/2019 49
Properties of the 2-D DFT
Symmetry
4/7/2019 50
Properties of the 2-D DFT
Fourier Spectrum and Phase Angle
Power spectrum
P(u, v) =| F (u, v) |2 = R 2 (u, v) + I 2 (u, v)
Phase angle
I (u, v)
(u,v)=arctan
R (u , v )
4/7/2019 51
4/7/2019 52
4/7/2019 53
Example: Phase Angles
4/7/2019 54
Example: Phase Angles and The Reconstructed
4/7/2019 55
2-D Convolution Theorem
1-D convolution
M −1
f ( x ) h( x ) = f ( m)h( x − m)
m =0
2-D convolution
M −1 N −1
f ( x, y ) h ( x, y ) = f (m, n)h( x − m, y − n)
m =0 n =0
x = 0,1,2,..., M − 1; y = 0,1,2,..., N − 1.
f ( x, y ) h( x, y ) F (u, v) H (u, v)
f ( x, y )h( x, y ) F (u, v) H (u, v)
4/7/2019 56
An Example of Convolution
Mirroring h
about the
origin
Translating
the mirrored
function by x
Computing the
sum for each
x
4/7/2019 57
An Example of Convolution
It causes the
wraparoun
d error
It can be
solved by
appending
zeros
4/7/2019 58
Zero Padding
P ≥A+B-1
4/7/2019 59
Zero Padding
► Let f(x,y) and h(x,y) be two image arrays of sizes A×B and
C×D pixels, respectively. Wraparound error in their
convolution can be avoided by padding these functions
with zeros
f ( x, y ) 0 x A -1 and 0 y B -1
f p ( x, y ) =
0 A x P or B y Q
h ( x, y ) 0 x C -1 and 0 y D -1
h p ( x, y ) =
0 C x P or D y Q
Here P A + C − 1; Q B + D − 1
4/7/2019 60
Summary
4/7/2019 61
Summary
4/7/2019 62
Summary
4/7/2019 63
Summary
4/7/2019 64
The Basic Filtering in the Frequency Domain
4/7/2019 65
The Basic Filtering in the Frequency Domain
g ( x, y ) = −1{H (u , v) F (u , v)}
4/7/2019 66
The Basic Filtering in the Frequency Domain
4/7/2019 67
The Basic Filtering in the Frequency Domain
4/7/2019 68
The Basic Filtering in the Frequency Domain
4/7/2019 69
Zero-Phase-Shift Filters
−1
g ( x, y ) = {H (u, v) F (u, v)}
F (u, v) = R(u, v) + jI (u, v)
−1
g ( x, y) = H (u, v) R(u, v) + jH (u, v) I (u, v)
Filters affect the real and imaginary parts equally,
and thus no effect on the phase.
These filters are called zero-phase-shift filters
4/7/2019 70
Examples: Nonzero-Phase-Shift Filters
Even small
Phasechanges
angle is in the phase angle can ishave
Phase angle
dramaticmultiplied
(usually by undesirable) effects on the
multiplied by filtered
output 0.5 0.25
4/7/2019 71
Summary:
Steps for Filtering in the Frequency Domain
1. Given an input image f(x,y) of size MxN, obtain the
padding parameters P and Q. Typically, P = 2M and Q = 2N.
g p ( x, y) = real −1 G(u, v) (−1) x + y
4/7/2019 73
An Example:
Steps for Filtering in the Frequency Domain
4/7/2019 74
Correspondence Between Filtering in the
Spatial and Frequency Domains (1)
4/7/2019 75
Correspondence Between Filtering in the
Spatial and Frequency Domains (2)
Let H (u ) denote the difference of Gaussian filter
- u 2 /212 - u 2 /2 22
H (u ) = Ae − Be
with A B and 1 2
4/7/2019 76
Correspondence Between Filtering in the
Spatial and Frequency Domains (3)
4/7/2019 77
Correspondence Between Filtering in the
Spatial and Frequency Domains: Example
600x600
4/7/2019 78
Correspondence Between Filtering in the
Spatial and Frequency Domains: Example
4/7/2019 79
Generate H(u,v)
h( x, y) 0 x 2 and 0 y 2
hp ( x, y) =
0 3 x 602 or 3 y 602
4/7/2019 80
Generate H(u,v)
4/7/2019 81
Image Smoothing Using Filter Domain Filters:
ILPF
4/7/2019 82
Image Smoothing Using Filter Domain Filters:
ILPF
4/7/2019 83
ILPF Filtering Example
4/7/2019 84
ILPF
Filtering
Example
4/7/2019 85
The Spatial Representation of ILPF
4/7/2019 86
Image Smoothing Using Filter Domain Filters:
BLPF
Butterworth Lowpass Filters (BLPF) of order n and
with cutoff frequency D0
1
H (u , v ) =
1 + D(u, v) / D0
2n
4/7/2019 87
4/7/2019 88
The Spatial Representation of BLPF
4/7/2019 89
Image Smoothing Using Filter Domain Filters:
GLPF
By letting = D0
− D 2 ( u , v )/2 D02
H (u , v ) = e
4/7/2019 90
Image Smoothing Using Filter Domain Filters:
GLPF
4/7/2019 91
4/7/2019 92
Examples of smoothing by GLPF (1)
4/7/2019 93
Examples of smoothing by GLPF (2)
4/7/2019 94
Examples of smoothing by GLPF (3)
4/7/2019 95
Image Sharpening Using Frequency Domain
Filters
H HP (u, v) = 1 − H LP (u, v)
4/7/2019 96
Image Sharpening Using Frequency Domain
Filters
4/7/2019 97
4/7/2019 98
The Spatial Representation of Highpass
Filters
4/7/2019 99
Filtering Results by IHPF
4/7/2019 100
Filtering Results by BHPF
4/7/2019 101
Filtering Results by GHPF
4/7/2019 102
Using Highpass Filtering and Threshold for
Image Enhancement
BHPF
(order 4 with a cutoff
frequency 50)
4/7/2019 103
The Laplacian in the Frequency Domain
H (u, v) = −4 2 (u 2 + v 2 )
Enhancement is obtained
g ( x, y) = f ( x, y ) + c2 f ( x, y ) c = -1
4/7/2019 104
The Laplacian in the Frequency Domain
= −1 1 + 4 2 D 2 (u, v) F (u, v)
4/7/2019 105
The Laplacian in the Frequency Domain
4/7/2019 106
Unsharp Masking, Highboost Filtering and
High-Frequency-Emphasis Fitering
g mask ( x, y ) = f ( x, y ) − f LP ( x, y )
g ( x, y ) = −1 1 + k * 1 − H LP (u, v) F (u, v)
= −1 1 + k * H HP (u, v) F (u, v)
4/7/2019 107
Unsharp Masking, Highboost Filtering and
High-Frequency-Emphasis Fitering
4/7/2019 108
Gaussian Filter
D0=40
High-Frequency-Emphasis Filtering
Gaussian Filter
K1=0.5, k2=0.75
4/7/2019 109
Homomorphic Filtering
f ( x, y) = i( x, y)r ( x, y)
f ( x, y)
= i ( x, y ) r ( x, y ) ?
z( x, y) = ln f ( x, y) = ln i( x, y) + ln r ( x, y)
4/7/2019 110
Homomorphic Filtering
4/7/2019 111
Homomorphic Filtering
H (u, v) = ( H − L ) 1 − e
− c D2 ( u ,v )/ D02
+
L
4/7/2019 113
L = 0.25
Homomorphic
H = 2
Filtering
c =1
D0 = 80
4/7/2019 114
Homomorphic Filtering
4/7/2019 115
Selective Filtering
Non-Selective Filters:
operate over the entire frequency rectangle
Selective Filters
operate over some part, not entire frequency rectangle
• bandreject or bandpass: process specific bands
• notch filters: process small regions of the frequency
rectangle
4/7/2019 116
Selective Filtering:
Bandreject and Bandpass Filters
H BP (u, v) = 1 − H BR (u, v)
4/7/2019 117
Selective Filtering:
Bandreject and Bandpass Filters
4/7/2019 118
Selective Filtering:
Notch Filters
Zero-phase-shift filters must be symmetric about the origin.
A notch with center at (u0, v0) must have a corresponding
notch at location (-u0,-v0).
where H k (u, v) and H - k (u, v) are highpass filters whose centers are
at (uk , vk ) and (-uk , -vk ), respectively.
4/7/2019 119
Selective Filtering:
Notch Filters
Q
H NR (u, v) = H k (u, v) H − k (u, v)
k =1
where H k (u, v) and H - k (u, v) are highpass filters whose centers are
at (uk , vk ) and (-uk , -vk ), respectively.
2 1/2
D− k (u, v) = (u − M / 2 + uk ) + (v − N / 2 + vk )
2
4/7/2019 120
Examples:
Notch
Filters (1)
A Butterworth notch
reject filter D0 =3
and n=4 for all
notch pairs
4/7/2019 121
Examples:
Notch Filters
(2)
4/7/2019 122
4/7/2019 123