งานนำเสนอ PowerPoint - Ajay...
Transcript of งานนำเสนอ PowerPoint - Ajay...
18-11-2015
1
Unit 6 (continued) Image Enhancement in the
Frequency Domain
Background: Fourier Series
Any periodic signals can be
viewed as weighted sum
of sinusoidal signals with
different frequencies
Fourier series:
Frequency Domain:
view frequency as an
independent variable
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Fourier Tr. and Frequency Domain
Time, spatial
Domain
Signals
Frequency
Domain
Signals
Fourier Tr.
Inv Fourier Tr.
1-D, Continuous case
dxexfuF uxj 2)()(Fourier Tr.:
dueuFxf uxj 2)()(Inv. Fourier Tr.:
Fourier Tr. and Frequency Domain (cont.)
1-D, Discrete case
1
0
/2)(1
)(M
x
MuxjexfM
uF Fourier Tr.:
Inv. Fourier Tr.:
1
0
/2)()(M
u
MuxjeuFxf
u = 0,…,M-1
x = 0,…,M-1
F(u) can be written as
)()()( ujeuFuF or )()()( ujIuRuF
22 )()()( uIuRuF
where
)(
)(tan)( 1
uR
uIu
Example of 1-D Fourier Transforms
Notice that the longer
the time domain signal,
The shorter its Fourier
transform
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
18-11-2015
2
Relation Between Dx and Du
For a signal f(x) with M points, let spatial resolution Dx be space
between samples in f(x) and let frequency resolution Du be space
between frequencies components in F(u), we have
xMu
DD
1
Example: for a signal f(x) with sampling period 0.5 sec, 100 point,
we will get frequency resolution equal to
Hz02.05.0100
1
Du
This means that in F(u) we can distinguish 2 frequencies that are
apart by 0.02 Hertz or more.
2-Dimensional Discrete Fourier Transform
1
0
1
0
)//(2),(1
),(M
x
N
y
NvyMuxjeyxfMN
vuF
2-D IDFT
1
0
1
0
)//(2),(),(M
u
N
v
NvyMuxjevuFyxf
2-D DFT
u = frequency in x direction, u = 0 ,…, M-1
v = frequency in y direction, v = 0 ,…, N-1
x = 0 ,…, M-1
y = 0 ,…, N-1
For an image of size MxN pixels
F(u,v) can be written as
),(),(),( vujevuFvuF or ),(),(),( vujIvuRvuF
22 ),(),(),( vuIvuRvuF
where
),(
),(tan),( 1
vuR
vuIvu
2-Dimensional Discrete Fourier Transform (cont.)
For the purpose of viewing, we usually display only the
Magnitude part of F(u,v)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
2-D DFT Properties
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
2-D DFT Properties (cont.)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
2-D DFT Properties (cont.)
18-11-2015
3
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
2-D DFT Properties (cont.)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Computational Advantage of FFT Compared to DFT
Relation Between Spatial and Frequency Resolutions
xMu
DD
1
yNv
DD
1
where
Dx = spatial resolution in x direction
Dy = spatial resolution in y direction
Du = frequency resolution in x direction
Dv = frequency resolution in y direction
N,M = image width and height
( Dx and Dy are pixel width and height. )
How to Perform 2-D DFT by Using 1-D DFT
f(x,y)
1-D
DFT
by row F(u,y)
1-D DFT
by column
F(u,v)
How to Perform 2-D DFT by Using 1-D DFT (cont.)
f(x,y)
1-D
DFT
by row F(x,v)
1-D DFT
by column
F(u,v)
Alternative method
Periodicity of 1-D DFT
0 N 2N -N
DFT repeats itself every N points (Period = N) but we usually
display it for n = 0 ,…, N-1
We display only in this range
1
0
/2)(1
)(M
x
MuxjexfM
uF From DFT:
18-11-2015
4
Conventional Display for 1-D DFT
0 N-1
Time Domain Signal
DFT
f(x)
)(uF
0 N-1
Low frequency
area
High frequency
area
The graph F(u) is not
easy to understand !
)(uF
0 -N/2 N/2-1
)(uF
0 N-1
Conventional Display for DFT : FFT Shift
FFT Shift: Shift center of the
graph F(u) to 0 to get better
Display which is easier to
understand.
High frequency area
Low frequency area
Periodicity of 2-D DFT
For an image of size NxM
pixels, its 2-D DFT repeats
itself every N points in x-
direction and every M points
in y-direction.
We display only
in this range
1
0
1
0
)//(2),(1
),(M
x
N
y
NvyMuxjeyxfMN
vuF
0 N 2N -N
0
M
2M
-M
2-D DFT:
g(x,y)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Conventional Display for 2-D DFT
High frequency area
Low frequency area
F(u,v) has low frequency areas
at corners of the image while high
frequency areas are at the center
of the image which is inconvenient
to interpret.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
2-D FFT Shift : Better Display of 2-D DFT
2D FFTSHIFT
2-D FFT Shift is a MATLAB function: Shift the zero frequency
of F(u,v) to the center of an image.
High frequency area Low frequency area (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Original display
of 2D DFT
0 N 2N -N
0
M
2M
-M
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Display of 2D DFT
After FFT Shift
2-D FFT Shift (cont.) : How it works
18-11-2015
5
Example of 2-D DFT
Notice that the longer the time domain signal,
The shorter its Fourier transform (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example of 2-D DFT
Notice that direction of an
object in spatial image and
Its Fourier transform are
orthogonal to each other.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example of 2-D DFT
Original image
2D DFT
2D FFT Shift
Example of 2-D DFT
Original image
2D DFT
2D FFT Shift
Basic Concept of Filtering in the Frequency Domain
From Fourier Transform Property:
),(),(),(),(),(),( vuGvuHvuFyxhyxfyxg
We can perform filtering process by using
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Multiplication in the frequency domain
is easier than convolution in the spatial
Domain.
Filtering in the Frequency Domain with FFT shift
f(x,y)
2D FFT
FFT shift
F(u,v)
FFT shift
2D IFFT X
H(u,v)
(User defined)
G(u,v)
g(x,y)
In this case, F(u,v) and H(u,v) must have the same size and
have the zero frequency at the center.
18-11-2015
6
0 20 40 60 80 100 120
0
0.5
1
0 20 40 60 80 100 120
0
0.5
1
0 20 40 60 80 100 1200
20
40
Multiplication in Freq. Domain = Circular Convolution
f(x) DFT F(u) G(u) = F(u)H(u)
h(x) DFT H(u) g(x) IDFT
Multiplication of
DFTs of 2 signals
is equivalent to
perform circular
convolution
in the spatial domain.
f(x)
h(x)
g(x)
“Wrap around” effect
H(u,v)
Gaussian
Lowpass
Filter with D0 = 5
Original image
Filtered image
(obtained using circular convolution)
Incorrect areas at image rims
Multiplication in Freq. Domain = Circular Convolution
Linear Convolution by using Circular Convolution and Zero Padding
f(x) DFT F(u) G(u) = F(u)H(u)
h(x) DFT H(u)
g(x)
IDFT
Zero padding
Zero padding
Concatenation
0 50 100 150 200 250
0
0.5
1
0 50 100 150 200 250
0
0.5
1
0 50 100 150 200 2500
20
40
Padding zeros Before DFT
Keep only this part
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Linear Convolution by using Circular Convolution and Zero Padding
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Linear Convolution by using Circular Convolution and Zero Padding
Zero padding area in the spatial
Domain of the mask image (the ideal lowpass filter)
Filtered image
Only this area is kept.
Filtering in the Frequency Domain : Example
In this example, we set F(0,0) to zero
which means that the zero frequency
component is removed.
Note: Zero frequency = average
intensity of an image (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
18-11-2015
7
Filtering in the Frequency Domain : Example
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Highpass Filter
Lowpass Filter
Filtering in the Frequency Domain : Example (cont.)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Result of Sharpening Filter
Filter Masks and Their Fourier Transforms
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Ideal Lowpass Filter
0
0
),( 0
),( 1),(
DvuD
DvuDvuH
where D(u,v) = Distance from (u,v) to the center of the mask.
Ideal LPF Filter Transfer function
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Examples of Ideal Lowpass Filters
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
The smaller D0, the more high frequency components are removed.
Results of Ideal Lowpass Filters
Ringing effect can be
obviously seen!
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
18-11-2015
8
How ringing effect happens
Ideal Lowpass Filter
with D0 = 5
-20
0
20
-20
0
20
0
0.2
0.4
0.6
0.8
1
Surface Plot
Abrupt change in the amplitude
0
0
),( 0
),( 1),(
DvuD
DvuDvuH
How ringing effect happens (cont.)
-20
0
20
-20
0
20
0
5
10
15
x 10-3
Spatial Response of Ideal
Lowpass Filter with D0 = 5
Surface Plot
Ripples that cause ringing effect
How ringing effect happens (cont.)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Butterworth Lowpass Filter
NDvuD
vuH2
0/),(1
1),(
Transfer function
Where D0 = Cut off frequency, N = filter order.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Results of Butterworth Lowpass Filters
There is less ringing
effect compared to
those of ideal lowpass
filters!
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Spatial Masks of the Butterworth Lowpass Filters
Some ripples can be seen. (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
18-11-2015
9
Gaussian Lowpass Filter
20
2 2/),(),(
DvuDevuH
Transfer function
Where D0 = spread factor.
Note: the Gaussian filter is the only filter that has no ripple and
hence no ringing effect.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Gaussian Lowpass Filter (cont.)
-20
0
20
-20
0
20
0.2
0.4
0.6
0.8
1
Gaussian lowpass
filter with D0 = 5
-20
0
20
-20
0
20
0
0.01
0.02
0.03
Spatial respones of the
Gaussian lowpass filter
with D0 = 5
Gaussian shape
20
2 2/),(),(
DvuDevuH
Results of Gaussian Lowpass Filters
No ringing effect!
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Application of Gaussian Lowpass Filters
The GLPF can be used to remove jagged edges
and “repair” broken characters.
Better Looking Original image
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Application of Gaussian Lowpass Filters (cont.)
Remove wrinkles
Softer-Looking
Original image
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Application of Gaussian Lowpass Filters (cont.)
Remove artifact lines: this is a simple but crude way to do it!
Filtered image Original image : The gulf of Mexico and
Florida from NOAA satellite. (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
18-11-2015
10
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Highpass Filters
Hhp = 1 - Hlp
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Ideal Highpass Filters
0
0
),( 1
),( 0),(
DvuD
DvuDvuH
where D(u,v) = Distance from (u,v) to the center of the mask.
Ideal HPF Filter Transfer function
Butterworth Highpass Filters
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
NvuDD
vuH2
0 ),(/1
1),(
Transfer function
Where D0 = Cut off frequency, N = filter order.
Gaussian Highpass Filters
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
20
2 2/),(1),(
DvuDevuH
Transfer function
Where D0 = spread factor.
Gaussian Highpass Filters (cont.)
20
2 2/),(1),(
DvuDevuH
1020
3040
5060
20
40
60
0
0.2
0.4
0.6
0.8
1
1020
3040
5060
20
40
60
0
1000
2000
3000
Gaussian highpass
filter with D0 = 5
Spatial respones of the
Gaussian highpass filter
with D0 = 5
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Spatial Responses of Highpass Filters
Ripples
18-11-2015
11
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Results of Ideal Highpass Filters
Ringing effect can be
obviously seen!
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Results of Butterworth Highpass Filters
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Results of Gaussian Highpass Filters
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Laplacian Filter in the Frequency Domain
( )()(
uFjudx
xfd n
n
n
From Fourier Tr. Property:
Then for Laplacian operator
( ),(22
2
2
2
22 vuFvu
y
f
x
ff
Surface plot
( 222 vu
We get
Image of –(u2+v2)
Laplacian Filter in the Frequency Domain (cont.)
Spatial response of –(u2+v2) Cross section
Laplacian mask in Chapter 3
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Sharpening Filtering in the Frequency Domain
),(),(),( yxfyxfyxf lphp
),(),(),( yxfyxAfyxf lphb
Spatial Domain
Frequency Domain Filter
),(),(),()1(),( yxfyxfyxfAyxf lphb
),(),()1(),( yxfyxfAyxf hphb
),(1),( vuHvuH lphp
),()1(),( vuHAvuH hphb
18-11-2015
12
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Sharpening Filtering in the Frequency Domain (cont.)
p P2
P2 PP 2
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Sharpening Filtering in the Frequency Domain (cont.)
),(),()1(),( yxfyxfAyxf hphb
Pfhp
2f
A = 2 A = 2.7
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
High Frequency Emphasis Filtering
),(),( vubHavuH hphfe
Original Butterworth
highpass
filtered image
High freq. emphasis
filtered image After
Hist Eq.
a = 0.5, b = 2
Homomorphic Filtering:
• If the image model is based on illumination-reflectance, then frequency
domain procedures are not as easy to perform.
• The main reason is that illumination and reflectance components of the model
are not separable.
• To be able to improve appearance of an image by simultaneous brightness
range compression and contrast enhancement it is necessary to separate the
two components.
Homomorphic Filtering
An image can be expressed as
),(),(),( yxryxiyxf
i(x,y) = illumination component
r(x,y) = reflectance component
To accomplish separability, first map the model to natural
log domain and then take the Fourier transform of it.
• The illumination component of an image is generally characterized by slow
spatial variation.
• The reflectance component of an image tends to vary abruptly.
• These characteristics lead to associating the low frequencies of the Fourier
transform of the natural log of an image with illumination and high frequencies
with reflectance.
• a good deal of control can be gained over the illumination and reflectance
components with a homomorphic filter.
• For homomorphic filter to be effective it needs to affect the low- and high-
frequency components of the Fourier transform in different way.
• To compress the dynamic range of an image, the low frequency components
ought to be attenuated to some degree.
• On the other hand, to enhance the contrast, the high frequency components of
the Fourier transform ought to be magnified.
Homomorphic Filtering
18-11-2015
13
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Homomorphic Filtering
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Homomorphic Filtering
More details in the room can be seen!
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Correlation Application: Object Detection