Upload
sherman-johns
View
235
Download
4
Tags:
Embed Size (px)
Citation preview
1
DREAMDREAM
PLANPLANIDEAIDEA
IMPLEMENTATIONIMPLEMENTATION
3
Introduction to Image ProcessingIntroduction to Image Processing
Dr. Kourosh KianiEmail: [email protected]: [email protected]: [email protected]: www.kouroshkiani.com
Present to:Amirkabir University of Technology (Tehran
Polytechnic) & Semnan University
4
Lecture 10
2D Discrete Fourier Transform
(DFT )
The two-dimensional Fourier transform and its inverse Fourier transform (discrete case) DFt
Inverse Fourier transform:
u, v : the transform or frequency variables x, y : the spatial or image variables
1,...,2,1,0,1,...,2,1,0for
),(1
),(1
0
1
0
)//(2
NvMu
eyxfMN
vuFM
x
N
y
NvyMuxj
1,...,2,1,0,1,...,2,1,0for
),(),(1
0
1
0
)//(2
NyMx
evuFyxfM
u
N
v
NvyMuxj
24118
25533
14624
269101
19149
I
DFT-6.80 + 7.89i 17.8 - 12.76i 17.8 -7.89i -6.8 - 7.89i 103.00
19.28 + 9.2i 2.05+ 20.34i 5.07 - 13.76i -5.09+- 13.76i 9.28-10.82i
8.43 + 1.31i 9.22 + 14.89i 6.09 + 3.25i -3.55 +13.88i -0.78+ 8i
-3.55 – 13.88i 6.09 - 3.25i 9.22 - 14.89i 8.43 - 1.31i -0.78+ 8i
- 5.09 + 13.76i 5.07 + 2.13i 2.05 - 1.83i 19.28 - 9.2i 9.28-10.82i
4...0,4...0for
),(25
1),(
4
0
4
0
)5/5/(2
vu
eyxIvuFx y
vyuxj
),( vuF
103.00 10.41 21.90 21.90 10.41
14.26 14.67 5.50 20.44 21.36
8.04 14.33 6.90 17.51 8.53
8.04 8.53 17.51 6.90 14.33
14.26 21.36 20.44 5.50 14.67
|F|=abs(F)=
2.01 1.02 1.34 1.34 1.02
1.15 1.17 0.74 1.31 1.33
0.91 1.16 0.84 1.24 0.93
0.91 0.93 1.24 0.84 1.16
1.15 1.33 1.31 0.74 1.17
log10 |F|=log10(abs(F)) =
0.00 - 2.28 -0.62 0.62 2.28
-0.86 1.93 -0.40 1.47 0.45
-1.67 1.82 0.49 1.02 0.15
1.67 -0.15 -1.02 -0.49 -1.82
0.86 -0.45 -1.47 0.40 -1.93
angleF =
0.00 - 130.76 - 5.64 35.64 130.76
-49.39 110.30 - 2.74 84.26 25.51
- 95.57 104.33 28.08 58.23 8.86
95.57 - 8.86 58.23- -28.08 - 04.33
49.39 -25.51 - 84.26 22.74 110.30-
radToDegF=
),(),(),(),(
),(
),(tan),(
),(),(),(
),(),(),(
)(
222
1
22
vuIvuRvuFvuP
SpectrumPower
vuR
vuIvu
SpectrumPhase
vuIvuRvuF
SpectrumAmplitude
vuiIvuRvuF
SpectrumComplex
24118
25533
14624
269101
19149
)),(( IIvuFInvers
Inverse Fourier transform-6.80 + 7.89i 17.8 - 12.76i 17.8 -7.89i -6.8 - 7.89i 103.00
19.28 + 9.2i 2.05+ 20.34i 5.07 - 13.76i -5.09+- 13.76i 9.28-10.82i
8.43 + 1.31i 9.22 + 14.89i 6.09 + 3.25i -3.55 +13.88i -0.78+ 8i
-3.55 – 13.88i 6.09 - 3.25i 9.22 - 14.89i 8.43 - 1.31i -0.78+ 8i
- 5.09 + 13.76i 5.07 + 2.13i 2.05 - 1.83i 19.28 - 9.2i9.28-10.82i
),( vuF
Inverse Fourier transform
Magnitude and Phase of DFT
• What is more important?
magnitude phase
Magnitude and Phase of DFT
Reconstructed image using
magnitude only
Reconstructed image using
phase only
original
amplitude
phase
),( vuF
),( vuF
Magnitude and Phase of DFT
Example: DFT of 2D rectangle function
Fourier spectrum
Input function
Spectrum displayed as an intensity function
Extending DFT to 2D2D cos/sin functions
1,...,2,1,01,...,2,1,0for
),(),(1
0
1
0
)//(2
NyMx
evuFyxfM
u
N
v
NvyMuxj
2D - DFT
Base-functions are waves
u
v
NvyMuxje //2
1,...,2,1,01,...,2,1,0for
),(),(1
0
1
0
)//(2
NyMx
evuFyxfM
u
N
v
NvyMuxj
Why is DFT Useful?
• Easier to remove undesirable frequencies.
• Faster perform certain operations in the frequency domain than in the spatial domain.
Properties in the frequency domain
• Fourier transform works globally– No direct relationship between a specific
components in an image and frequencies
• Intuition about frequency– Frequency content– Rate of change of gray levels in an image
Example: Removing undesirable frequencies
remove highfrequencies
reconstructedsignal
frequenciesnoisy signal
To remove certain frequencies, set their corresponding F(u) coefficients to zero!
How do frequencies show up in an Signal?• Low frequencies correspond to slowly
varying information • High frequencies correspond to quickly
varying information
How do frequencies show up in an image?• Low frequencies correspond to slowly varying
information (e.g., continuous surface).• High frequencies correspond to quickly varying
information (e.g., edges)
How do frequencies show up in an image?
How do frequencies show up in an image?
How do frequencies show up in an image?
How do frequencies show up in an image?
How do frequencies show up in an image?
How do frequencies show up in an image?
How do frequencies show up in an image?
The 2D DFT and its inverse
• Centered spectrum for display
)0,0(
)0,0(
)1,1( NM
2-D Fourier transform
• Frequency axis
[ ( , )( 1) ] ( / 2, / 2)x yf x y F u M v N
x
y
u
v
u
vF shift
0
Low and high frequencies
Low
High
LowLo
w
Hig
h
Low
Low Low
LowLow
High
Frequencies of the 2D DFT
Periodicity of 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:
f(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 : How it works
Example of 2-D DFT
Original image
2D DFT
2D FFT Shift
Example of 2-D DFT
Original image
2D DFT
2D FFT Shift
Spectrum shift
Original imageLog enhanced
transform
Shifted
log enhanced
transform
• Computing DFT– Use the two-dimensional FFT command
E=fft2(A)– Puts center of the beam in the corners
– Use the fftshift command to put it into the centerA=imread(‘slit’, ‘gif’) fft2( A ) fftshift( fft2( A ) )
DFT Properties: Rotation
• Rotating f(x,y) by θ rotates F(u,v) by θ
DFT
DFT
DFT Properties: Rotation
The Property of Two-Dimensional DFT Linear Combination
The Property of Two-Dimensional DFT Linear Combination
DFT
DFT
DFT
A
B
0.25 * A + 0.75 * B
Two-Dimensional DFT with Different FunctionsTwo-Dimensional DFT with Different Functions
Sine wave
Rectangle
Its DFT
Its DFT
Two-Dimensional DFT with Different FunctionsTwo-Dimensional DFT with Different Functions
2D Gaussianfunction
Impulses
Its DFT
Its DFT
Two-Dimensional DFT with Different FunctionsTwo-Dimensional DFT with Different Functions
2D Gaussianfunction
Impulses
Its DFT
Its DFT
Relation Between Spatial and Frequency Resolutions
xMu
1yN
v
1
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 DFTby column
F(u,v)
How to Perform 2-D DFT by Using 1-D DFT
f(x,y)
1-D DFT
by rowF(x,v)
1-D DFTby column
F(u,v)
Alternative method
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 and have the zero frequency at the center.
Smoothing filters: Gaussian
• The weights are samples of the Gaussian function
mask size:
σ = 1.4
Smoothing filters: Gaussian
•As σ increases, more samples must be obtained to represent the Gaussian function accurately.• Therefore, σ controls the amount of smoothing
σ = 3
Smoothing filters: Gaussian
Fourier Low Pass Filtering
Gaussian Low Pass Filter
Low pass filtering
Low pass filtering
Fourier High Pass Filtering
Linear filtering and convolution
DFT
IDFT
High pass filtering
High pass filtering
Example of noise reduction using DFT
Questions? Discussion? Suggestions?
102