Lecture 6
Lecture 6
Spring 2020
●
Discrete Fourier Transform (DFT) of One Variable
●
Extensions to Functions of Two Variables
●
Some Properties of 2D DFT and IDFT
●
Basics of Filtering in the Frequency Domain
2 / 45
Continuous and Discrete Impulse Functions
●
Continuous ●
Discrete
t 0 1 x 0
(t ) ( x)
0 t 0 0 t 0
( x) 1
(t )dt 1
x
f ( x) ( x) f (0)
f (t ) (t )dt f (0)
x
f (t ) (t t0 )dt f (t0 ) f ( x) ( x x ) f ( x )
x
0 0
3 / 45
Impulse Trains
∞
sΔ T (t )= ∑ δ (t −n Δ T )
n=−∞
∞
sΔ X ( x )= ∑ δ ( x−n Δ X )
n=−∞ 4 / 45
FT of Functions of One Continuous Variable
●
The Fourier Transform (FT) of a non-periodic function f(t) is defined as:
{ f (t )} f (t )e j 2ut dt
●
The FT, also shown as F(u), is a function of only u, because variable t is
integrated out.
●
The inverse of FT is defined as:
f (t ) F (u )e j 2ut du
●
The function and its Fourier transform can be shown as a pair:
f (t )⇔ F (u)
5 / 45
FT – Example 1
●
What is the FT of a box function, defined as:
6 / 45
FT – Example 2
t 0
●
What is the FT of a unit impulse located at the origin? (t )
0 t 0
●
Using the FT definition, and the sifting property of the impulse function:
+∞
F (u)= ∫ δ (t )e
− j 2π u t − j2π u 0 0
dt=e =e =1
−∞
7 / 45
FT – Example 3
●
What is the FT of the impulse train: sT (t ) (t nT )
n
●
Its Fourier series, with period ΔT, can be written as:
2n
1 j t
sT (t )
T
e
n
T
●
Because of the symmetry property of the FT: if f (t )⇒ F (u), then F (t)⇒ f (−u)
2π n
j
ΔT n
FT {e }=δ (u− )
ΔT
●
Combining these, we can find the FT of the impulse train as:
2π n
1 ∞ j 1 ∞ n
S (u)=FT {sΔ T (t )}=FT { ∑
Δ T n=−∞
e ΔT
}= ∑
Δ T n=−∞
δ (u−
ΔT
)
8 / 45
Convolution
●
Convolution of two functions involves flipping one function about its origin,
and sliding it past the other. At each displacement, we perform the
computation (sum-of-product).
●
Convolution of two continuous functions is defined as:
f (t ) h(t ) f ( )h(t )d
●
We proved that:
FT
f (t )⊗h(t ) ⇔ H (u) F (u)
IFT
FT
f (t )h (t ) ⇔ H (u)⊗F (u)
IFT
9 / 45
1D Sampling Theory
●
So far we only talked about continuous
functions, either periodic, or non-periodic.
●
Continuous functions need to be sampled
and quantized to be processed by a
computer.
●
Sampling can be modeled by multiplying
the function f(t) with a train of impulses
ΔT apart:
~
f (t ) f (t ) sT (t ) f (t ) (t nT )
n
∞
f k =∫−∞ f (t ) δ (t−k Δ T )dt =f (k Δ T )
10 / 45
Fourier Transform of the Sampled Signal
●
How to find the FT of the sampled signal? Remember the convolution
property of FT:
FT FT
f (t )⊗h(t ) ⇔ H (u) F (u) f (t )h (t ) ⇔ H (u)⊗ F (u)
IFT IFT
~
●
This means that: F (u ) { f (t ) s (t )} F (u ) S (u )
T
●
Remember the FT of the impulse train:
∞ 2π n ∞
1 j 1 n
S (u)=FT {sΔ T (t )}=FT {
ΔT
∑ e ΔT
}=
ΔT
∑ δ (u−
ΔT
)
n=−∞ n=−∞
●
Therefore:
~ 1 n
F (u ) F (u ) S (u )
T
n
F (u
T
)
●
Over-sampled: 1/ΔT is sufficiently large
to separate the copies of the sampled
function’s FT in the frequency domain.
●
Critically-sampled: 1/ΔT is just large
enough to separate the sampled
function’s FT in the frequency domain.
●
Under-sampled: 1/ΔT is not large
enough to separate the sampled
function’s FT in the frequency domain.
●
Sampling Theorem: extraction of a
single copy of a band limited signal from
its samples is possible, if the sampling
rate (1/ΔT) satisfies:
1
2umax
T 12 / 45
Discrete Fourier Transform of One Variable
●
FT of a sampled, band-limited function extending from -∞ to +∞ is a
continuous, periodic function that also extends from -∞ to +∞.
●
In practice, we work with finite number of samples; we need to drive
Discrete Fourier Transform (DFT) of such finite sample sets.
●
Previously, we derived the FT of the sampled data with respect to the FT of
the original data:
~ 1 n
F (u ) F (u ) S (u )
T
n
F (u
T
)
●
This does not provide an expression based on the samples of the data in
the signal domain.
13 / 45
Discrete Fourier Transform of One Variable
●
Let’s apply the FT definition directly to the sampled data:
~ ~ ~
{ f (t )} F (u ) f (t )e j 2ut dt
n
f (t ) (t nT )e j 2ut dt
n
f (t ) (t nT )e j 2ut dt
n
f n e j 2unT
●
The last step follows from the sampling equation using an impulse train
and the sifting property of the impulse function.
14 / 45
Discrete Fourier Transform of One Variable
●
Even though the sampled function is discrete, its FT is continuous and
infinitely periodic with period 1/ΔT.
●
To build the DFT, we need to do sampling over only one period of the FT.
●
Let’s have M equally spaced samples of the FT over one period, from u=0
to u=1/ΔT:
m
u , m 0,1,2, M 1
MT
●
Substituting this in the previous equation we have (DFT):
M 1
Fm f n e j 2mn / M , m 0,1,2, M 1
n 0
●
This means that (IDFT):
M 1
1
fn
M
m
F
m 0
e j 2mn / M
, n 0,1,2, M 1
15 / 45
Discrete Fourier Transform of One Variable
●
To be more consistent, we use x and y for the variables in the signal
domain and u and v for the variables in the frequency domain.
●
Let’s re-write the forward DFT and inverse DFT equations:
M −1
F (u)= ∑ f ( x)e
− j2 π u x/M
u=0,1,2 , ..., M −1
x=0
M −1
1
f ( x)=
M
∑ F (u)e j2 π u x/M
x=0,1,2 , ..., M −1
u=0
16 / 45
Some Properties of 1D DFT
●
Both the forward and inverse DFTs are infinitely periodic, with period M,
and integer k:
F (u)=F (u+kM )
f ( x)=f ( x +kM )
●
Remember discrete 1D convolution defined as:
M −1
f ( x)⊗h( x )= ∑ f (m) h( x−m) x=0,1,2 ,... , M −1
m=0
●
Because of the periodicity of DFT and its inverse, the convolution is also
periodic, and the equation gives only one period of the convolution result.
●
For discrete signals, we perform Circular Convolution.
●
What is the DFT of the sampled function?
M −1
F (u)= ∑ f ( x)e
− j2 π u x / M
u=0,1,2 ,... , M −1
x =0
3
F (0)= ∑ f (x )e
− j 2 π (0) x / 4
=[f (0)+f (1)+f (2)+f (3)]=1+2+4 +4=11
x=0
3
F (1)=∑ f ( x)e− j 2 π (1) x / 4 =1 e 0 +2 e− j π / 2 +4 e− j π +4 e− j 3 π /2 =−3+2 j
x =0
3
F (2)= ∑ f ( x) e
− j 2 π (2)x / 4
=................................................. =−1
x =0
3
F (3)= ∑ f ( x )e− j2 π (3) x /4 =................................................. =−3−2 j
x =0
●
What is the IDFT?
3
1 j 2 π u(0) 1 1
f (0)= ∑ F (u) e = [11−3+2 j−1−3−2 j ]= [4]=1
4 u=0 4 4
f (1)=? , f (2)=? , f (3)=? 18 / 45
2D Extension: 1D and 2D Continuous Impulse
Functions
●
1D ●
2D
t 0 t z 0
(t ) (t , z )
0 t 0 0 otherwise
(t , z )dtdz 1
(t )dt 1
(t , z ) f (t , z )dtdz f (0,0)
f (t ) (t )dt f (0)
f (t ) (t t0 )dt f (t0 )
(t t0 , z z0 ) f (t , z )dtdz f (t0 , z0 )
19 / 45
2D Extension: 1D and 2D Discrete Impulse
Functions
●
1D ●
2D
1 x y 0
1 x 0 ( x, y )
( x) 0 otherwise
0 t 0
( x) 1 ( x, y ) 1
x y
x
f ( x, y) ( x, y) f (0,0)
f ( x) ( x) f (0)
x
x y
f ( x, y) ( x x , y y ) f ( x , y )
f ( x) ( x x ) f ( x )
x
0 0
x y
0 0 0 0
20 / 45
2D Extension: 1D and 2D Continuous Fourier
Transform
●
1D ●
2D
∞ ∞ ∞
F (u)= ∫ f (t )e
− j2π ut
dt F (u , v)= ∫ ∫ f (t , z)e
− j 2 π (u t +v z )
−∞
dt dz
∞ −∞ −∞
∞ ∞
f (t )= ∫ F (u) e j 2 π u t du f (t , z)= ∫ ∫ F (u , v)e j 2 π (u t +v z) du dv
−∞ −∞ −∞
f (t )⇔ F (u) f (t , z)⇔ F (u , v )
●
Example: FT of a 2D box function
Z /2 T /2
sin( π u T ) sin( π v Z )
F (u , v)= ∫ ∫ Ae − j 2 π (u t + v z)
dt dz= ATZ [ ][ ]
−Z /2 −T / 2 (π u T ) (π v Z )
21 / 45
2D Sampling and 2D Sampling Theorem
●
Similar to 1D, sampling in 2D can be done by an impulse train:
sTZ (t , z ) (t mT , z nZ )
m n
●
Samples: f (t , z ) sTZ (t , z )
22 / 45
2D Sampling and 2D Sampling Theorem
●
Function f(t,z) is said to be band limited, if its 2D FT is 0 outside a
rectangle in the frequency domain, by the limits [-umax, umax] and [-vmax,
vmax]:
F (u , v)=0 for |u|≥u max and |v|≥v max
●
The 2D sampling theorem states that a continuous, band-limited function
f(t,z) can be recovered with no error from a set of its samples if the
sampling rates are:
1
>2u max
ΔT
1
>2 v max
ΔZ
23 / 45
2D Aliasing
●
Similar to 1D case, aliasing is created as a result of under-sampling.
●
Two types of aliasing in images:
– Spatial aliasing: related to sampling in the spatial domain, more
pronounced in images with repetitive patterns;
– Temporal aliasing: related to sampling in the time domain for
sequences of images, wagon wheel effect is a common example.
●
Spatial aliasing introduces artifacts such as jaggedness in line features,
spurious highlights, appearance of frequency patterns not present in the
original image.
24 / 45
2D Aliasing – Example 1
●
A camera with resolution of 96x96 pixels; the spatial sampling rate is fixed.
●
Different patterns are to be taken by the camera.
●
All of the patterns are band-limited, but the frequency spans are different.
●
Block sizes of 16, 6, 0.92 and 0.48 pixels, respectively.
●
The bottom two are affected by the aliasing effects.
25 / 45
2D Aliasing – Example 2
●
Aliasing occurs in image re-sampling as well.
●
Image smoothing before re-sampling can be used to reduce the aliasing.
26 / 45
2D Extension: 1D and 2D Discrete Fourier
Transform
●
1D
M −1
F (u)= ∑ f ( x) e− j 2 π u x / M u=0,1 , ... , M −1
x=0
M −1
1
f ( x)=
M
∑ F (u) e j 2 π u x / M x=0,1 ,... , M −1
u=0
f ( x)⇔ F (u)
●
2D
M −1 N −1
F (u , v )= ∑ ∑ f ( x , y) e− j 2 π (ux / M + vy/ N ) u=0,1 ,... , M −1, v=0,1 ,.... , N −1
x=0 y=0
M−1 N −1
1
f ( x , y)=
MN
∑ ∑ F (u , v )e j 2 π (ux / M + vy/ N ) x=0,1 ,... , M −1, y=0,1 ,.... , N −1
u=0 v=0
f ( x , y)⇔ F (u , v)
27 / 45
Some Properties of 2D Discrete Fourier Transform
●
Sampling intervals in spatial and frequency domains:
1
u
MT
v 1
N Z
●
Translation:
j 2 ( u 0 x / M v0 y / N )
f ( x, y ) e F (u u0 , v v0 )
f ( x x0 , y y0 ) F (u, v)e j 2 ( x0u / M y0v / N )
●
Using polar coordinates: x=r cos θ , y=r sin θ , u=ω cos ϕ , v=ω sin ϕ
we have the following pair for the rotated image:
f (r , θ +θ 0 )⇔ F (ω , ϕ +θ 0 )
28 / 45
Some Properties of 2D Discrete Fourier Transform
●
Periodicity:
F (u, v) F (u k1M , v) F (u , v k 2 N )
F (u k1M , v k 2 N ),
f ( x, y ) f ( x k1M , y ) f ( x, y k 2 N )
f ( x k1M , y k 2 N ),
●
Centering the Fourier transform:
f ( x)( 1) x F (u M / 2)
(u0 M / 2)
f ( x, y )( 1) x y F (u M / 2, v N / 2)
(u0 M / 2, v0 N / 2)
29 / 45
2D Discrete Convolution
●
The 1D discrete convolution can be extended to 2D:
M −1 N −1
f (x , y)⊗h (x , y)= ∑ ∑ f (m , n) h( x−m , y−n) for x=0,1 ,... , M −1 , y=0,1 ,... , N −1
m=0 n=0
●
Similar to the 1D case, because of the periodicity of DFT and its inverse,
the convolution is also periodic, and the equation gives only one period of
the convolution result.
●
For discrete signals, we perform Circular Convolution.
●
The 2D discrete convolution theorem is:
DFT {f ⊗h}=DFT {f }. DFT {h}
1
DFT {f . h}= DFT {f }⊗DFT {h}
MN
30 / 45
Convolution vs. Circular Convolution
●
Circular Convolution requires zero-padding
to avoid overlap!
– Mirroring h about the origin;
– Translating the mirrored function by x;
– For each x, calculate the sum-of-
products in the entire domain.
●
To avoid overlapping, we add enough
number of zeros to both f and h.
●
Minimum size after zero-padding, with A
and B as the sizes of f and h respectively:
P A B 1
●
For 2D circular convolution, the same will
be done in both dimensions.
31 / 45
Fourier Spectrum and Phase Angle
●
The Fourier transform is a complex function in general; therefore it can be
shown in a polar form:
F (u, v) | F (u, v) | e j (u ,v )
●
Where the magnitude is called the Fourier spectrum, and defined based
on the real and imaginary part of the F(u,v):
1
| F (u , v) | R 2 (u , v) I 2 (u , v) 2
●
The phase angle is defined as:
I (u, v)
(u, v) tan 1
R (u , v )
●
The power spectrum is defined as:
32 / 45
Fourier Spectrum and Phase Angle – Example 1
●
The original image;
●
FT spectrum, showing small bright
areas in the four corners;
●
Centered spectrum, as a result of:
(x + y )
DFT {f ( x , y)∗(−1) }
●
Result of log transformation of the
previous image: log(1+|F (u , v )|)
●
The zero crossings of the spectrum are
closer in the vertical direction, because
the rectangle is longer in that direction.
33 / 45
Fourier Spectrum and Phase Angle – Example 1
●
Image coordinate translation does not
change its Fourier spectrum. Why?
f ( x x0 , y y0 ) F (u , v)e j 2 ( x0u / M y0v / N )
●
Image coordinate rotation rotates the
Fourier spectrum by the same angle.
Why?
f (r , θ +θ 0 )⇔ F (ω , ϕ +θ 0 )
●
The bottom figure shows the phase
angles for the original, translated and
rotated images.
34 / 45
Fourier Spectrum and Phase Angle – Example 2
●
Spectrum or phase angles; which one is more important?
35 / 45
Summary of DFT Definitions
36 / 45
Summary of DFT Pairs
37 / 45
Basics of Filtering in the Frequency Domain
●
The Fourier transform is computed by combination of the values of the
signal in the spatial domain, modified by the values of the exponential
terms.
●
In general, it is impossible to make direct correspondence between
specific components of an image and its Fourier transform.
●
Since frequency is directly related to spatial rates of change, we can
associate frequencies in the Fourier transform with patterns of intensity
variations in an image.
●
Filtering in the Fourier domain is based on modification of the Fourier
transform to achieve a specific objective, followed by inverse Fourier
transform to obtain the spatial domain representation of the processed
result.
38 / 45
Steps for Filtering in the Frequency Domain
4) Construct a real, symmetric filter transfer function, H(u,v), of size PxQ with
center at (P/2, Q/2);
40 / 45
Filtering in the Frequency Domain - Examples
41 / 45
Filtering in the Frequency Domain - Examples
●
Two ways to design filters:
– Specify the filter in the spatial domain
– Specify the filter in the frequency domain
●
Two ways for implementation:
– Use spatial convolution
– Use DFT and IDFT
42 / 45
Filtering in the Frequency Domain - Examples
43 / 45
What is Next?
●
Image Smoothing Using Lowpass Frequency Domain Filters
●
Image Sharpening Using Highpass Frequency Domain Filters
●
Selective Filtering
●
The Fast Fourier Transform (FFT)
44 / 45
Questions?
[email protected]
45 / 45