- Dr. Iyad Jafar
Digital Image Analysis and Processing CPE 0907544
Filtering in the Frequency Domain – Part I Introduction
Chapter 4 Sections : 4.1-4.6
Digital Image Analysis and Processing CPE 0907544 Filtering in the - - PowerPoint PPT Presentation
Digital Image Analysis and Processing CPE 0907544 Filtering in the Frequency Domain Part I Introduction Chapter 4 Sections : 4.1-4.6 Dr. Iyad Jafar Outline Background Preliminary Concepts Sampling The 1D Discrete Fourier
Filtering in the Frequency Domain – Part I Introduction
Chapter 4 Sections : 4.1-4.6
2
In 1807, the French mathematician Jean Fourier
proposed that any periodic function that satisfies some mild mathematical conditions can be expressed as the sum of sines and/or cosines of different frequencies and amplitudes
Now, we know this as Fourier series Even aperiodic functions that have finite energy can be
represented as an integral of sines and/or cosines multiplied weighting function. This formulation is known as Fourier transform
Both formulations have an important feature
A function represented in Fourier series or transform can be
fully reconstructed into its original form without any loss of information
3
The use of Fourier analysis was in the field of heat
diffusion.
The usefulness of Fourier transform is of greater
importance and applicability in many fields
The availability of digital computers and the discovery
field of signal processing
Our focus in this course will be on Fourier Transform
as we will be working with images of finite duration (energy).
Specifically, we will use Fourier transform as a tool to
study filtering in the frequency domain
4
Complex Numbers
A complex number C is represented by
C = R + jI
Complex numbers can be viewed as a point in the
complex plane
Representation of complex number in polar coordinates
C = |C|ejθ = |C| (cos θ + j sin θ)
where
|C| = (R2+I2)1/2 θ = tan-1(I/R)
5
Real Imaginary Magnitude Phase
Impulses
A unit impulse of continuous variable located at t=t0 is
defined as constrained to
Sifting property
6
, t t δ(t t ) 0 , t t δ(t t )dt = 1
f (t )δ(t t )dt = f(t )
Impulses
In the discrete domain
constrained to and sifting property becomes
7
1 , t t δ(t t ) 0 , t t δ(t t ) = 1
f (t )δ(t t ) = f(t )
Impulses
Impulse Train
A set of infinite, periodic impulses that are ∆T apart
8
T n
s (t ) = δ(t n T )
The Fourier Series of Periodic Functions
The Fourier series of a continuous periodic function f(t)
with period T is where
9
2πn j t T n n
f (t ) = c e
2 2 2
1
T / πn j t T n T /
c = f (t ) e dt , n = 0, 1, 2,... T
The Fourier Transform of Functions of One
ContinuousVariable
The Fourier transform of a continuous function f(t) of a
continuous variable t
We can reconstruct f(t) back using
10
2 j πμt
f (t ) = F(μ) = f (t ) e dt
1 2 j πμt
F( μ) = f (t ) = F( μ) e dμ
The Fourier Transform of One Continuous
Variable
Example 4.1. Compute the Fourier transform of the
function f(t) shown below
11
The Fourier Transform of One Continuous
Variable
Example 4.1 – continued Usually we work with the
magnitude of F(u)
12
sin(πμW ) F(μ) = AW = AW sinc(πμW ) πμW
sin(πμW ) F(μ) = AW = AW sinc(πμW ) πμW
The Fourier Transform of One Continuous
Variable
Example 4.2. Compute the Fourier transform of the
unit impulse located at t=0
13
2
1
j πμt
δ(t ) = F(μ) = δ(t ) e dt
The Fourier Transform of One Continuous
Variable
Example 4.3. Compute the Fourier transform of the
unit impulse located at t=t0
14
2 2 j π μ t j π μ t
δ(t t ) = F(μ) = δ(t t ) e dt e
2 j π au
The Fourier
Transform of One Continuous Variable
Example 4.4. Compute the inverse Fourier transform
15
1 2 2 j π μ t j π a t
2 j π a t
The Fourier
Transform of One Continuous Variable
Example 4.5. Compute the Fourier transform of
sin(2πat) and cos(2πat)
16
1 sin(2 πat) δ(μ a ) δ(μ a ) 2 j
1 cos(2 πat) δ(μ a ) δ(μ a ) 2
The Fourier
Transform of One Continuous Variable
Example 4.6. Compute the Fourier transform of the
impulse train with period ∆T
17
1
T n
n S (t ) = S(μ) = δ( μ ) T T
T n
s (t ) = δ(t n T )
ConvolutionTheorem
The convolution of two continuous functions f(t) and
h(t) where t is a continuous variable is given by
It
can be easily shown that convolution in the spatial/time domain is equivalent to multiplying the Fourier transforms of the two functions in the frequency domain
18
f(t) h(t) F(μ) H(μ) f (t) h(t) = f (τ ) h(t-τ )dτ
ConvolutionTheorem – cont’d
Similarly, convolving two functions in the frequency
domain is defined as
It can be easily shown that convolution in the frequency
domain is equivalent to multiplying the two functions in the original domain
19
f(t) h(t) F(μ) H(μ) F(μ) H(μ) = F(τ ) H(μ-τ )dτ
Sampling is required to convert continuous signals
into discrete form
Collecting samples of a signal/function f(t) that are
spaced by ∆T can be viewed as multiplying the signal by an impulse train s∆T(t) with period ∆T
20
x
Δ
Δ
~ T n
f(t ) f(t ) s (t ) = f(t )δ(t n T )
The value of each sample fk can be computed by
integration
21
Δ Δ
k
f f ( t ) δ(t-n T)dt = f (k T )
The Fourier
Transform of Sampled Function
Let F(u) denotes the Fourier transform of f(t), then
according to convolution theorem, the Fourier transform is the convolution between F(u) and the Fourier transform of s∆T(t) where
22
Δ
~ ~ T
F( μ ) f ( t ) f ( t )s ( t ) = F( μ ) S( μ )
1
T n
n s (t ) = S(μ) = δ( μ ) T T
The Fourier
Transform of Sampled Function
Carrying out convolution in frequency domain
23
1 Δ 1 Δ 1 Δ
~ n n n
F( μ ) F( μ ) S( μ ) F( τ )S( μ τ )dτ n = F( τ ) δ( μ τ )dτ T T n = F( τ )δ( μ τ )dτ T T n = F( μ ) T T
The Fourier
Transform of Sampled Function
The previous formulation implies that the Fourier
transform of a sampled function is simply an infinite, periodic sequence of copies of F(u)that are centered at multiples of 1/∆T
24
Sampling
The Sampling
Theorem
If f(t) represents a function whose Fourier transform
F(u) is band-limited, i.e. F(u) = 0 , u >= |umax|, then the
spectrum if the sampling rate is at least twice the maximum frequency in F(u)
We have three different cases
Under-sampling (1/∆T < 2umax) Critically sampling; sampling at Nyquest rate (1/∆T = 2umax) Over-sampling (1/∆T > 2umax)
25
1
max
2μ T
The Sampling
Theorem
26
Over-Sampling Critical-Sampling Under-Sampling
Recovering f(t) from its SampledVersion
To recover f(t) we can multiply the sampled spectrum
with a function
Accordingly And f(t) can be computed using the inverse Fourier
transform
27
Δ
max max
T , -μ μ μ H( μ) 0 , otherwise
~
F(u ) F( μ)H( μ)
1 2
j πμt
f (t ) = F( μ) = F( μ) e dμ
Recovering f(t) from its Sampled
Version
28
Aliasing
When we sample with a rate less than the Nyquest rate ,
the replicas of the function transform will overlap. This affects the recovery of the original function.
29
For a sampled function f(t), the Fourier transform is
given by
However, This gives a continuous function that has to be
sampled in the frequency domain.
If we take M samples between 0 and 1/∆T
then, the Fourier transform becomes Which is called the Discrete Fourier Transform (DFT) and its the inverse is
30 2 Δ
~ j π μ n T n n
F( μ) f e Δ m μ , m = 0,1,2,...,M-1 M T
1 2
M j π m n / M m n n
F f e , m =0,1,2,...,M-1
1 2
1
M j π m n / M n m m
f F e , n = 0,1,2,...,M-1 M
The Discrete Fourier Transform (DFT) of one
Variable
A better and convenient representation is to replace m
and n with x and u, and to use the functional notation instead of subscripts for simplicity
DFT IDFT
31 1 2
1
M j π μ x / M u
f ( x) F( μ)e , x = 0,1,2,...,M-1 M
1 2
M j π μ x / M x
F( μ) f ( x)e , μ =0,1,2,...,M-1
The Discrete Fourier Transform (DFT) of one
Variable
The DFT of a sampled
function is periodic since the continuous transform is periodic
The inverse DFT is periodic also, since we have sampled
the spectrum. Thus, the M samples represent one period in of inverse.
32
F( μ) F( μ kM ) f ( x) f ( x kM )
Relationship Between Sampling and Frequency
intervals
If the samples spacing is ∆T and we have M samples, then
the duration of f(x) is given by
In the frequency domain, the spacing ∆u is The frequency range spanned by M components of the
DFT
Note the inverse relationship between the spacing in the
two domains
33
Δ T M T 1 1 Δ Δ μ M T T 1 Ω Δ Δ M μ T
The Discrete Fourier Transform (DFT) of one
Variable
Example
4.7. Compute the DFT
f(x) = {0.5,1.5,3.5,3.5}
34
3 2
j π μ x / M x
F( μ ) f ( x )e , μ =0,1,2,3
3 2
1 2 3 9
j π x / M x
μ F( ) f ( x)e f ( ) f ( ) f ( ) f ( )
3 2 4 2 4 2 4 2 4 2 4
1 1 1 2 3
j π x / x j π 0 / j π 1 / j π 2 / j π 3 /
μ F( ) f ( x)e f ( )e f ( )e f ( )e f ( )e = -3+2j
The Discrete Fourier
Transform (DFT) of one Variable
Example 4.7 – continued Note how all samples of f(x) are used to compute the
value of the transform F(u) at each u
35
3 4 4 4 4 4 4 4 4 4 4
2 2 1 2 3
j π x / x j π 0 / j π 1 / j π 2 / j π 3 /
μ F( ) f ( x)e f ( )e f ( )e f ( )e f ( )e = -1+0j
3 6 4 6 4 6 4 6 4 6 4
3 3 1 2 3
j π x / x j π 0 / j π 1 / j π 2 / j π 3 /
μ F( ) f ( x)e f ( )e f ( )e f ( )e f ( )e = -(3+2j)
Example 4.8 – Compute the IDFT of F(u) in the example 4.7 to obtain f(x)
36
Convolution with discrete signals is performed
by
And correlation is given by
37
1
M m
f ( x) h( x) f (m) h( x m)
1
M m
f ( x) h( x) f (m) h( x m)
The
Fourier Transform
a Continuous Function ofT woVariables
The discussion so far has been for functions of one
variables
Extension to continuous functions of two variables is
straight forward if we know that
38
, t t and z=z δ(t t ,z z ) 0 , otherwise
f (t,z )δ(t t ,z z )dtdz= f(t ,z )
The
Fourier Transform
a Continuous Function ofT woVariables
The transform pair is given by
39
2
j π(μt+υz)
F( μ,υ) f (t,z )e dtdz
2
j π(μt+υz)
f (t,z ) F( μ,υ)e dμdυ
The
Fourier Transform
a Continuous Function ofT woVariables
Example 4.9.
40
sin(πμT ) sin(πυZ ) F( μ,υ) ATZ πμT πυZ
2-D Sampling and 2-D SamplingTheorem We
can consider sampling a 2-D function as multiplying it with an impulse train
Where the discrete impulse in 2-D is defined as
41
T Z m n
s (t,z ) = δ(t m T,z n Z )
1 , x x and y=y δ( x x ,x x ) 0 , otherwise
x y
f ( x,y )δ( x x ,y y ) f ( x ,y )
2-D Sampling and 2-D Sampling
Theorem
If we perform the convolution between the spectrum of
the impulse train and the spectrum of f(t,z) we conclude (as in the 1-D case) that the spectrum of the sampled function is an infinite periodic copies of the original of the spectrum F(u,v) that are centered at multiples of the sampling rates in the t and z directions
42
1 Δ Δ
~ m n
m n F (μ,υ ) = F( μ ,υ ) T Z T Z
2-D Sampling and 2-D SamplingTheorem Similar to the 1-D case, the spectrum of the sampled
function is just infinite replicas that are located at the multiples of sampling rate (1/∆T and 1/ ∆ Z) in both directions
In order to avoid aliasing, the transform F(u,v) should
be band-limited and the sampling rate in both directions should be greater than or equal the maximum frequency component in all directions
43
1 1 2 2 Δ Δ
max max
μ and v T Z
2-D Sampling and 2-D Sampling
Theorem
44
Spectrum of Sampled Function Aliasing due to under-sampling
The Discrete Fourier Transform of a Function
woVariables
The transform pair is given by
And
45
1 1 2
0 1 2 1 0 1 2 1
M N j π(μx/M+υy/ N ) x y
F( μ,υ) f ( x,y )e μ , , ,...,M and υ , , ,...,N
1 1 2
1 0 1 2 1 0 1 2 1
M N j π(μx/M+υy/ N ) μ υ
f ( x,y ) F( μ,υ)e MN x , , ,...,M and y , , ,...,N
Relationship Between Sampling and Frequency
Intervals
Translation
46
1 1 Δ Δ Δ Δ μ and υ M T N Z
2 2
j π( μ x/ M υ y/ N ) j π( x μ/ M y υ/ N )
f ( x,y)e F(μ μ ,υ υ ) f ( x x ,y y ) F(μ,υ)e
Periodicity
We mentioned earlier that the spectrum of the sampled
2-D function and its inverse are periodic. In other words
It is more convenient for processing and display to shift
the spectrum to the middle of domain by multiplying the sampled function by (-1)x+y
47
1 2 1 2
F( μ,υ) F( μ k M,υ) F( μ,υ k N ) F( μ k ,υ k N )
1 2 1 2
f ( x,y ) f ( x k M,y ) f ( x,y k N ) f ( x k ,y k N )
2
2 2 2 2 1 2 2
j π( μ x/ M υ y/ N ) jπ( x y ) ( x y )
f ( x,y )e F( μ μ ,υ υ ) if we let μ M / and υ N / f ( x,y )e F( μ M / ,υ N / ) f ( x,y )( ) F( μ M / ,υ N / )
Periodicity
48
Spectrum of f(t) before multiplying by (-1)x+y Spectrum of f(t) after multiplying by (-1)x+y
Periodicity
49
Spectrum of f(t) without multiplying by (-1)x+y Spectrum of f(t) x (-1)x+y F(0,0) F(0,0)
Fourier Spectrum and Phase Angle
The 2-D DFT is complex in general and usually it is
expressed as two separate functions in the frequency domain
The magnitude The phase The power spectrum is defined as The magnitude of F(0,0) (dc component) is proportional
to the average value of f(x,y) and is typically the largest component in the spectrum
50
1 2 2 2
F( μ,υ) R ( μ,υ) I ( μ,υ) I( μ,υ) φ( μ,υ) arctan R( μ,υ)
2 2 2
P( μ,υ) F( μ,υ) R ( μ,υ) I ( μ,υ)
0 0 F( , ) MN f ( x,y )
51
Image Spectrum without shifting Spectrum after shifting Spectrum After shifting and log transformation
Example: Effect of translation and rotation
52
Image Spectrum Phase
Fourier Spectrum and Phase Angle
The components of the spectrum of the DFT reflects
the amplitudes
the sinusoids that combine to represent the images.
A large amplitude at any frequency implies greater
prominence of that frequency in the image, and vice versa.
The phase of the spectrum is a measure of the
displacement of various sinusoids with respect to their
We can say that the magnitude of the DFT is an array
whose components determine the intensities in the image while the phase angle carry the information about where discernable objects are located
53
Fourier Spectrum and Phase Angle
54
Image Magnitude of Spectrum Phase of Spectrum Image Reconstructed Using Magnitude only Image Reconstructed Using Phase only
The need for Zero padding
The discrete 2-D convolution theorem states that In this course we will be multiplying functions (F(u,v) and
H(u,v)) in the frequency domain to perform some tasks.
This is equivalent to convolving f(x,y) and h(x,y) Although it sounds simple, the periodicity of the IDFT
for the two functions causes a serious problem
Let’s investigate using 1-D example
55
f ( x,y) h( x,y ) F( μ,υ)H( μ,υ) and f(x,y)h(x,y) F( μ,υ) H( μ,υ)
The need for Zero padding
Assume that we want to convolve two aperiodic
functions each of which is 400 samples
Note that the convolution result is 799 points
56
1
M m
f ( x) h( x) f (m) h( x m)
The need for Zero padding
Now consider convolving two periodic functions each of
which is 400 samples
Note that the convolution result is also periodic but
each period doesn’t correspond to the result in the previous slide
57
The need for Zero padding
A simple solution is to zero-pad both functions f(x,y)
and h(x,y) such that they are of equal size P that satisfies where A and B are the size of the original functions
If we perform convolution after zero-padding the result
will be periodic and each period contains the desired result
58
The need for Zero padding
For two 2-D functions f(x,y) and h(x,y) with sizes AxB
and CxD, zero-padding should be performed in both directions such that the new size is PxQ
If the two function/arrays/images are of the same size,
padding is achieved by
The padded zeros are to be removed once we have the
final result
59
The need for Zero padding - Example
60
Original |F(u,v)| H(u,v) |F(u,v)| x H(u,v) Output IDFT DFT
The need for Zero padding - Example
61
Original - padded |F(u,v)| H(u,v) |F(u,v)| x H(u,v) Output IDFT DFT
The need for Zero padding - Example
Note
More blurring in the image that was padded Blurring near the image borders is symmetric in the padded
case
62
Output without padding Output with padding
63
64
65
66
Symmetry
67
Check Matlab documentation for the
real imag abs atan2 fft2 ifft2 fftshift
68