Chapter 4 Image Enhancement in The Frequency Domain
Chapter 4 Image Enhancement in The Frequency Domain
4. Image Enhancement in
the Frequency Domain
1
4. Image Enhancement in the Frequency Domain
Contents
Background
Introduction to the FT and the Frequency Domain
Smoothing Frequency-Domain Filters
Sharpening Frequency-Domain Filters
Homomorphic Filtering
Implementation
2
4. Image Enhancement in the Frequency Domain
Background
Fourier Series
Any function that periodically repeats itself can be expressed as
the sum of sines and / or cosines of different frequencies, each
multiplied by a different coefficient.
Fourier Series
2nx 2nx
f ( x) ao
n 1
(an cos
2L
bnsin
2L
) , ( p 2 L)
1 L
2 L L
a0 f ( x)dx,
1 L 2nx 1 L 2nx
an f ( x) cos( )dx, bn f ( x) sin( )dx
L L 2L L L 2L
complex Fourier Series
f ( x) c e
k
n
j 2nx / 2 L
, ( p 2 L)
1 L
cn
2L L
f ( x ) e j 2nx / 2 L dx
3
4. Image Enhancement in the Frequency Domain
Background (cont’)
Fourier Transform
Even functions that are not periodic can be expressed as the
integral of sines and / or cosines multiplied by a weighing
function.
proof of the 1-D FT
1 L/2
f ( x) cn e j 2nx / L , ( p L) cn f ( x ) e j 2nx / L
dx
k L L / 2
1
L/2
f ( x)
k
L
L / 2
f ( x ) e j 2nx / L dx e j 2nx / L
n n 1 n 1
L , U n , u un 1 un , lim u du
L L L L L
lim u f ( x )e j 2x ( n / L ) dx e j 2x ( n / L )
f ( x)
n
L
f ( x ) f ( x )e j 2ux dx e j 2ux du
F (u) f ( x)e j 2ux
dx f ( x) F (u )e j 2ux du
4
4. Image Enhancement in the Frequency Domain
5
4. Image Enhancement in the Frequency Domain
1-D Discrete FT
for discrete function f ( x), x 0, 1, 2, , M 1
DFT
M 1
1
F (u )
M
x 0
f ( x )e j 2ux / M
F (u)
f ( x)e j 2ux dx
for u 0, 1, 2, , M 1
IDFT
M 1
f ( x) F (u )e
u 0
j 2ux / M
f ( x)
F (u )e j 2ux du
for x 0, 1, 2, , M 1
6
4. Image Enhancement in the Frequency Domain
F (u) F (u) e j (u )
magnitude or spectrum of the FT
F (u) R (u) I (u)
2 2
1/ 2
( P V 2 / R, V amplitude, P / 2 (V / 2 )2
1/ 2 0.707 : cutoff frequency)
7
4. Image Enhancement in the Frequency Domain
(2)
M=1024, (1)
A=1,
K=8
(2)
8
4. Image Enhancement in the Frequency Domain
for u 0, 1, 2, , M 1
v 0, 1, 2, , N 1
IDFT
M 1 N 1
f ( x, y ) F (u, v)e
u 0 v 0
j 2 ( ux / M vy / N )
for x 0, 1, 2, , M 1
y 0, 1, 2, , N 1
9
4. Image Enhancement in the Frequency Domain
10
4. Image Enhancement in the Frequency Domain
11
4. Image Enhancement in the Frequency Domain
f ( x, y ) e j 2 (u0 x / M v0 y / N ) F (u u0 , v v0 )
M 1 N 1
proof) F (u, v) 1 f ( x, y )e j 2 (ux / M vy / N )
MN x 0 y 0
M 1 N 1
1
[ f ( x, y ) e j 2 ( u 0 x / M v0 y / N )
]
MN
x 0 y 0
f ( x, y )e j 2 (u0 x / M v0 y / N ) e j 2 (ux / M vy / N )
M 1 N 1
1
MN
x 0 y 0
f ( x, y )e j 2 (u u0 ) x / M ( v v0 ) y / N
F (u u0 , v v0 )
f ( x, y ) e j 2 (u0 x / M v0 y / N ) F (u u0 , v v0 )
12
4. Image Enhancement in the Frequency Domain
u0 M / 2, v0 N / 2 이면
j 2 ( x / M y / N )
M N
f ( x, y )e 2 2
F (u M / 2, v N / 2)
f ( x, y )e j ( x y ) F (u M / 2, v N / 2)
f ( x, y )( 1) F (u M / 2, v N / 2)
( x y )
f ( x, y) (1) x y F (u M / 2, v N / 2)
13
4. Image Enhancement in the Frequency Domain
(1) x y
f ( x, y)(1) x y F (u M / 2, v N / 2) (1)
(a)
(b)
2k
k (2)
(1) center the spectrum
(2) separation of spectrum zeros
14
4. Image Enhancement in the Frequency Domain
low frequency
F (0,0)
15
4. Image Enhancement in the Frequency Domain
16
4. Image Enhancement in the Frequency Domain
17
4. Image Enhancement in the Frequency Domain
18
4. Image Enhancement in the Frequency Domain
LPF
k
HPF H (u, v) H (u, v) ,
2
(k filter height )
19
4. Image Enhancement in the Frequency Domain
x 0 y 0 m 0 n 0
M 1 N 1 M 1 N 1 u ( x m) v ( y n ) um vn
j 2 j 2
f (m, n) h( x m, y n)e M N
e M N
m 0 n 0 x 0 y 0
M 1 N 1 um vn
j 2
f (m, n)H (u, v)e M N
m 0 n 0
M 1 N 1 um vn
j 2
H (u, v) f (m, n)e M N
m 0 n 0
H (u, v) F (u, v)
21
4. Image Enhancement in the Frequency Domain
22
4. Image Enhancement in the Frequency Domain
23
4. Image Enhancement in the Frequency Domain
H (u) Ae u 2 / 2 2
where, is standard deviation
2 2 2 x 2
h( x) 2 Ae
24
4. Image Enhancement in the Frequency Domain
A B, 1 2
u2 u2
2 12 2 2 2
H (u ) Ae Be
2 2 12 x 2
h( x) 21 Ae
2 2 2 2 x 2
22 Ae
25
4. Image Enhancement in the Frequency Domain
sorts
Ideal Lowpass Filter high
Butterworth Filter
filter order
Gaussian Filter low
26
4. Image Enhancement in the Frequency Domain
where, D(u, v) (u M / 2) 2 (v N / 2) 2 1/ 2
27
4. Image Enhancement in the Frequency Domain
% 100 P(u, v) / PT
u v
28
4. Image Enhancement in the Frequency Domain
D0 15 D0 30
94.6% 96.4%
D0 80 D0 230
ringing effect
98% 99.5%
29
4. Image Enhancement in the Frequency Domain
Inverse DFT
(c) (d)
(b) * (c)
Five impulses
δ ( x , y ) * h ( x, y )
in the spatial domain
30
4. Image Enhancement in the Frequency Domain
31
4. Image Enhancement in the Frequency Domain
(n 2)
D0 30
D0 15
(1) smooth transition
32
4. Image Enhancement in the Frequency Domain
n 1 n2 n5 n 20
33
4. Image Enhancement in the Frequency Domain
D 2 ( u ,v ) / 2 D0 2
H (u, v) e
34
4. Image Enhancement in the Frequency Domain
D0 15 D0 30
35
4. Image Enhancement in the Frequency Domain
using a GLPF
with D0 80
36
4. Image Enhancement in the Frequency Domain
using a GLPF
with D0 80
original image
using a GLPF
“cosmetic” processing
with D0 100
37
4. Image Enhancement in the Frequency Domain
38
4. Image Enhancement in the Frequency Domain
H hp (u, v) 1 H lp (u, v)
sorts
Ideal highpass filter
Butterworth highpass filter
Gaussian highpass filter
39
4. Image Enhancement in the Frequency Domain
40
4. Image Enhancement in the Frequency Domain
ringing effect
spatial representations of typical ideal, Butterworth,
and Gaussian Frequency domain highpass filters
41
4. Image Enhancement in the Frequency Domain
ringing effect
42
4. Image Enhancement in the Frequency Domain
43
4. Image Enhancement in the Frequency Domain
44
4. Image Enhancement in the Frequency Domain
f ( x)e j 2ux
j 2u f ( x) 0 j 2u f ( x) ( j 2u ) f ( x)
d n f ( x)
( j 2u ) F (u )
n
n
dx
2 f ( x, y ) 2 f ( x, y)
( j 2u ) 2
F (u, v ) ( j 2v ) 2
F (u, v)
x y
2 2
2 f ( x, y) 4 2 (u 2 v 2 ) F (u, v)
H (u, v) 4 2 (u 2 v 2 )
45
4. Image Enhancement in the Frequency Domain
H (u, v) 4 2 (u 2 v 2 )
46
4. Image Enhancement in the Frequency Domain
Laplacian
Enhancement is achieved using equation
g(x,y)= f(x,y) +c
C=-1 as H(u,v) is negative
{[1+4π2D2(u,v)]F(u,v)}
47
4. Image Enhancement in the Frequency Domain
h( x, y) 1 4 2 (u M / 2)2 (v N / 2)2
48
4. Image Enhancement in the Frequency Domain
2 f ( x, y )
2 M 2 N 2
4 (u ) (v ) F (u, v)
1
2 2
g ( x, y) f ( x, y) 2 f ( x, y)
scaling
g ( x, y)
M N
1 1 4 2 (u )2 (v )2 F (u, v)
2 2
49
4. Image Enhancement in the Frequency Domain
50
4. Image Enhancement in the Frequency Domain
Laplacian of (a)
A=2 A=2.7
51
4. Image Enhancement in the Frequency Domain
result of Butterworth
highpass filtering
result of performing
histogram equalization
on (c)
Homomorphic Filtering
Homomorphic filtering approach
The separation of the illumination and reflectance components
f ( x, y ) i ( x, y ) r ( x, y )
z ( x, y ) ln f ( x, y ) ln i( x, y ) ln r ( x, y )
z( x, y) ln f ( x, y) ln i( x, y) ln r ( x, y)
ln i( x, y) Fi (u, v), ln r ( x, y) Fr (u, v)
Z (u, v) Fi (u, v) Fr (u, v)
S (u, v) H (u, v)Z (u, v) H (u, v) Fi (u, v) H (u, v) Fr (u, v)
s( x, y ) 1H (u, v) Fi (u, v) 1H (u, v) Fr (u, v)
s( x, y) i ' ( x, y) r ' ( x, y)
i ' ( x, y ) 1H (u, v) Fi (u, v), r ' ( x, y) 1H (u, v) Fr (u, v),
g ( x, y) e s ( x, y ) ei ( x, y ) e r ( x, y ) i0 ( x, y)r0 ( x, y)
' '
i0 ( x, y) ei ( x, y ) , r0 ( x, y) e r ( x, y )
' '
g ( x, y) e i ' ( x, y )
e r ' ( x, y )
53
4. Image Enhancement in the Frequency Domain
Homomorphic Filtering
Homomorphic filtering approach
H 1, L 1
illumination↓ a reduction of dynamic range,
reflectance↑ Increase in contrast
54
4. Image Enhancement in the Frequency Domain
H (u, v) ( H L ) 1 e c ( D 2 ( u ,v ) / D02 )
,
L
( L 0.5, H 2.0)
H 1, L 1
0 , if (u, v) ( M / 2, N / 2)
H (u, v)
1 , otherwise
56
4. Image Enhancement in the Frequency Domain
57
4. Image Enhancement in the Frequency Domain
Implementation
some additional properties of the 2-D FT
translation
f ( x, y ) e j 2 (u0 x / M v0 y / N ) F (u u0 , v v0 )
rotation
x r cos , y r sin , u w cos , v w sin
f ( x, y ) f (r , ), F (u, v) F ( w, )
f (r , 0 ) F ( w, 0 )
58
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
some additional properties of the 2-D FT (cont’)
periodicity and conjugate symmetry
F (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 )
F (u, v) F (u,v)
separability
M 1
1 1 N 1
F (u, v)
M
e
x 0
j 2ux / M
N y 0
f ( x, y )e j 2vy / N
M 1
1
M
F ( x, v )e
x 0
j 2ux / M
1 N 1
F ( x, v) f ( x, y)e j 2vy / N
N y 0
59
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
computing the inverse FT using a forward
transform algorithm
M 1 M 1
1
F (u )
M
f ( x )e
x 0
j 2ux / M
, f ( x) F (u )e j 2ux / M
u 0
M 1
1 * 1
M
f ( x)
M
F
u 0
*
(u )e j 2ux / M
M 1 N 1
1 * 1
MN
f ( x, y )
MN
F
u 0 v 0
*
(u , v)e j 2 (ux / M ,vy / N )
60
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
more on periodicity : the need for padding
problem : convolution of the functions
Wraparound error
61
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
more on periodicity : the need for padding (cont’)
solution : extended or padded function
f ( x), 0 x A 1
f e ( x)
0, A x P
h( x), 0 x B 1
he ( x)
0, B x P
P A B 1
62
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
more on periodicity : the need for padding (cont’)
2-D
f ( x, y ), 0 x A 1 and 0 y B 1
f e ( x, y )
0, A x P or B y Q
h( x, y ), 0 x C 1 and 0 y D 1
he ( x, y )
0, C xP or D y Q
63
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
more on periodicity : the need for padding (cont’)
example
(a) padded lowpass filter in the spatial domain
(b) result of filtering with padding
64
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
the convolution and correlation theorems
correlation theorems – for matching
M 1 N 1
1
f ( x, y ) * h ( x, y )
MN
f (m, n)h( x m, y n)
m 0 n 0
M 1 N 1
1
f ( x, y ) h ( x, y )
MN
f
m 0 n 0
*
(m, n)h( x m, y n)
f ( x, y) h( x, y) F * (u, v) H (u, v)
f * ( x, y)h( x, y) F (u, v) H (u, v)
cross correlation
To clarify that the images being correlated are different
autocorrelation
both images are identical
f ( x, y ) f ( x, y ) F (u, v) f ( x, y ) F (u, v) F (u, v)
2 2
65
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
the convolution and correlation theorems (cont’)
example
f ( x , y ) h ( x, y )
66
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
the Fast Fourier Transform
successive doubling method
1 M 1 1 M 1
F (u )
M x 0
f ( x )e j 2ux / M
M x 0
f ( x)WMux , (WM e j 2 / M )
M 2n 2 K
1 2 K 1 1 1 K 1 1 K 1 u ( 2 x 1)
F (u )
2 K x 0
f ( x )W ux
2K
2 K x 0
f ( 2 x )W u(2 x)
2K
K x 0
f ( 2 x 1)W2K
1 1 K 1 1 K 1
(W W ), F (u ) f (2 x)WK f (2 x 1)WKuxW2uK
2ux
2K
ux
K
ux
2 K x 0 K x 0
K 1 K 1
1 1
Feven (u ) f (2 x)WKux , Fodd (u ) f (2 x 1)WKux
K x 0 K x 0
1
F (u ) Feven (u ) Fodd (u )W2uK , (WMu M WMu , W2uM M W2uM )
2
1
F (u K ) Feven (u ) Fodd (u )W2uK
2
67
4. Image Enhancement in the Frequency Domain
Implementation (cont’)
the Fast Fourier Transform (cont’)
total computational counting
M 2n 2 K
m(n) 2m(n 1) 2n1 , (n 1)
a(n) 2a(n 1) 2n , (n 1)
1
m(n) M log 2M ,
2
a(n) M log 2M
M2 M
C (M ) M
M
, (M 2n )
M log 2 log 2
computational advantage of the FFT over
2n
C ( n) a direct implementation of the 1-D DFT
n
68