IP Unit 2
IP Unit 2
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.1 Background
4.2 Introduction to the Fourier Transform and the
Frequency Domain
4.3 Smoothing Frequency-Domain Filters
4.4 Sharpening Frequency-Domain filters
4.5 Homomorphic Filtering
4.6 Implementation
1
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.1 Background
Source:http://www-groups.dcs.st-and.ac.uk/~history/PictDisplay/Fourier.html
© 2002 R. C. Gonzalez & R. E. Woods
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.1 Background
2
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.1 Background
Fourier Series
Any periodically repeated function can be expressed
of the sum of sines/cosines
sines/cosines of different frequencies,
frequencies,
each multiplied by a different coefficient
Fourier Transform
Finite curves can be expressed as the integral of
sines/cosines
sines/cosines multiplied by a weighing function
wildly used in signal processing field
Fourier Series/Transform can be reconstructed
completely via an inverse process
© 2002 R. C. Gonzalez & R. E. Woods
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
3
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Frequency Domain
Euler’s formula
e jθ = cos θ + j sin θ (4.2 - 7)
substituting this expression into Eq. (4.2-5)
1 M −1
F (u ) = ∑ f (x )[cos 2πux / M − j sin 2πux / M ]
M x =0
for u = 1, 2, ..., M - 1 (4.2 - 8)
F(u) f(x) Fourier Transform
f(x) F(u)
© 2002 R. C. Gonzalez & R. E. Woods
5
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
[ ]
1
F (u ) = R (u ) + I (u )
2 2 2
(4.2 - 10) R(u) I(u) F(u)
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
M x =0
K −1
1
=
M
∑ Ae
x =0
− j 2πux M
K −1
A
=
M
∑e
x =0
− j 2πux M
K −1
A
F (0) = ∑e − j 2π 0 x M
M x =0
A K −1
= ∑1
M x =0
AK
=
M
© 2002 R. C. Gonzalez & R. E. Woods
6
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
7
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
8
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
9
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
10
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
11
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
12
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
13
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
f ( x, y )* h( x, y ) ⇔ F (u , v )H (u , v ) (4.2 - 31)
f ( x, y )h( x, y ) ⇔ F (u , v )* H (u , v ) (4.2 - 32 )
14
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
h( x,y )
1
= (4.2 - 36)
MN
15
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
H (u ) = Ae −u
2
2
/ 2σ
(4.2 - 38)
h( x ) = 2π σAe −2π σ 2 x2
2
(4.2 - 39)
H (u ) = Ae −u / 2σ 12
- Be − u / 2σ 22
2 2
(4.2 - 40)
h( x ) = 2π σ 1 Ae −2π σ 12 x 2
- 2π σ 2 Be −2π σ 22 x 2
2 2
(4.2 - 41)
16
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
G (u , v ) = H (u , v )F (u , v ) (4.3 - 1)
4.3.1 Ideal Lowpass Filters
1 if D (u,v ) ≤ D0
H (u , v ) = (4.3 - 2)
0 if D(u,v ) > D0
D(u,v) , MxN
(M/2, N/2)
[
D (u , v ) = (u − M / 2 ) + (v − N / 2 )
2 2
]
1
2
(4.3 - 3)
17
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
α = 100 ∑∑ P(u, v ) / PT (4.3 - 5)
u v
18
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
a b c
d e f
19
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Frequency Domain : G (u , v ) = H (u , v )F (u , v )
Spatial Domain : g (x, y ) = h(x, y )* f (x, y )
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
20
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
H (u , v ) =
1
(4.3 - 6)
1 + [D(u , v ) D0 ]
2n
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
a b c
d e f
FIGURE 4.15 (a) Original image. (b)-(f) Results of filtering with BLPFs of order 2,
with cutoff frequencies at radii of 5, 15, 30, 80, 230, as shown in Fig. 4.11 (b).
Compare with Fig. 4.12.
© 2002 R. C. Gonzalez & R. E. Woods
21
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
H (u , v ) = e − D (u , v )
2
2 D02
(4.3 - 8)
22
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
a b c
d e f
FIGURE 4.18 (a) Original image. (b)-(f) Results of filtering with Gaussian lowpass
filters with cutoff frequencies set at radii of 5, 15, 30, 80, 230, as shown in Fig. 4.11
(b). Compare with Figs. 4.12 and 4.15.
© 2002 R. C. Gonzalez & R. E. Woods
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
23
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
24
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
H hp (u , v ) = 1 − H lp (u , v ) (4.4 - 1)
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
25
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
26
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
27
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
∇2 f ( x, y ) ⇔ −[(u − M / 2 ) ]
+ (v − N / 2 ) F (u , v )
2 2
(4.4 - 11)
g ( x, y ) = f ( x, y ) − ∇ 2 f ( x, y ) (4.4 - 12)
{ [
g ( x, y ) = ℑ−1 1 − (u − M 2) + (v − N 2) F (u, v)
2 2
] } (4.4 -13)
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
28
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
f hp ( x, y ) = f ( x, y ) − f lp ( x, y ) (4.4 - 14)
High-Boost filtering
f hb ( x, y ) = Af ( x, y ) − f lp ( x, y ) (4.4 - 15)
= (A - 1) f ( x, y ) + f ( x, y ) − f lp ( x, y ) (4.4 - 16)
= (A - 1) f ( x, y ) + f hp ( x, y ) (4.4 - 17)
29
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
30
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
31
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
illumination-reflectance model
simultaneous gray-level range compression and
contract enhancement
f ( x, y ) = i ( x, y )r ( x, y ). (4.5 - 1)
Let z ( x, y ) = ln f ( x, y )
= ln i ( x, y ) + ln r ( x, y ). (4.5 - 3)
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
S (u , v ) = H (u , v )Z (u , v )
= H (u,v )Fi (u,v ) + H (u,v )Fr (u,v ) (4.5 - 5)
s ( x, y ) = ℑ−1 {S (u , v )}
= ℑ−1 {H (u,v )Fi (u,v )}+ ℑ−1 {H (u,v )Fr (u,v )} (4.5 - 6)
32
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
g ( x, y ) = e s ( x , y )
= ei' ( x,y ) ⋅ e r' ( x,y )
= i0 ( x,y )r0 ( x,y ) (4.5 - 10)
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
33
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
34
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Distributivity
ℑ[ f1 ( x, y ) + f 2 ( x, y )] = ℑ[ f1 ( x, y )] + ℑ[ f 2 ( x, y )] (4.6 - 5)
ℑ[ f1 ( x, y ) ⋅ f 2 ( x, y )] ≠ ℑ[ f1 ( x, y )]⋅ ℑ[ f 2 ( x, y )] (4.6 - 6)
Scaling
af ( x, y ) ⇔ aF (u , v ) (4.6 - 7)
1 u v
f (ax, by ) ⇔ F , (4.6 - 8)
ab a b
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Rotation
Let x = r cos θ , y = r sin θ u = ω cos ϕ , v = ω sin ϕ
Then f ( x,y ) and F (u,v ) become f (r,θ ) and F (ω,ϕ )
f (r , θ + θ 0 ) ⇔ F (ω , ϕ + θ 0 ) (4.6 - 9)
35
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Periodicity
F (u , v ) = F (u + M , v ) = F (u , v + N ) = F (u + M , v + N ) (4.6 - 10)
f ( x,y ) = f ( x + M,y ) = f ( x,y + N ) = f ( x + M,y + N ) (4.6 - 11)
Conjugate symmetry
F (u , v ) = F * (− u ,−v ) (4.6 - 12)
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
36
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Separability
M −1 N −1
F (u, v ) = ∑ f (x, y )e
1 1
M
∑ e− j 2πux / M
x =0 N y =0
− j 2πvy / N
M −1
∑ F (x, v )e
1 − j 2πux / M
= (4.6 - 14)
M x =0
N −1
F ( x, v ) = ∑ f (x, y )e
1 − j 2πvy / N
(4.6 - 15)
N y =0
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
37
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
More on Periodicity
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
38
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
wraparound error
f (x ) 0 ≤ x ≤ A -1
f e (x ) = (4.6 - 21)
0 A≤x≤P
g (x ) 0 ≤ x ≤ B -1
g e (x ) = (4.6 - 22)
0 B≤ x ≤P
P≥A+B-1
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
2D
39
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
40
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The convolution and Correlation Theorems
Convolution Theorems
41
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The convolution and Correlation Theorems
Correlation Theorems
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The convolution and Correlation Theorems
42
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Summary of Properties of the 2D Fourier Transform
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Summary of Properties of the 2D Fourier Transform
43
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Summary of Properties of the 2D Fourier Transform
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Summary of Properties of the 2D Fourier Transform
44
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
M −1
F (u ) = ∑ f (x )W
1 ux
M (4.6 - 35)
M x =0
WM = e − j 2π / M (4.6 - 36)
1 1 k −1 1 k −1
= ∑ f (2 x )W2
u (2 x )
K + ∑ f (2 x + 1)W2uK(2 x +1) (4.6 - 39)
2 K x =0 K x =0
45
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
M −1
F (u ) = ∑ f (x )W
1 ux
M
2K x =0
1 1 k −1 1 k −1
= ∑ f (2 x )W u (2 x )
2K + ∑ f (2 x + 1)W2uK(2 x +1) (4.6 - 39)
2 K x =0 K x =0
1 k −1 1 k −1
∑ f (2 x )W2uK(2 x )
K x =0 ∑ f (2 x + 1)W2uK(2 x+1)
K x =0
© 2002 R. C. Gonzalez & R. E. Woods
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
M −1
F (u ) = ∑ f (x )W
1 ux
M
2K x =0
1 1 k −1 1 k −1
= ∑ f (2 x )W u (2 x )
2K + ∑ f (2 x + 1)W2uK(2 x +1) (4.6 - 39)
2 K x =0 K x =0
46
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
1 k −1
Defining Feven (u ) = ∑ f (2 x )WKux (4.6 - 41)
K x =0
1 k −1
Defining Fodd (u ) = ∑ f (2 x + 1)WKux (4.6 - 42)
K x =0
F (u ) =
1
2
[
Feven (u ) + Fodd (u )W2uK ] (4.6 - 43)
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
∴ F (u + K ) =
1
2
[
Feven (u + K ) + Fodd (u + K )W2uk+ k ]
1 1 K −1 1 K −1
= ∑ f (2 x )WK(u + K )x + ∑ f (2 x + 1)WK(u + K )xW2uk+ k
2 K x =0 K x =0
1 1 K −1
= ∑
2 K x =0
f (2 x )WK
ux
+
1 K −1
∑ (
f (2 x + 1)WKux − W2uK )
K x =0
1 1 K −1 1 K −1
= ∑ f (2 x )WKux − ∑ f (2 x + 1)WKuxW2uK
2 K x =0 K x =0
=
1
2
[
Feven (u ) − Fodd (u )W2uK ] (4.6 - 44)
© 2002 R. C. Gonzalez & R. E. Woods
47
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
F (0) =
1
2
[
Feven (0) + Fodd (0)W20k ]
[
F (1) = Feven (1) + Fodd (1)W21k
1
2
]
L
F (K − 1) =
1
2
[F even (K − 1) + Fodd (K − 1)W2KK−1 ]
F (0 + K ) =
1
2
[F even (0) − Fodd (0)W20K ]
F (1 + K ) =
1
2
[F even (1) − Fodd (1)W21K ]
F (K − 1 + K ) =
1
2
[F even (K − 1) − Fodd (K − 1)W2KK−1 ]
© 2002 R. C. Gonzalez & R. E. Woods
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
FFT
M = 2n
m(n ) =
1
M log 2 M (4.6 - 47)
2
a (n ) = M log 2 M (4.6 - 48)
48
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
M2
C (M ) =
M log 2 M
M
= (4.6 - 49)
log 2 M
2n
M = 2 n ⇒ C (n ) = (4.6 - 50)
n
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
49
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
The Fast Fourier Transformation
Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed. www.imageprocessingbook.com
4.6 Implementation
Some comments on filter design
• filter
Filter
filter
50