fourier transform - part ii - cs.haifa.ac.ilcs.haifa.ac.il/~dkeren/ip/lecture6.pdf · fourier...
Post on 23-Apr-2018
229 Views
Preview:
TRANSCRIPT
Fourier Transform - Part II
Image Processing - Lesson 6
• Discrete Fourier Transform - 1D
• Discrete Fourier Transform - 2D
• Fourier Properties
• Convolution Theorem
• FFT
• Examples
Discrete Fourier Transform
Move from f(x) (x R) to f(x) (x Z) by sampling at equal intervals.
f(x0), f(x0+∆x), f(x0+2∆x), .... , f(x0+[n-1]∆x),
Given N samples at equal intervals, we redefine f as:
f(x) = f(x0+x∆x) x = 0, 1, 2, ... , N-1
4
3
2
1
4
3
2
1
0 0.25 0.5 0.75 1.0 1.25 0 1 2 3
f(x)
f(x0)
f(x0+∆x)
f(x0+2∆x) f(x0+3∆x)
f(xn) = f(x0 + x∆x)
∈ ∈
Discrete Fourier Transform
The Discrete Fourier Transform (DFT) is defined as:
u = 0, 1, 2, ..., N-1∑−
=
−
=1
0
2
)(1)(N
x
Niux
exfN
uFπ
∑−
=
=1
0
2
)()(N
u
Niux
euFxfπ
x = 0, 1, 2, ..., N-1
The Inverse Discrete Fourier Transform (IDFT) is defined as:
Matlab: F=fft(f);
Matlab: F=ifft(f);
4
3
2
1
Discrete Fourier Transform - Example
4
3
2
1
0 0.25 0.5 0.75 1.0 1.25 0 1 2 3
f(x)
f(x0)
f(x0+∆x)
f(x0+2∆x) f(x0+3∆x)
f(x) = f(x0 + x∆x)
F(0) = 1/4 Σ f(x) e = 1/4 Σ f(x) 13
x=0
-2πi0x4
= 1/4(f(0) + f(1) + f(2) + f(3)) = 1/4(2+3+4+4) = 3.25
3
x=0
F(1) = 1/4 Σ f(x) e = 1/4 [2e0+3e-iπ/2+4e−π i 4e-i3π/2] = [-2+i]3
x=0
-2πix4 1
4
F(3) = 1/4 Σ f(x) e = 1/4 [2e0+3e-i3π/2+4e−3πi 4e-i9π/2] = [-2-i]3
x=0
-6πix4 1
4
F(2) = 1/4 Σ f(x) e = 1/4 [2e0+3e-iπ+4e−2πi 4e-3πi] = [-1-0i]=3
x=0
-4πix4 -1
4-14
Fourier Spectrum:
|F(0)| = 3.25
|F(1)| = [(-1/2)2 + (1/4)2]0.5
|F(2)| = [(-1/4)2 + (0)2]0.5
|F(3)| = [(-1/2)2 + (-1/4)2]0.5
Discrete Fourier Transform - 2D
Image f(x,y) x = 0,1,...,N-1 y= 0,1,...,M-1
The Discrete Fourier Transform (DFT) is defined as:
The Inverse Discrete Fourier Transform (IDFT) is defined as:
x = 0, 1, 2, ..., N-1∑−
=∑
−
=
+=
1
0
1
0
)(2),(),(
N
u
Mvy
NuxM
v
ievuFyxf
π
y = 0, 1, 2, ..., M-1
u = 0, 1, 2, ..., N-1v = 0, 1, 2, ..., M-1
∑−
=
−
=∑
+−=
1
0
1
0
)(2),(1),(F
N
x
M
y
Mvy
Nuxi
eyxfMN
vuπ
Matlab: F=fft2(f);
Matlab: F=ifft2(f);
u=0, v=0 u=1, v=0 u=2, v=0u=-2, v=0 u=-1, v=0
u=0, v=1 u=1, v=1 u=2, v=1u=-2, v=1 u=-1, v=1
u=0, v=2 u=1, v=2 u=2, v=2u=-2, v=2 u=-1, v=2
u=0, v=-1 u=1, v=-1 u=2, v=-1u=-2, v=-1 u=-1, v=-1
u=0, v=-2 u=1, v=-2 u=2, v=-2u=-2, v=-2 u=-1, v=-2
U
V
v
u
Fourier Transform - Image
Visualizing the Fourier Transform Image using Matlab Routines
• F(u,v) is a Fourier transform of f(x,y) and it has complex entries.
F = fft2(f);• In order to display the Fourier Spectrum |F(u,v)|
– Cyclically rotate the image so that F(0,0) is in the center:
F = fftshift(F);– Reduce dynamic range of |F(u,v)| by displaying
the log:
D = log(1+abs(F));
Example:
|F(u)| = 100 4 2 1 0 0 1 2 4
|F(u)| = 0 1 2 4 100 4 2 1 0Cyclic
|F(u)|/10 = 0 0 0 0 10 0 0 0 0
log(1+|F(u)|) = 0 0.69 1.01 1.61 4.62 1.61 1.01 0.69 0
0 1 2 4 10 4 2 1 0
Display in Range([0..10]):
log(1+|F(u)|)/0.462 =
Original
Visualizing the Fourier Image - Example
|F(u,v)|
|F(0,0)| at center log(1 + |F(u,v)|)
Original
Shifted Fourier Image Shifted Log Fourier Image = log(1+ |F(u,v)|)
Fourier Image = |F(u,v)|
Properties of The Fourier Transform
Distributive (addition)
LinearityF[a f(x,y)] = aF [f(x,y)]
a f(x,y) a F(u,v)
CyclicF(u,v) = F(u+N,v) = F(u,v+N) = F(u+N,v+N)
F(x,y) = F(x+N,y+N)
SymmetricF(u,v) = F*(-u,-v)
thus:
|F(u,v)| = |F (-u,-v)| Fourier Spectrum is symmetric
DC (Average)1MF(0,0) = Σ Σ f(x) e0
N-1
x=0
1N
M-1
y=0
if f(x) is real:
F[ f1(x,y) + f2(x,y)] = [f1(x,y)] + F [f2(x,y)]F~ F
~F~
F~
F~
x
f(x)
ω
|F(ω)|
x
g(x)
ω
|G(ω)|
x
f+g
ω
|F(ω)+G(ω)|
Distributive: { } { } { }gFfFgfF ~~~ +=+
1 cycle
0 N/2 N-1N
-N/2
Cyclic and Symmetry of the Fourier Transform - 1D Example
|F(u)|
Translation
Image Transformations
f(x-x0,y-y0) F(u,v)e-2πi(ux0+vy0)
N
f(x,y)e F(u-u0,v-v0)2πi(u0x+v0y)
N
The Fourier Spectrum remains unchanged under translation:
|F(u,v)| = |F(u,v)e |-2πi(ux0+vy0)
N
Rotation
Rotation of f(x,y) by θ
Rotation of F(u,v)by θ
Scale
f(ax,by) F(u/a,v/b)1|ab|
x
f(x)
ω
|F(ω)|
x
f(x)
ω
|F(ω)|
Change of Scale- 1D:
x
f(x)
ω
|F(ω)|
( ){ } ( ) ( ){ }
==
aF
a1axfF~thenFxfF~if ωω
x
f(x)
ω
F(ω)
x
f(2x)
ω
0.5 F(ω/2)
Change of Scale
x
f(x/2)
ω
2 F(2ω)
2D Image 2D Image - Rotated
Fourier Spectrum Fourier Spectrum
Example - Rotation
Image Domain Frequency Domain
Fourier Transform Examples
Separabitity
F(u,v) = Σ Σ f(x,y) e-2πi(ux+vy)/n
N-1
x=0
1N
N-1
y=0
F(u,v) = Σ (Σ f(x,y) e-2π ivy/n) e-2π iux/nN-1
x=0
1N
N-1
y=0
F(u,v) = Σ F(x,v) e-2π iux/n
N-1
x=0
1N
Thus, to perform a 2D Fourier Transform is equivalent to performing 2 1D transforms:
1) Perform 1D transform on EACH column of image f(x,y).Obtain F(x,v).
2) Perform 1D transform on EACH row of F(x,v).
Higher Dimensions:Fourier in any dimension can be performed by applying 1D transform on each dimension.
Image Domain Frequency Domain
Fourier Transform Examples
Image Domain Frequency Domain
Fourier Transform Examples
Linear Systems and Responses
SpatialDomain
FrequencyDomain
Input f F
Output g G
ImpulseResponse h
Freq.Response H
Relationship g=f*h G=FH
The Convolution Theorem
g = f * h g = f h
implies implies
G = F H G = F * H
Convolution in one domain is multiplication in the other and vice
versa
The Convolution Theorem
Convolution in one domain is multiplication in the other and vice
versa
( ) ( ){ } ( ){ } ( ){ }xgFxfFxgxfF ~~~ =∗
and likewise
( ) ( ){ } ( ){ } ( ){ }xgFxfFxgxfF ~~~ ∗=
f(x,y) * g(x,y) F(u,v) G(u,v)
f(x,y) g(x,y) F(u,v) * G(u,v)
f(x)
-0.5 0.5
x
h(x)Example:
-1 1
f(x)
-0.5 0.5
*h(x) =
F(ω) F(ω)
H(ω) = .
=
f(x,y) g(x,y) f * g (x,y)
F(u,v) G(u,v) F(u,v) G(u,v)
F[F(u,v) G(u,v)]
Convolution Theorem -2D Example
F-1ℑ
1−ℑ
Sampling the Image
x
f(x)
ω
|F(ω)|
F̂
x
g(x)
ω
F̂|G(ω)|
ω
T 1/T
x
*
F̂
-1/2T 1/2T
Undersampling the Image
x
g(x)
F̂|G(ω)|
ω
T 1/T
*
ω
-1/2T 1/2Tx
F̂
x
f(x)
ω
|F(ω)|
F̂
Critical Sampling• If the maximal frequency of f(x) is ωmax , it
is clear from the above replicas that ωmax should be smaller that 1/2T.
• Alternatively:
• Nyquist Theorem: If the maximal frequency of f(x) is ωmax the sampling rate should be larger than 2ωmax in order to fully reconstruct f(x) from its samples.
• If the sampling rate is smaller than 2ωmax overlapping replicas produce aliasing.
max21
ω>T
ω
|F(ω)|
-1/2T 1/2T
Optimal Interpolation
• It is possible to fully reconstruct f(x) from its samples:
ω
|F(ω)|
x
f(x)F-1^
-1/2T 1/2T
ω
|F(ω)|
x
f(x)F-1^
-1/2T 1/2T
ω
|F(ω)|
x
f(x)F-1^
-1/2T 1/2T
1
*
Note, that only N/2 different transform values are obtainedfor the N/2 point transforms.
Fast Fourier Transform - FFT
u = 0, 1, 2, ..., N-1∑−
=
−
=1
0
2
)(1)(N
x
Niux
exfN
uFπ
O(n2) operations
∑∑−
=
−
=
+−−
++=12/
0
12/
0
)12(222
)12(1)2(1)(N
x
N
x
Nxiu
Nxiu
exfN
exfN
uFππ
The Fourier transform of N inputs, can be performed as2 Fourier Transforms of N/2 inputs each + one complex multiplication and addition for each value i.e. O(N).
even x odd x
−−
∑ ++∑=−
=
−−
=
12/
0
212/
0
2/2
2/2
2/)12(
2/1)2(1
21 N
x
NiuN
x
Niux
Niux
Nexf
Neexf
πππ
Fourier Transform ofof N/2 even points
Fourier Transform ofof N/2 odd points
0 1 2 3 4 5 6 7 0 2 4 6 1 3 5 7
All sampling pointsOdd
sampling pointsEven
sampling points
For u = 0, 1, 2, ..., N/2-1
−−−
∑ ++∑=−
=
−
=
12/
0
12/
0
2/22
2/2
2/)12(
2/1)2(1
21)(
N
x
N
xN
Niux
Niu
Niux
Nexf
NeexfuF
πππ
−
+= )()(21)(
2/2/
2
uFeuFuF o
N
e
NNN
iuπ
For u' = u+N/2 :N
iuiN
iuN
NuiN
iu
eeeeeπ
ππππ 22)2/(2'2 −
−=−−
=
+−
=
−
obtain :
Thus: only one complex multiplication is needed for two terms.
−
+= )()(21)(
2/
2
2/uFeuFuF o
NN
iue
NN
π
−
−=+ )()(21)(
2/
2
2/2 uFeuFuF oN
Niu
eN
NN
π
)u(e2/NFCalculating and is done recursively by
calculating and .)u(o
2/NF)u(e
4/NF )u(o4/NF
F(0) F(1) F(2) F(3) F(4) F(5) F(6) F(7)
F(0) F(2) F(4) F(6) F(1) F(3) F(5) F(7)
F(0) F(4) F(2) F(6) F(1) F(5) F(3) F(7)
F(0) F(1) F(2) F(3) F(4) F(5) F(6) F(7)
2-pointtransform
4-pointtransform
FFT
FFT : O(nlog(n)) operations
FFT of NxN Image: O(n2log(n)) operations
FilteredImage
Image Transform
Filtered
FFT
FFT-1NewImage
Frequency Enhancement
top related