ENG4BF3
Medical Image Processing
Image Enhancement in
Frequency Domain
Image Enhancement
Original image Enhanced image
Enhancement: to process an image for more
suitable output for a specific application.
2
Image Enhancement
• Image enhancement techniques:
Spatial domain methods
Frequency domain methods
• Spatial (time) domain techniques are techniques that
operate directly on pixels.
• Frequency domain techniques are based on modifying
the Fourier transform of an image.
3
Fourier Transform: a review
• Basic ideas:
A periodic function can be
represented by the sum of
sines/cosines functions of
different frequencies,
multiplied by a different
coefficient.
Non-periodic functions can
also be represented as the
integral of sines/cosines
multiplied by weighing
function.
4
Joseph Fourier
(1768-1830)
Fourier was obsessed
with the physics of
heat and developed
the Fourier transform
theory to model heat-
flow problems.
5
Fourier transform
basis functions
Approximating a
square wave as the
sum of sine waves.
6
Any function can be written as the
sum of an even and an odd function
E ( x) [ f ( x) f ( x)] / 2
E(-x) = E(x)
O( x) [ f ( x) f ( x )] / 2
O(-x) = -O(x)
f ( x) E ( x) O( x)
7
Fourier Cosine Series
Because cos(mt) is an even function, we can write an even
function, f(t), as:
F
1
f(t) m cos(mt)
m 0
where series Fm is computed as
Fm
f (t ) cos(mt ) dt
Here we suppose f(t) is over the interval (–π,π).
8
Fourier Sine Series
Because sin(mt) is an odd function, we can write any
odd function, f(t), as:
1
f (t) Fmsin(mt)
m 0
where the series F’m is computed as
Fm
f (t ) sin( mt ) dt
9
Fourier Series
So if f(t) is a general function, neither even nor
odd, it can be written:
1 1
f (t )
m 0
Fm cos(mt )
m 0
Fm sin(mt )
Even component Odd component
where the Fourier series is
Fm
f (t) cos(mt) dt Fm
f (t) sin(mt) dt
10
The Fourier Transform
Let F(m) incorporates both cosine and sine series coefficients,
with the sine series distinguished by making it the imaginary
component:
F (m) Fm jFm' f (t ) cos(mt )dt j f (t ) sin(mt )dt
Let’s now allow f(t) range from – to , we rewrite:
f (t ) F (u ) f (t ) exp( j 2ut )dt
F(u) is called the Fourier Transform of f(t). We say that f(t)
lives in the “time domain,” and F(u) lives in the “frequency
domain.” u is called the frequency variable.
11
The Fourier Transform
u·x 1/M
12
d a
time domain frequency domain
d=a+b+ b time domain frequency domain
c
time domain frequency domain time domain frequency domain
13
The Inverse Fourier Transform
We go from f(t) to F(u) by
Fourier
f (t ) F (u ) f (t ) exp( j 2ut )dt
Transform
Given F(u), f(t) can be obtained by the inverse Fourier transform
Inverse
1 F (u ) f (t ) F (u ) exp( j 2ut )du Fourier
Transform
14
Discrete Fourier Transform (DFT)
• A continuous function f(x) is discretized as:
{ f ( x0 ), f ( x0 x), f ( x0 2x),..., f ( x0 ( M 1)x)}
15
Discrete Fourier Transform (DFT)
Let x denote the discrete values (x=0,1,2,…,M-1),
i.e.
f ( x) f ( x0 xx)
then
{ f ( x0 ), f ( x0 x), f ( x0 2x),..., f ( x0 ( M 1)x)}
{ f (0), f (1), f (2),..., f ( M 1)}
16
Discrete Fourier Transform (DFT)
• The discrete Fourier transform pair that applies to
sampled functions is given by:
M 1
1
F (u )
M
f ( x) exp( j 2ux / M )
x 0
u=0,1,2,…,M-1
and
M 1
f ( x) F (u ) exp( j 2ux / M ) x=0,1,2,…,M-1
u 0
17
2-D Discrete Fourier Transform
• In 2-D case, the DFT pair is:
M 1 N 1
1
F (u, v)
MN
f ( x, y) exp( j 2 (ux / M vy / N ))
x 0 y 0
u=0,1,2,…,M-1 and v=0,1,2,…,N-1
and:
M 1 N 1
f ( x, y ) F (u , v) exp( j 2 (ux / M vy / N ))
u 0 v 0
x=0,1,2,…,M-1 and y=0,1,2,…,N-1
18
Polar Coordinate Representation of FT
• The Fourier transform of a real function is generally
complex and we use polar coordinates:
F (u , v) R (u , v) j I (u , v)
Polar coordinate
F (u , v) F (u , v) exp( j (u , v))
Magnitude: F (u , v) [ R 2 (u , v) I 2 (u , v)]1/ 2
I (u, v)
Phase: (u, v) tan 1
R(u, v)
19
Fourier Transform: shift
• It is common to multiply input image by (-1)x+y prior to
computing the FT. This shift the center of the FT to (M/2,N/2).
f ( x, y ) F (u , v)
f ( x, y )(1) x y F (u M / 2, v N / 2)
Shift
20
Symmetry of FT
• For real image f(x,y), FT is conjugate symmetric:
F (u, v) F (u, v) *
• The magnitude of FT is symmetric:
F (u , v) F (u , v)
21
FT
IFT
22
IFT
IFT
23
The central part of FT, i.e.
the low frequency
components are responsible
for the general gray-level
appearance of an image.
The high frequency
components of FT are
responsible for the detail
information of an image.
24
Image Frequency Domain
(log magnitude)
v Detail
General
appearance
25
5% 10 % 20 % 50 %
26
Frequency Domain Filtering
27
Frequency Domain Filtering
• Edges and sharp transitions (e.g., noise) in an
image contribute significantly to high-frequency
content of FT.
• Low frequency contents in the FT are
responsible to the general appearance of the
image over smooth areas.
• Blurring (smoothing) is achieved by attenuating
range of high frequency components of FT.
28
Convolution in Time Domain
g(x,y)=h(x,y)f(x,y)
M 1 M 1
g( x , y ) h( x' , y' ) f ( x x' , y y' )
x' 0 y ' 0
f ( x , y )* h( x , y )
– f(x,y) is the input image
– g(x,y) is the filtered
– h(x,y): impulse response
29
Convolution Theorem
Multiplication in
G(u,v)=F(u,v)H(u,v) Frequency Domain
g(x,y)=h(x,y)f(x,y) Convolution in
Time Domain
• Filtering in Frequency Domain with H(u,v) is
equivalent to filtering in Spatial Domain with f(x,y).
30
blue line = sum of 3 sinusoids (20,
50, and 80 Hz) + random noise
red line = sum of 3 sinusoids
without
withou noise
blue line = sum of 3 sinusoids after
filtering in time domain
1x average [1 1 1 1 1] / 5
blue line = sum of 3 sinusoids after
filtering in frequency domain
cut-off 90 Hz
31
Algorithm Complexity
• We can compute the DFT directly using the formula
– An N point DFT would require N2 floating point multiplications per
output point
– Since there are N2 output points , the computational complexity of the
DFT is N4
– N4=4x109 for N=256
– Bad news! Many hours on a workstation
32
Algorithm Complexity
• The FFT algorithm was developed in the 60’s for seismic
exploration
• Reduced the DFT complexity to 2N2log2N
– 2N2log2N~106 for N=256
– A few seconds on a workstation
33
Examples of Filters
Frequency
domain
Gaussian lowpass filter Gaussian highpass filter
Spatial
domain
34
Ideal low-pass filter (ILPF)
1 D(u, v) D0
H (u, v)
0 D(u, v) D0
D(u , v) [(u M / 2) (v N / 2) ]
2 2 1/ 2
(M/2,N/2): center in frequency domain
D0 is called the cutoff frequency.
35
Shape of ILPF
Frequency domain
h(x,y)
Spatial domain
36
FT
ringing
and
Ideal in frequency blurring
domain means
non-ideal in
spatial domain,
vice versa.
37
Butterworth Lowpass Filters (BLPF)
• Smooth transfer function, 1
no sharp discontinuity, H (u, v) 2n
D(u, v)
no clear cutoff 1
D0
frequency.
1
2
38
Butterworth Lowpass Filters (BLPF)
n=1 n=2 n=5 n=20
h(x)
1
H (u, v) 2n
D(u , v)
1
D 0
39
No serious
ringing
artifacts
40
Gaussian Lowpass Filters (GLPF)
• Smooth transfer function,
2
smooth impulse
D ( u ,v )
response, no ringing H (u , v) e 2 D 20
41
GLPF
Frequency
domain
Gaussian lowpass filter
Spatial
domain
42
No ringing
artifacts
43
Examples of Lowpass Filtering
44
Examples of Lowpass Filtering
Low-pass filter H(u,v)
Original image and its FT Filtered image and its FT
45
High-pass Filters
• Hhp(u,v)=1-Hlp(u,v)
1 D(u, v) D0
• Ideal: H (u, v)
0 D(u, v) D0
1
• Butterworth: | H (u, v) |
2
2n
D0
1
D (u , v )
• Gaussian: D 2 ( u ,v ) / 2 D02
H (u , v) 1 e
46
47
High-pass Filters
h(x,y)
48
Ideal High-pass Filtering
ringing artifacts
49
Butterworth High-pass Filtering
50
Gaussian High-pass Filtering
51
Gaussian High-pass Filtering
Gaussian filter H(u,v)
Original image
Filtered image and its FT
52
Laplacian in Frequency Domain
2 f ( x , y ) 2 f ( x, y )
[ ] 2
2
(u v ) F (u, v)
x 2
y 2
H1 (u , v) 2
(u v )2
Frequency
Spatial domain
f 2
f domain
2
f 2 2
2
Laplacian operator
x y
53
54
Subtract Laplacian from the Original
Image to Enhance It
enhanced Original Laplacian
image image output
Spatial
g ( x , y ) f ( x, y ) 2
f ( x, y )
domain
Frequency
G (u, v) F (u, v) (u 2 v 2 ) F (u , v)
domain
new operator H 2 (u , v) 1 (u 2 v 2 ) 1 H 1 (u , v)
Laplacian
55
f 2 f
f f
2
56
Unsharp Masking, High-boost Filtering
• Unsharp masking: fhp(x,y)=f(x,y)-flp(x,y)
• Hhp(u,v)=1-Hlp(u,v)
One more
parameter to
• High-boost filtering: adjust the
enhancement
fhb(x,y)=Af(x,y)-flp(x,y)
• fhb(x,y)=(A-1)f(x,y)+fhp(x,y)
• Hhb(u,v)=(A-1)+Hhp(u,v)
57
58
End of Lecture
59