Upload
alize
View
30
Download
0
Embed Size (px)
DESCRIPTION
Frequency Domain Processing. Digital Image Processing Week V. Thurdsak LEAUHATONG. Background: Fourier Series . Fourier series:. Any periodic signals can be viewed as weighted sum of sinusoidal signals with different frequencies. Frequency Domain: view frequency as an - PowerPoint PPT Presentation
Citation preview
Digital Image Processing Week V
Thurdsak LEAUHATONG
Frequency Domain Processing
Background: Fourier Series
Any periodic signals can beviewed as weighted sumof sinusoidal signals with different frequencies
Fourier series:
Frequency Domain: view frequency as an independent variable
Fourier Tr. and Frequency Domain
Time, spatial Domain Signals
Frequency Domain Signals
Fourier Tr.
Inv Fourier Tr.
1-D, Continuous case
dxexfuF uxj 2)()(Fourier Tr.:
dueuFxf uxj 2)()(Inv. Fourier Tr.:
2 cos 2 sin 2j uxe ux j ux
Example of 1-D Fourier Transforms
Notice that the longerthe time domain signal,The shorter its Fouriertransform
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Fourier Tr. and Frequency Domain (cont.)
1-D, Discrete case
1
0
/2)(1)(M
x
MuxjexfM
uF Fourier Tr.:
Inv. Fourier Tr.:
1
0
/2)()(M
u
MuxjeuFxf
u = 0,…,M-1
x = 0,…,M-1
F(u) can be written as)()()( ujeuFuF or)()()( ujIuRuF
22 )()()( uIuRuF
where
)()(tan)( 1
uRuIu
Relation Between Dx and Du For a signal f(x) with M points, let spatial resolution Dx be space between samples in f(x) and let frequency resolution Du be space between frequencies components in F(u), we have
xMu
DD
1
Example: for a signal f(x) with sampling period 0.5 sec, 100 point, we will get frequency resolution equal to
Hz02.05.0100
1
Du
This means that in F(u) we can distinguish 2 frequencies that are apart by 0.02 Hertz or more.
2-Dimensional Discrete Fourier Transform
1
0
1
0
)//(2),(1),(M
x
N
y
NvyMuxjeyxfMN
vuF
2-D IDFT
1
0
1
0
)//(2),(),(M
u
N
v
NvyMuxjevuFyxf
2-D DFT
u = frequency in x direction, u = 0 ,…, M-1v = frequency in y direction, v = 0 ,…, N-1
x = 0 ,…, M-1y = 0 ,…, N-1
For an image of size MxN pixels
F(u,v) can be written as),(),(),( vujevuFvuF or),(),(),( vujIvuRvuF
22 ),(),(),( vuIvuRvuF
where
),(),(tan),( 1
vuRvuIvu
2-Dimensional Discrete Fourier Transform (cont.)
For the purpose of viewing, we usually display only theMagnitude part of F(u,v)
2-D DFT Properties
2-D DFT Properties (cont.)
2-D DFT Properties (cont.)
2-D DFT Properties (cont.)
Relation Between Spatial and Frequency Resolutions
xMu
DD
1yN
vD
D1
whereDx = spatial resolution in x directionDy = spatial resolution in y direction
Du = frequency resolution in x directionDv = frequency resolution in y directionN,M = image width and height
Dx and Dy are pixel width and height. )
How to Perform 2-D DFT by Using 1-D DFT
f(x,y)
1-D DFT
by row F(u,y)1-D DFT
by column
F(u,v)
How to Perform 2-D DFT by Using 1-D DFT (cont.)
f(x,y)
1-D DFT
by rowF(x,v)
1-D DFTby column
F(u,v)
Alternative method
1-D DFT
0 N 2N-N
DFT repeats itself every N points (Period = N) but we usually display it for n = 0 ,…, N-1
We display only in this range
1
0
/2)(1)(M
x
MuxjexfM
uF From DFT:
Conventional Display for 1-D DFT
0 N-1Time Domain Signal
DFTf(x)
)(uF
0 N-1
Low frequencyarea
High frequencyarea
The graph F(u) is not easy to understand !
)(uF
0-N/2 N/2-1
)(uF
0 N-1
Conventional Display for DFT : FFT Shift
FFT Shift: Shift center of thegraph F(u) to 0 to get betterDisplay which is easier to understand.
High frequency area
Low frequency area
2-D DFT
For an image of size NxM pixels, its 2-D DFT repeats itself every N points in x-direction and every M points in y-direction.
We display only in this range
1
0
1
0
)//(2),(1),(M
x
N
y
NvyMuxjeyxfMN
vuF
0 N 2N-N
0
M
2M
-M
2-D DFT:g(x,y)
Conventional Display for 2-D DFT
High frequency area
Low frequency area
F(u,v) has low frequency areasat corners of the image while highfrequency areas are at the centerof the image which is inconvenientto interpret.
2-D FFT Shift : Better Display of 2-D DFT
2D FFTSHIFT
2-D FFT Shift is a MATLAB function: Shift the zero frequency of F(u,v) to the center of an image.
High frequency area Low frequency area
Original displayof 2D DFT
0 N 2N-N
0
M
2M
-M
Display of 2D DFTAfter FFT Shift
2-D FFT Shift (cont.) : How it works
Example of 2-D DFT
Notice that the longer the time domain signal,The shorter its Fourier transform
Example of 2-D DFT
Notice that direction of an object in spatial image andIts Fourier transform are orthogonal to each other.
Example of 2-D DFT
Original image
2D DFT
2D FFT Shift
F=fft2(f);S=abs(F); imshow(S,[ ]);
Fc=fftshift(F);Sc=abs(Fc); imshow(Sc,[ ]);
Example of 2-D DFT
Original image
2D DFT
2D FFT Shift
F=fft2(f);S=abs(F); imshow(S,[ ]);
Fc=fftshift(F);Sc=abs(Fc); imshow(Sc,[ ]);
Basic Concept of Filtering in the Frequency Domain
From Fourier Transform Property:
),(),(),(),(),(),( vuGvuHvuFyxhyxfyxg
We cam perform filtering process by using
Multiplication in the frequency domainis easier than convolution in the spatialDomain.
Filtering in the Frequency Domain with FFT shift
f(x,y)
2D FFT
FFT shift
F(u,v)
FFT shift
2D IFFTX
H(u,v)(User defined)
G(u,v)
g(x,y)
In this case, F(u,v) and H(u,v) must have the same size andhave the zero frequency at the center.
0 20 40 60 80 100 1200
0.5
1
0 20 40 60 80 100 1200
0.5
1
0 20 40 60 80 100 1200
20
40
Multiplication in Freq. Domain = Circular Convolution
f(x) DFT F(u)G(u) = F(u)H(u)
h(x) DFT H(u)g(x)IDFT
Multiplication of DFTs of 2 signalsis equivalent toperform circular convolutionin the spatial domain.
f(x)
h(x)
g(x)
“Wrap around” effect
H(u,v)GaussianLowpassFilter
Original image
Filtered image (obtained using circular convolution)
Incorrect areas at image rims
Multiplication in Freq. Domain = Circular Convolution
Linear Convolution by using Circular Convolution and Zero Padding
f(x) DFT F(u)G(u) = F(u)H(u)
h(x) DFT H(u)
g(x)
IDFTZero padding
Zero padding
Concatenation
0 50 100 150 200 2500
0.5
1
0 50 100 150 200 2500
0.5
1
0 50 100 150 200 2500
20
40
Padding zerosBefore DFT
Keep only this part
Linear Convolution by using Circular Convolution and Zero Padding
Filtering in the Frequency Domain : Example
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Highpass Filter
Lowpass Filter
Filter Masks and Their Fourier Transforms
Ideal Lowpass Filter
0
0
),( 0),( 1
),(DvuDDvuD
vuH
where D(u,v) = Distance from (u,v) to the center of the mask.
Ideal LPF Filter Transfer function
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Examples of Ideal Lowpass Filters
The smaller D0, the more high frequency components are removed.
Results of Ideal Lowpass Filters
Ringing effect can be obviously seen!
How ringing effect happens
Ideal Lowpass Filter with D0 = 5
-200
20
-20
0
20
0
0.2
0.4
0.6
0.8
1
Surface Plot
Abrupt change in the amplitude
0
0
),( 0),( 1
),(DvuDDvuD
vuH
How ringing effect happens (cont.)
-200
20
-20
0
20
0
5
10
15
x 10-3
Spatial Response of Ideal Lowpass Filter with D0 = 5
Surface Plot
Ripples that cause ringing effect
Butterworth Lowpass Filter
NDvuDvuH 2
0/),(11),(
Transfer function
Where D0 = Cut off frequency, N = filter order.
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Results of Butterworth Lowpass Filters
There is less ringing effect compared to those of ideal lowpassfilters!
Gaussian Lowpass Filter
20
2 2/),(),( DvuDevuH Transfer function
Where D0 = spread factor.
Note: the Gaussian filter is the only filter that has no ripple and hence no ringing effect.
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Results of Gaussian Lowpass Filters
No ringing effect!
Application of Gaussian Lowpass Filters
The GLPF can be used to remove jagged edges and “repair” broken characters.
Better LookingOriginal image
Highpass Filters
Hhp = 1 - Hlp
Ideal Highpass Filters
0
0
),( 1),( 0
),(DvuDDvuD
vuH
where D(u,v) = Distance from (u,v) to the center of the mask.
Ideal LPF Filter Transfer function
Butterworth Highpass Filters
NvuDDvuH 2
0 ),(/11),(
Transfer function
Where D0 = Cut off frequency, N = filter order.
Gaussian Highpass Filters
20
2 2/),(1),( DvuDevuH Transfer function
Where D0 = spread factor.
Laplacian Filter in the Frequency Domain
)()( uFjudxxfd nn
n
From Fourier Tr. Property:
Then for Laplacian operator
),(222
2
2
22 vuFvu
yf
xff
Surface plot
222 vu
We get
Image of –(u2+v2)
Sharpening Filtering in the Frequency Domain
),(),(),( yxfyxfyxf lphp
),(),(),( yxfyxAfyxf lphb
Spatial Domain
Frequency Domain Filter
),(),(),()1(),( yxfyxfyxfAyxf lphb
),(),()1(),( yxfyxfAyxf hphb
),(1),( vuHvuH lphp
),()1(),( vuHAvuH hphb
High Frequency Emphasis Filtering),(),( vubHavuH hphfe
Original Butterworthhighpass filteredimage
High freq. emphasisfiltered image
AfterHistEq.
a = 0.5, b = 2
Correlation Application: Object Detection