fourier series • fourier transform • discrete fourier transform • … · 2006. 2. 24. ·...
TRANSCRIPT
Image Comm. Lab EE/NTHU 1
Chapter 4Image Enhancement in the
Frequency Domain
Chapter 4Image Enhancement in the
Frequency Domain
• Fourier Series• Fourier Transform• Discrete Fourier Transform• Fourier Transform for Image Enhancement• Implementation
Image Comm. Lab EE/NTHU 2
Chapter 4.1 BackgroundChapter 4.1 Background
Image Comm. Lab EE/NTHU 3
4.2 Fourier Transform in theFrequency Domain
• Fourier transform F(u) of f(x) is defined as
• The inverse Fourier Transform is
• DFT for Discrete function f(x), x=0,1,..M-1for u=0,1,..M-1
• Inverse DFT
∫∞
∞−
−= dxexfuF uxj π2)()(
∫∞
∞−= dueuFxf uxj π2)()(
∑−
=
−=1
0
/2)(1)(M
x
MuxjexfM
uF π
∑−
=
−=1
0
/2)()(M
u
MuxeuFxf π
Image Comm. Lab EE/NTHU 4
4.2 Fourier Transform in theFrequency Domain
• Example (1-D DFT, Fig.4.2)• f(x) sampled K points or f(x) sampled 2K points • More samples in time domain (higher resolution) →
Lower resolution in frequency domain.• Scaling property of DFT
f(ax, by)⇔ F (u/a, v/b)/|ab|• Sampling : f(x)=f(x0+∆x), ∆x is the time resolution • f(x) → F(u)=F(u+ ∆u), ∆u is the freq. resolution.• ∆u=1/(M∆x)
Image Comm. Lab EE/NTHU 5
4.2 Fourier Transform in theFrequency Domain
4.2 Fourier Transform in theFrequency Domain
Image Comm. Lab EE/NTHU 6
• For discrete case (DFT: Discrete Fourier Transform)• f(x), x=0,…M-1• f(x0), f(x0+Δx)……….f(x0+(M-1)Δx)
f(x)= .f(x0+xΔx)• F(u) , u=0,…M-1• F(u0), F(u0+Δu)……….f(u0+(M-1)Δu)
F(u)= .F(u0+uΔu)Δu= 1/MΔx
4.2 Fourier Transform in theFrequency Domain
4.2 Fourier Transform in theFrequency Domain
Image Comm. Lab EE/NTHU 7
4.2.2 The Two-dimensional Discrete Fourier Transform(DFT)
• 2D-DFT of f(x, y) of size M×N
• Inverse 2-D DFT
• Magnitude and Phase of F(u, v)=R(u, v) + jI(u,v)|F(u, v)|=(R2(u, v)+I2(u, v))1/2
φ(u, v)=tan-1(I(u,v)/R(u,v))• Power Spectrum
P(u,v)=|F(u,v)|2=R2(u, v)+I2(u,v)
∑∑−
=
−
=
+−=1
0
1
0
)//(2),(1),(M
x
N
y
NvyMuxjeyxfMN
vuF π
∑∑−
=
−
=
+=1
0
1
0
)//(2),(),(M
u
N
v
NvyMuxjevuFyxf π
Image Comm. Lab EE/NTHU 8
4.2.2 The Two-dimensional Discrete Fourier Transform(DFT)
• Modulation in space domain f(x, y)(-1)xy
• F(u,v) will be shifted to (M/2, N/2)F(u-M/2, v-N/2)
• The center of (u, v), u=1,…M, v=1,…Nu=(M/2)+1, v=(N/2)+1
• Average of f(x,y) ∑∑−
=
−
=
=1
0
1
0),(100
M
x
N
yyxf
MN),F(
Image Comm. Lab EE/NTHU 9
4.2.2 The Two-dimensional Discrete Fourier Transform(DFT)
• For real f(x,y)F(u, v)=F*(-u, -v)|F(u, v)|=|F(-u, -v)|
• Samples in the space domain and frequency domain Δu= 1/MΔx
Δv= 1/NΔy
Image Comm. Lab EE/NTHU 10
4.2.2 The Two-dimensional Discrete Fourier Transform(DFT)
4.2.2 The Two-dimensional Discrete Fourier Transform(DFT)
Image Comm. Lab EE/NTHU 11
4.2.3 Filtering in the Frequency Domain4.2.3 Filtering in the Frequency Domain
Image Comm. Lab EE/NTHU 12
4.2.3 Filtering in the Frequency Domain
Filtering in Frequency domain steps:1) Multiply the input image by (-1)x+y
2) Compute DFT of the input image and get F(u, v)3) Multiply F(u,v) by a filter function H(u,v)
G(u,v)=F(u,v)H(u,v)4) Computer the inverse DFT of G(u,v), i.e.,F-1{G(u,v)}5) Obtain the real part of the g(x,y)6) Multiply g(x,y) with (-1)x+y
Image Comm. Lab EE/NTHU 13
4.2.3 Filtering in the Frequency Domain4.2.3 Filtering in the Frequency Domain
Image Comm. Lab EE/NTHU 14
4.2.3 Filtering in the Frequency Domain4.2.3 Filtering in the Frequency Domain
Notch filter: H(u, v)=0 if (u, v)=(M/2, N/2), H(u, v)=1 otherwise
u, v
H(u, v)
M/2, N/2
Image Comm. Lab EE/NTHU 15
4.2.3 Filtering in the Frequency Domain4.2.3 Filtering in the Frequency Domain
Image Comm. Lab EE/NTHU 16
4.2.3 Filtering in the Frequency Domain4.2.3 Filtering in the Frequency Domain
Image Comm. Lab EE/NTHU 17
4.2.4 Filtering in spatial and frequency domains
• Convolution in time domain
• f(x, y)*h(x, y)⇔ F(u, v)H(u, v)i.e., f(x, y)*h(x, y)=F-1{F(u, v)H(u, v)}
• Convolution in freq domain• F(u, v)*H(u, v) ⇔ f(x, y)h(x, y)
i.e., F{f(x, y)h(x, y)}=F(u, v)*H(u,v)
∑∑−
=
−
=
−−=∗1
0
1
0),(),(1),(,(
M
m
N
nnymxhnmf
MNyxhy)xf
h(x, y)f(x, y) g(x, y)
Image Comm. Lab EE/NTHU 18
4.2.4 Filtering in spatial and frequency domains
• An impulse of strength A, located at coordinates (x0, y0), is denoted as Aδ(x-x0, y-y0 )
• An unit impulse is defined as δ(x, y). i.e., δ(x, y)=1 only when x=0, y=0, δ(x, y)=0 otherwise.
• For function s(x, y) (a) sampled at (0, 0) is denoted asΣxΣys(x, y)δ(x, y) = s(0, 0), (b) sampled at (x0, y0), is ΣxΣys(x, y)δ(x–x0, y–y0) = s(x0, y0),
• The Fourier transform of δ(x, y ) is
MNeyx
MNvuF
M
x
N
y
NvyMuxj 1),(1),(1
0
1
0
)//(2 == ∑∑−
=
−
=
+− πδ
Image Comm. Lab EE/NTHU 19
4.2.4 Filtering in spatial and frequency domains
• If we let f(x, y)= δ(x, y) then
• δ(x,y)*h(x,y)⇔ F {δ(x, y)}H(u,v) h(x,y)⇔ H(u,v)
• Gaussian filters – lowpass filtering
• Difference of two Gaussian filters –highpass filtering
22 2/)( σuAeuH −=22222)( xuAexh σπσπ −=
22
221
2 2/2/)( σσ uu BeAeuH −− −=
),(1),(),(1),(,(1
0
1
0
yxhMN
nymxhnmMN
yxhy)xfM
m
N
n
=−−=∗ ∑∑−
=
−
=
δ
Image Comm. Lab EE/NTHU 20
4.2.4 Filtering in spatial and frequency domains4.2.4 Filtering in spatial and frequency domains
Image Comm. Lab EE/NTHU 21
4.3 Smoothing Frequency-Domain Filters
• Freq-Domain Filtering:G(u,v)=H(u,v)F(u,v)
• Filter H(u,v)• Ideal filter• Butterworth filter• Gaussian Filter
Image Comm. Lab EE/NTHU 22
4.3.1 Ideal Low pass filter
• H(u, v) with Sharp cut-off at cut-off frequency D0 , i.e., H(u, v)=1 if D(u, v)≤D0
=0 if D(u, v)>D0
• For image of size M x N, the center is at (u, v)=(M/2, N/2). The distance from any point to the center is
D(u, v)=[(u-M/2)2+(v-N/2)2]1/2
• Cut off frequency is D0
• Total power:
∑∑−
=
−
=
=1
0
1
0),(
M
u
N
vT vuPP
Image Comm. Lab EE/NTHU 23
4.3.1 Ideal Low pass filter4.3.1 Ideal Low pass filter
Image Comm. Lab EE/NTHU 24
4.3.1 Ideal Low pass filter4.3.1 Ideal Low pass filter
Image Comm. Lab EE/NTHU 25
4.3.1 Ideal Low pass filter4.3.1 Ideal Low pass filter
Image Comm. Lab EE/NTHU 26
4.3.1 Ideal Low pass filter4.3.1 Ideal Low pass filter
Image Comm. Lab EE/NTHU 27
4.3.2 Butterworth Lowpass Filter (BLPF)
• Butterworth filter has no sharp cutoff
• At cutoff frequency D0: H(u, v)=0.5
nDvuDvuH 2
0 ]/),([11),(
+=
Image Comm. Lab EE/NTHU 28
4.3.2 Butterworth Lowpass Filter4.3.2 Butterworth Lowpass Filter
Image Comm. Lab EE/NTHU 29
4.3.2 Butterworth Lowpass Filter4.3.2 Butterworth Lowpass Filter
Image Comm. Lab EE/NTHU 30
4.3.2 Butterworth Lowpass Filter4.3.2 Butterworth Lowpass Filter
Image Comm. Lab EE/NTHU 31
4.3.3 Gaussian Lowpass Filter (GLPF)
• Gaussian low-pass filter (GLPF)
• Let σ=D0
• When D(u, v)=D0 , H(u, v)=0.667
22 2/),(),( σvuDevuH −=
20
2 2/),(),( DvuDevuH −=
Image Comm. Lab EE/NTHU 32
4.3.3 Gaussian Lowpass Filter4.3.3 Gaussian Lowpass Filter
Image Comm. Lab EE/NTHU 33
4.3.3 Gaussian Lowpass Filter4.3.3 Gaussian Lowpass Filter
Image Comm. Lab EE/NTHU 34
4.3.4 Other Lowpass filtering examples4.3.4 Other Lowpass filtering examples
Image Comm. Lab EE/NTHU 35
4.3.4 Other Lowpass filtering examples4.3.4 Other Lowpass filtering examples
Image Comm. Lab EE/NTHU 36
4.3.4 Other Lowpass filtering examples4.3.4 Other Lowpass filtering examples
Image Comm. Lab EE/NTHU 37
4.4 Sharpening Frequency-Domain Filter
• Highpass filtering:Hhp(u,v)=1-Hlp(u,v)
• Given a lowpass filter Hlp(u,v), find the spatial representation of the highpass filter
(1) Compute the inverse DFT of Hlp(u, v)(2) Multiply the real part of the result with (-1)x+y
Image Comm. Lab EE/NTHU 38
4.4 Sharpening Frequency-Domain Filter4.4 Sharpening Frequency-Domain Filter
Image Comm. Lab EE/NTHU 39
4.4 Sharpening Frequency-Domain Filter4.4 Sharpening Frequency-Domain Filter
Image Comm. Lab EE/NTHU 40
4.4.1 Ideal Highpass Filter (IHPF)
• H(u, v)=0 if D(u, v)≤D0
=1 if D(u, v)>D0
• The center is at (u, v)=(M/2, N/2) D(u, v)=[(u-M/2)2+(v-N/2)2]1/2
• Cut off frequency is D0
Image Comm. Lab EE/NTHU 41
4.4.1 Ideal Highpass Filter (IHPF)4.4.1 Ideal Highpass Filter (IHPF)
Image Comm. Lab EE/NTHU 42
4.4.2 Butterworth Highpass Filter (BHPF)
• Butterworth filter has no sharp cutoff
• At cutoff frequency D0: H(u, v)=0.5
nvuDDvuH 2
0 )],(/[11),(
+=
Image Comm. Lab EE/NTHU 43
4.4.2 Butterworth Highpass Filter (BHPF)4.4.2 Butterworth Highpass Filter (BHPF)
IHPF
Image Comm. Lab EE/NTHU 44
4.4.3 Gaussian Highpass Filter (GHPF)
• Gaussian Highpass filter (GHPF)
• Let σ=D0
• When D(u, v)=D0 , H(u, v)=0.667
22 2/),(1),( σvuDevuH −−=20
2 2/),(1),( DvuDevuH −−=
Image Comm. Lab EE/NTHU 45
4.4.3 Gaussian Highpass Filter4.4.3 Gaussian Highpass Filter
Image Comm. Lab EE/NTHU 46
4.4.4 Laplacian in the Frequency Domain
• Fourier property:
• H(u, v) = –(u2+v2)• If F(u, v) has been centered by f(x, y)(-1)x+y
then H(u, v)= –[(u-M/2)2+(v-N/2)2]
)()()( uFjudx
xfd nn
n
=⎥⎦
⎤⎢⎣
⎡F
),()(
),()(),()(),(),(
22 vuFvu
vuFjvvuFjudy
yxfddx
yxfd nnn
n
n
n
+−=
+=⎥⎦
⎤⎢⎣
⎡+F
[ ] ),(),(),()(),( 222 vuFvuHvuFvuyxf =+−=∇F
Image Comm. Lab EE/NTHU 47
4.4.4 Laplacian in the Frequency Domain
• Laplacian filtering
• Enhanced image g(x, y)=f(x, y)-∇2f(x, y)• G(u,v)=F(u,v)H(u, v)
H(u,v)= 1–[(u-M/2)2+(v-N/2)2]• g(x,y)= {[1 –((u-M/2)2+(v-N/2)2)]F(u,v)}
)},(])2/()2/[({),( 222 vuFNvMuyxf −+−−=∇ -1F
-1F
Image Comm. Lab EE/NTHU 48
4.4.4 Laplacian in the Frequency Domain4.4.4 Laplacian in the Frequency Domain
Image Comm. Lab EE/NTHU 49
4.4.4 Laplacian in the Frequency Domain4.4.4 Laplacian in the Frequency Domain
Image Comm. Lab EE/NTHU 50
4.4.5 Unsharp masking High-boost filtering and High frequency emphasis filtering
• Highpass filtered image: fhp(x, y)=f(x, y)-flp(x, y)• High-boost image: fhb(x, y)=Af(x, y)-flp(x, y)
or fhb(x, y)=(A-1)f(x, y)-fhp(x, y)• In Freq. Domain: Fhp(u, v)= F(u, v)-Flp(u, v)
The highpass filter: Hhp(u, v)= 1-Hlp(u, v)The high-boost filter: Hhb(u, v)= (A-1)+Hhp(u, v), A≥1
• High frequency emphasis filter:Hhfe(u, v) = a+bHhp(u, v) where a≥0, b>aa=0.25~0.5, b=1.5~2.0
Image Comm. Lab EE/NTHU 51
4.4.5 Unsharp masking High-boost filtering and High frequency emphasis filtering
4.4.5 Unsharp masking High-boost filtering and High frequency emphasis filtering
Image Comm. Lab EE/NTHU 52
4.4.5 Unsharp masking High-boost filtering and High frequency emphasis filtering
4.4.5 Unsharp masking High-boost filtering and High frequency emphasis filtering
Image Comm. Lab EE/NTHU 53
4.5 Homomorphic Filtering
• Improve image by simultaneous gray-level range compression and contrast enhancement
f(x, y)=i(x, y)r(x, y)where i(x, y)=illumination, r(x, y)=reflectance
• i(x, y)and r(x, y) are not separable• Define z(x, y)=ln{f(x, y)}=ln{i(x, y)}+ln{r(x, y)}• F{z(x, y)}=F{ln f(x, y)}=F{ln i(x, y)}+F{ln r(x, y)}
or Z(u, v)=Fi(u, v)+Fr(u, v)• Applying filter H(u, v) :
S(u, v)=H(u, v)Z(u, v)=H(u, v)Fi(u, v)+H(u, v)Fr(u, v)
Image Comm. Lab EE/NTHU 54
4.5 Homomorphic Filtering
• S(x, y)=F-1{S(u, v)}=F-1{H(u, v)Fi(u, v)}+F-1{H(u, v)Fr(u, v)}=i’(x, y)+r’(x, y)
• g(x, y)=es(x, y)= ei’(x, y) ·er’(x, y)=i0(x, y)r0(x, y)• The illumination component is characterized by
slow spatial variation• The reflectance component tends to vary abruptly
especially at the junction of dissimilar objects.• Homomorphic filter H(u, v) affects the low and
high frequency components in a different ways.
54
Image Comm. Lab EE/NTHU 55
4.5 Homomorphic Filtering4.5 Homomorphic Filtering
LDvuDc
LH evuH γγγ +−−= − ]1)[(),( )/),(( 20
2
Image Comm. Lab EE/NTHU 56
4.5 Homomorphic Filtering4.5 Homomorphic Filtering
Image Comm. Lab EE/NTHU 57
4.6 Implmentation
• Translation
• DistributivityF[f1 (x, y)+f2 (x, y)]= F[f1 (x, y)]+F[f2 (x, y)]
• Scalingaf(x, y)⇔ aF (u, v) and f(ax, by)⇔ F (u/a, v/b)/|ab|
• Rotation (in polar coordinate, f(x, y) →f(r, θ), F(u, v)→F(ω,φ)).
f(r, θ+ θ0)⇔ F (ω,φ+ θ0)
),(),( 00)//(2 00 vvuuFeyxf NyvMxuj −−⇔+π
)//(200
00),(),( NvyMuxjevuFyyxxf +−⇔−− π
Image Comm. Lab EE/NTHU 58
4.6 Implmentation
• Periodicity and conjugate symmetryF(u, v)=F(u+M, v)=F(u, v+N)=F(u+M, v+N).f(x, y)=f(x+M, y)=f(x, y+N)=f(x+M, y+N).
• DFT is conjugate symmetry, i.e.F(u, v)=F*(-u, -v)F(u, v)=|F(-u, -v)|
• The values of F(u, v), u, v=(M/2)+1 ~ M-1 are reflection of the values of F(u, v), u, v=(M/2)-1 ~ 0
Image Comm. Lab EE/NTHU 59
4.6 Implmentation4.6 Implmentation
Image Comm. Lab EE/NTHU 60
4.6 Implmentation
• Separability
∑
∑ ∑−
=
−
−
=
−
=
−−
=
=
1
0
)/(2
1
0
1
0
)/(2)/(2
),(1
),(11),(
N
y
Nvyj
N
y
M
x
MuxjNvyj
eyuFMN
eyxfM
eN
vuF
π
ππ
u
y x
x u
f(x, y) )/(2 Muxje π− F(u, y)
y
Image Comm. Lab EE/NTHU 61
4.6 Implmentation4.6 Implmentation
F(u, y)
Image Comm. Lab EE/NTHU 62
4.6 Implmentation
• Computing Inverse DFT using forward DFT• The DFT and Inverse DFT are
• Take complex conjugate on both side and divide MN as
∑∑−
=
−
=
+−=1
0
1
0
)//(2),(1),(M
x
N
y
NvyMuxjeyxfMN
vuF π
∑∑−
=
−
=
+=1
0
1
0
)//(2),(),(M
u
N
v
NvyMuxjevuFyxf π
∑∑−
=
−
=
+−=1
0
1
0
)//(2** ),(1),(1 M
u
N
v
NvyMuxjevuFMN
yxfMN
π
Complex conjugate
DFT Complex conjugate
F(u, v) f(x, y)IDFT
Image Comm. Lab EE/NTHU 63
4.6 Implmentation4.6 Implmentation
∑−
=
−=∗1
0
)()(1)((M
m
mxhmfM
xhx)f
The periodic property of DFT
Image Comm. Lab EE/NTHU 64
fe(x)=f(x), 0≤x≤A-1 fe(x)=0, A≤x≤P he(x)=h(x), 0≤x≤B-1 he(x)=0, B≤x≤P
f(x)*h(x),→ fe(x)*he(x)
length P=A+B-1
4.6 Implmentation4.6 Implmentation
Image Comm. Lab EE/NTHU 65
4.6 Implmentation4.6 Implmentation
Image Comm. Lab EE/NTHU 66
4.6 Implmentation4.6 Implmentation
Image Comm. Lab EE/NTHU 67
4.6.4 The Convolution and Correlation Theorems
• Convolution
f(x, y) ∗ h(x, y)⇔F(u, v)H(u, v)f(x, y)h(x, y)⇔F(u, v)∗H(u, v)
• Correlationf(x, y)°h(x, y)=
• f(x, y)°h(x, y) ⇔F*(u, v)H(u, v)f*(x, y) h(x, y) ⇔F(u, v)°H(u, v)
• Autocorrelation: f(x, y)°f(x, y) ⇔ |F(u, v)|2
1 1
0 0
1 M N
m nf ( x, y )h( x m, y n )
MN
− −∗
= =
+ +∑∑
1 1
0 0
1 M N
m nf ( x, y )* h( x, y ) f ( x, y )h( x m, y n )
MN
− −∗
= =
= − −∑∑
Image Comm. Lab EE/NTHU 68
4.6.4 The Correlation4.6.4 The Correlation
Image Comm. Lab EE/NTHU 69
4.6 Implmentation4.6 Implmentation
Image Comm. Lab EE/NTHU 70
4.6 Implmentation4.6 Implmentation
Image Comm. Lab EE/NTHU 71
4.6 Implmentation4.6 Implmentation
Image Comm. Lab EE/NTHU 72
4.6 Implmentation4.6 Implmentation
Image Comm. Lab EE/NTHU 73
4.6 Implmentation – Fast Fourier Transform4.6 Implmentation – Fast Fourier Transform