practical image processing1 chap7 image transformation image and transformed image spatial...
TRANSCRIPT
Practical Image Processing 1
Chap7 Image Transformation
Image and Transformed imageImage and Transformed imageSpatial ---------------------Spatial --------------------- Transformed Transformeddomain domain Transformation Transformation domain domain h(x,y) Fourier, DCTFourier, DCT F(u,v)
Processing in the transformed domain :Processing in the transformed domain : Filtering, Compression, DescriptionFiltering, Compression, Description
Fourier transform : 1807 FourierFourier transform : 1807 Fourier any periodic signal can be represented as a any periodic signal can be represented as a
weighted sum of sinusoidsweighted sum of sinusoids
Practical Image Processing 2
Practical Image Processing 3
spatial frequency of an image refers to the spatial frequency of an image refers to the rate at which pixel intensities changerate at which pixel intensities change
dxdyeyxhvuH vyuxj )(2),(),(
dudvevuHyxh vyuxj )(2),(),(
anglePhasevuR
vuIvu
SpectrumFouriervuIvuRvuH
vujIvuRvuHLet
exjxej jxjx
:),(
),(tan),(
:),(),(),(
),(),(),(
1,sincos,1
1
22
Practical Image Processing 4
H(u,v); H(u,v); u : spatial frequency along x axisu : spatial frequency along x axis v : spatial frequency along y axisv : spatial frequency along y axis
Practical Image Processing 5
Discrete Fourier Transform (DFT)Discrete Fourier Transform (DFT) let h(x,y) be an M x N imagelet h(x,y) be an M x N image
Inverse Discrete Fourier Transform(IDFT)Inverse Discrete Fourier Transform(IDFT)
1
0
1
0
)(2),(
1),(
M
x
N
y
Nvy
Muxj
eyxhMN
vuH
1
0
1
0
)(2),(),(
M
x
N
y
Nvy
Muxj
evuHyxh
Practical Image Processing 6
Sample code for DFT
input : double h[M][N]
output : COMPLEX H[M][N]
for (u=0; u<M; u++)
for (v=0; v<N; v++) {
sum_re = 0; sum_im = 0;
cu = 2*3.14159*u/M;
cv=2*3.14159*v/N;
for (x=0; x<M; x++)
for (y=0; y<N; y++) {
theta = x*cu + y*cv;
sum_re += h[x][y] * cos(theta);
sum_im -= h[x][y] * sin(theta);
}
H[u][v].re = sum_re;
H[u][v].im = sum_im;
}
struct {
double re; double im;} COMPLEX;
Practical Image Processing 7
DFT expects input to be periodic DFT expects input to be periodic
Practical Image Processing 8
Gibbs phenomenon Gibbs phenomenon ringing effect caused by sampling & ringing effect caused by sampling &
truncationtruncation can reduce width of ringing by increasing can reduce width of ringing by increasing
the number of data samplesthe number of data samples amplitude of ringing is proportional to amplitude of ringing is proportional to
difference between amplitude of first and difference between amplitude of first and last samplelast sample can reduce it by multiplying data by windowing can reduce it by multiplying data by windowing
functionfunction
skipskip
Practical Image Processing 9skip
Practical Image Processing 10
window functions attenuate values at truncation edgeswindow functions attenuate values at truncation edges
Practical Image Processing 11
Fast Fourier transformFast Fourier transform for NxN image, time complexity of DFT isfor NxN image, time complexity of DFT is
O(NO(N44)) fast algorithm : Bell lab 1965fast algorithm : Bell lab 1965 adopt divide and conquer technique for fast adopt divide and conquer technique for fast
computation : O(Ncomputation : O(N22logN)logN)19 hours 19 hours 4.8 sec : table 7.2 4.8 sec : table 7.2
dimension of image must be powers of 2dimension of image must be powers of 2 expand to legal size by zero-paddingexpand to legal size by zero-padding
Practical Image Processing 12
(1) bit-reversal operation : (1) bit-reversal operation : skipskip
Practical Image Processing 13
skipskip exploit periodicity and symmetry of recursive exploit periodicity and symmetry of recursive
DFT computationDFT computation swap data elements for in-place computationswap data elements for in-place computation
butterflies operationbutterflies operation
divide set of data points down and perform divide set of data points down and perform series of 2 points DFTseries of 2 points DFT
Practical Image Processing 14
how to display frequency datahow to display frequency data 1 pixel range : 1 cycle1 pixel range : 1 cycle
small u, v : low frequencysmall u, v : low frequency
logarithmic transform : wide dynamic rangelogarithmic transform : wide dynamic rangeD(u,v) = c log(1+|H(u,v)|)D(u,v) = c log(1+|H(u,v)|)
unordered vs ordered display(centering)unordered vs ordered display(centering)
I
IVIII
II IV
III
III
1
0
1
0
)(2),(
1),(
M
x
N
y
Nvy
Muxj
eyxhMN
vuH
Practical Image Processing 15
Practical Image Processing 16
Magnitude only
+
Phase
Practical Image Processing 17
Practical Image Processing 18
Fourier,
Logarithmic
PartialInverse
Fourier
Practical Image Processing 19
Practical Image Processing 20
Practical Image Processing 21
Filtering in Frequency Domain
convolution in spatial domain == multiplicaticonvolution in spatial domain == multiplication in frequency domainon in frequency domain transform into frequency domain by FFTtransform into frequency domain by FFT
f(x, y) f(x, y) F(u, v). pgm : list 7.1 F(u, v). pgm : list 7.1
multiply by filtering mask in frequency domainmultiply by filtering mask in frequency domain G(u, v) = H(u, v) F(u, v). pgm : list 7.2G(u, v) = H(u, v) F(u, v). pgm : list 7.2 H(u, v) : filterH(u, v) : filter
transform back to spatial domain by IFFTtransform back to spatial domain by IFFT G(u, v) G(u, v) g(x, y) g(x, y)
Practical Image Processing 22
F(u,v)
f(x,y)
H(u,v)
H(u,v)F(u,v)
g(x,y)
Practical Image Processing 23
Ideal Filters filters : low-pass, high-pass, band-pass, band-stopfilters : low-pass, high-pass, band-pass, band-stop ideal filter : pass, not-pass style ideal filter : pass, not-pass style
Practical Image Processing 24
Ideal Low Pass Filter
Practical Image Processing 25
Ideal Low Pass Filter : Example
Input image500x500
H(u,v) with D0 : 5, 15, 30, 80, 230
D0 = 5
D0 = 30
D0 = 230D0 = 80
D0 = 15
Ringing 현상 나타남
Practical Image Processing 26
Practical Low Pass Filter : Butterworth
ideal filters cause blurring & ringing in spatial domainideal filters cause blurring & ringing in spatial domain use Butterworth filter for smooth frequency responseuse Butterworth filter for smooth frequency response Low Pass Filter : (== blurring, smoothing mask)Low Pass Filter : (== blurring, smoothing mask)
nDvuDvuH
20 ]/),([1
1),(
D0 : cutoff frequency
n : order
Practical Image Processing 27
Butterworth Low Pass Filter : Example
Input image500x500
H(u,v) with D0 : 5, 15, 30, 80, 230
D0 = 5
D0 = 30
D0 = 230D0 = 80
D0 = 15
Ringing 현상 안 나타남
Practical Image Processing 28
Practical Image Processing 29
D0=
1/3
D0=
1/2
Ideal
lowpass filters
Practical Image Processing 30
D0=
1/3
D0=
1/2
ideal
Butterworth
Practical Image Processing 31
Ideal High Pass Filter
Practical Image Processing 32
Ideal High Pass Filter : Example
IHPFD0 = 15
IHPFD0 = 30
IHPFD0 = 80
Input Image500 x 500
Practical Image Processing 33
ButterWorth HPFThe Butterworth high pass filter is given as:The Butterworth high pass filter is given as:
where where nn is the order and is the order and DD00 is the cut off is the cut off
distance as beforedistance as before
nvuDDvuH
20 )],(/[1
1),(
Practical Image Processing 34
Butterworth HPF : Example
D0 = 15 D0 = 30 D0 = 80
Practical Image Processing 35
High Pass Filter : sharpeningHigh Pass Filter : sharpening
Band Pass FilterBand Pass Filter pass specific frequency component onlypass specific frequency component only
W : bandwidth, DW : bandwidth, D00 : center freqency : center freqency
.:uv)D(u,
),(1
1),( 22
20
FreqCutoffv
vuD
DvuH
n
),(
),(1
1),(
2
20
2
n
DvuD
WvuDvuH
Practical Image Processing 36
Discrete Cosine Transform(DCT)
produce real frequency coefficientsproduce real frequency coefficients fast : pgm list 7.2, 7.3fast : pgm list 7.2, 7.3 used for image compression : JPEG, MPEGused for image compression : JPEG, MPEG
otherwiseforCHere
N
vy
M
uxvuHvCuC
MNyxh
M
u
N
v
1,02/1)(
2
)12(cos
2
)12(cos),()()(
2),(
1
0
1
0
1
0
1
0 2
)12(cos
2
)12(cos),()()(
2),(
M
u
N
v N
vy
M
uxyxhvCuC
MNvuH