DFT Domain Image
-
Upload
manjunath-achari -
Category
Documents
-
view
224 -
download
0
Transcript of DFT Domain Image
-
7/27/2019 DFT Domain Image
1/65
Lecture 6. DFT Domain ImageFilterin
ELEN E4830 Digital Image Processingpr ng
Zhu Liu David Gibbon
z u researc .att.comAT&T Labs - Research
cg researc .att.comAT&T Labs - Research
Note: Part of the materials in the slides are from Gonzalezs Digital
Image Processingand Prof. Yao Wangs lecture slides
-
7/27/2019 DFT Domain Image
2/65
Lecture Outline
1D/2D discrete Fourier transform (DFT)
u
1D/2D unitary transform
Discrete Cosine transform
Karhunen Loeve transform
Frequency domain filters
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 2
-
7/27/2019 DFT Domain Image
3/65
Discrete Fourier Transform (DFT):
DTFT for Finite Duration Si nals
:becomesansformFourier tr
:1,...,1,0fordefinedonlyissignaltheIf = Nn
)1,0(,)2exp()(1
0
=
=
uunjnf(u)FN
n
u
:(DFT)transformForward
:yieldsrescalingand,110atSampling == ,...,N-,k/N, ku(u)Fu
1,...,1,0,)/2exp()(11
)(1
0
===
=
NkNknjnfN
)N
k(F
NkF
N
n
u
1
:(IDFT)transformInverse
1
N
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 3
,...,,,0=N k
-
7/27/2019 DFT Domain Image
4/65
Property of 1D DFT - Periodicity
.modulore resentswhere
.0),))((()(
Nk
NkorkkFkF N
-
7/27/2019 DFT Domain Image
5/65
Property of 1D DFT - Translation
)}/(2exp{)()))((( oNo NknjkFnnf
).))(((}/2exp{)( 00 NkkFNnkjnf
Special case
N is even, k0 = N/2.
).))2
((()1)((}exp{)( Nn NkFnfnjnf =
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 5
-
7/27/2019 DFT Domain Image
6/65
Property of 1D DFT - Symmetry
Conjugate symmetry for real sequences** ==
|)(||)(|
NN
orkNFkF =
.,22
=
)()/2exp()(1)/)(2exp()(1)(1
*
1* kFNknjnfNnkjnfkFNN
== =
00 nn ==
F(k) F(k)
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 8k k
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 6
N=8 N=9
-
7/27/2019 DFT Domain Image
7/65
Property of 1D DFT - Convolution
Circular convolution1N
=
=0
)()))((()()(k N
khknnhn
f(((n-k))N)
f(n) h(n)
0 1 2 3 4 n 0 1 2 3 4 n nn+1
n+2n+3
n+4 kn-1
0
onvo u on eorem)()()()( kHkFnhnf
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 7
-
7/27/2019 DFT Domain Image
8/65
2D Discrete Fourier Transform
Definition
= - = -, , , , , , , , , ,
is a finite length 2D sequence1 1 1 )(2
=== +M N
N
ln
M
kmj
.1,...,1,0,1,...,1,0,),(1),(
,...,,,,...,,,,,
1 1 )(2
0 0
===
+
= =
NnMmelkFnmf
MN
M N
N
ln
M
kmj
m n
Comparing to DTFT
0 0= =
lknvmuj
+ )(2
NMm n= = ,,,,
+=2/1 2/1
)(2 dudvevunm nvmuj
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 8
2/1 2/1
-
7/27/2019 DFT Domain Image
9/65
Property of 2D DFT Periodicity
.0,0),))((,))(((),( NlorlMkorklkFlkF NM
-
7/27/2019 DFT Domain Image
10/65
-
7/27/2019 DFT Domain Image
11/65
-
7/27/2019 DFT Domain Image
12/65
Property of 2D DFT - Convolution
Circular Convolution 1 1M N
= =
=0 0 ),()))((,))(((),(),( k l NM lkhlnkmfnmhnmf
Convolution Theorem
,,,,
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 12
-
7/27/2019 DFT Domain Image
13/65
Property of 2D DFT - Separability
Separability 2D DFT can be accom lished b N- oint 1D DFT of each row,
followed by M-point 1D DFT of each column
+
==1 21 21 1 )(2 111 M
M
kmjN
N
lnjM N
N
ln
M
kmj
eenmenmlkF
Separable Images
= == = 0 00 0 m nm n NN
)()(),()()(),( lFkFlkFnfmfnmf yxyx ==
If h(m,n)=hx(m)hy(n), then 2D CC can be accomplished by N-point 1D CC of each row, followed by M point 1D CC of each
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 13
.
-
7/27/2019 DFT Domain Image
14/65
Computer Implementation of 2D DFT
+
=1 1 )(2
),(1
),(M N
N
ln
M
kmj
enmflkF
Complex array structure
= =m n
Pre-compute the constants- , , , , -
e-j2ln/N for all l,n=0, 1, , N-1.
For real square image, only need to calculate
~
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 14
-
7/27/2019 DFT Domain Image
15/65
Display of the Magnitude of 2D DFT
Shifting the low frequency components into the
center
).))2
((,))2
(((),()1)(,(),( )( NMnm NlMkFlkGnmfnmg == +
A B D Cl l
C D B A
F(k,l) G(k,l)
Low High
k k
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 15
-
7/27/2019 DFT Domain Image
16/65
Display of the Magnitude of 2D DFT
Amplitude rescaling )),(1log(),( lkFlkG +=
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 16
-
7/27/2019 DFT Domain Image
17/65
Fast Fourier Transform (FFT)
Direct computation of N-point DFT takes N2
o erations 1 1N
,...,,exp
0
===
njn
N n
,
reducing the computation from N2 to N log2(N)
Complex conjugate symmetry of Nknje /2
( )*/2/)(2/2/)(2 NknjNnkjNknjNnNkj eeee ===
eNnNkjNNnkjNknj eee /)(2/)(2/2 ++ ==
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 17
- ,
-
7/27/2019 DFT Domain Image
18/65
Computation of 2D DFT
2D (MxN) point DFT can be computed in a
se arable manner:
First compute N-point FFT for each rowM N log2 (N) Then computeM-point FFT for each columnN M log2 (M)
Total computationM N (log2 (N)+ log2 (M))
IfM=N: 2N2
log2 (N)
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 18
-
7/27/2019 DFT Domain Image
19/65
Calculate Linear Convolution Using DFT
1D DFT
1, 2
g(n) = f(n)*h(h) is length N = N1+N2-1.
o use , nee o ex en n an n o
length N by zero padding.
f(n) h(n) g(n)*Convolution
F(k) H(k) G(k)x
DFT DFT DFT
Multiplication
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 19
-
7/27/2019 DFT Domain Image
20/65
Calculate Linear Convolution Using DFT
f(n), N1=5 fe(n), N=8Fe(k)
n n k
h(n), N2=4 he(n), N=8He(k)
n n k
* e eee
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 20
kn
-
7/27/2019 DFT Domain Image
21/65
Comparison of Complexity
f(n) is length N1, h(n) is length N2 , g(n) is length
N=N +N -1 12N
=
==0
)()))((()()()(k
N khknnhnng
Each point, N2 multiplications
Overall, N * N O N2
Via FFT
N-point FFT for f(n) and h(n)
N multiplications in the DFT domain
N-point inverse FFT for F(k)*H(k)
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 21
Overall, 3NlogN + N O(NlogN)
-
7/27/2019 DFT Domain Image
22/65
One Dimensional Unitary Transform
Let CN represent the N dimensional complex
s ace.
Let h0, h1, , hN-1 represent N linearlyinde endent vectors in CN.
For any vectorf CN,1N
)0(
,0
===
t
k
k
AffB == 1
.)1(
],,...,,[ 110
==
twhere N
MthhhB
fand t form a transform pair
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 22
)1( t
-
7/27/2019 DFT Domain Image
23/65
Inner Product
Definition of inner product1N
==>==< ff
=>=====>=
-
7/27/2019 DFT Domain Image
25/65
Definition of Unitary Transform
Forward transformN 1
*
h
>========< FH
( ) )1(4
1221213221
4
1
1210
1310
0221
,1111
1111
4
1,
*
3,23,2 jjjjjjjjjjjj
T =+++++=
>==< FH
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 40
-
7/27/2019 DFT Domain Image
41/65
Property of Separable Transform
When the transform is separable, we can
.
First, do 1D transform for each row using
l,
Second, do 1D transform for each column of
.
Proof: =
1 1* ),(),(),(
M N
nmFnmlkT
= =
=
=1
*1 1
**
0 0
,
),()(),()()(MM N
l
m n
lmUmhnmFngmhkk
Spring 2010ELEN E4830 Digital Image Processing
Lecture 6, Page 41
== = 00 0 mm n
Computational Savings of
-
7/27/2019 DFT Domain Image
42/65
Computational Savings of
Separable Transform
A MxN transform takes about MxN
and the total number of calculation isM2N2 (N4 if M=N)
If the transform is separable
1. Calculate M N- oint 1D transform, eachrequiring N2 calculations
2. Calculate N M-point 1D transform, each
requ r ng ca cu a ons3. Overall: MN2+NM2 (2N2, if M=N)
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 42
-
7/27/2019 DFT Domain Image
43/65
Other Transforms
Discrete cosine transform (DCT)
Hadamard transform
Haar transform
Etc.
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 43
-
7/27/2019 DFT Domain Image
44/65
Discrete Cosine Transform (DCT)
The basis vectors for 1D N-point DCT 1
=
=
=
+
= .1,...,12
0
)(,2
)12(
cos)()(Nk
N
N
kwithN
kn
knhk
DCT
11 NN
==
==
11
00
)2
cos()()()()()(
NN
nn
kN
nfknfnhkt
== == 00 )2cos()()()()()( kkk Nktkktnhnf
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 44
-
7/27/2019 DFT Domain Image
45/65
Hadamard Transform
Hm is a 2mx2m matrix, and it can be defined
recursivel
=
11
21 mm
mH
HHH
10=
H
=11
11
2
11H
1111
1111
1
=
111111112
2
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 45
Constructing Signal Dependant
-
7/27/2019 DFT Domain Image
46/65
Constructing Signal Dependant
Transform Bases Applications
Feature selection
es gn ng cr er a
Signal de-correlation capability(Uncorrelated
componen s can e processe ana yze more e c en y
Energy compaction capability (Use the least numberof coefficients to re resent the ori inal si nal accuratel
=
=
===
1
11
0
,)(,)(
N
N
Kk
kKK
K
k
kK hktffeiserrorionapproximatthehktf
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 46=
== )(:Kk
KK kteenergyError
K h L T f (KLT)
-
7/27/2019 DFT Domain Image
47/65
Karhunen Loeve Transform (KLT)
For a signal with covariance matrix Cf -
KLT achieves the minimal approximation error
ons ruc on o
Let k
and k
the k-th eigenvalue and
norma ze e genvec or o f, en
.,, ,lklkkkkf with >=
-
7/27/2019 DFT Domain Image
48/65
Proof of KLT Properties
Diagonalize Cf.
0
H
[ ]
== 110
1
Nf
H
f
H
t LM C
CC
00
1
00
H
H
N
L
L
=
=
1
111100
100 N
NN
H
N
L
MOMML
M
Minimize approximation error Selecting the K coefficients associated with the K
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 48
.
Filt i i th F D i
-
7/27/2019 DFT Domain Image
49/65
Filtering in the Frequency Domain
Relation between spatial and frequency domain operation:
),(),(),(),(),(),( vuFvuHvuGyxfyxhyxg ==
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 49
.,,,,,
L P Filt U i DFT Wi d
-
7/27/2019 DFT Domain Image
50/65
Low-Pass Filter Using DFT Window
Filtering in DFT domain:
=, , ,
Ideal Low-Pass Filter H k l = 1 in low fre uenc ran e the four corners!
= 0 in high frequency range
Can think of H(k,l) as a mask in the DFT domain The (k,l)th coefficient is unchanged if H(k,l)=1, and is set to
zero if H(k,l)=0.
, ,
in low-frequency range, and lower values in highfre uenc ran e
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 50
L P Filt i DFT D i
-
7/27/2019 DFT Domain Image
51/65
Low-Pass Filter in DFT Domain
The window size where
=
,
(2 W1+1)x(2 W2+1)
Before shifting
R1=zeros(M,1);
R1(1:W1+1,M-W1+1:M)=1;
R2=zeros N,1 ; R2(1:W2+1,N-W2+1:N)=1;
H=R1*R2;
Given G(k,l)=F(k,l)H(k,l), matlab may make small numerical errors inthe inverse transform leading to complex valued images. g(m,n) isbest reconstructed via:
g=real(ifft2(F.*H));
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 51
Example
-
7/27/2019 DFT Domain Image
52/65
Example
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 52
Example
-
7/27/2019 DFT Domain Image
53/65
Example
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 53
Spatial Filter Corresponding
-
7/27/2019 DFT Domain Image
54/65
to Ideal LPF
10
30
40
50
10
10 20 30 40 50 60
60
20
30
40
50 IDFT
10 20 30 40 50 60
60
Ideal LPF with
W1=W2=10
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 54
High Pass Filtering
-
7/27/2019 DFT Domain Image
55/65
High Pass Filtering
The high-pass filtered image can be
low pass filtered image. -
If w(k,l) is a low-pass DFT window, simply define a
hi h- ass window h k l b h k l = 1 w k l . High-pass filtering in spatial domain:
If L is a low-pass filter of size W, simply define a
high pass filter H via H(m,n) = (m,n) - L(m,n).
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 55
High Pass Filtering in DFT Domain
-
7/27/2019 DFT Domain Image
56/65
High Pass Filtering in DFT Domain
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 56
Before shifting
Introduction to Wavelets
-
7/27/2019 DFT Domain Image
57/65
Introduction to Wavelets
Fourier Transform analyzes the entire signalf t y
Frequenc
Short Time Fourier Transform (STFT) analyzest
Time
f(t) y
window
Freque
n
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 57
tTime
Wavelets Analysis
-
7/27/2019 DFT Domain Image
58/65
Wavelets Analysis
Wavelets are obtained from the mother wavelet
t b dilations and shiftin
a is the scaling parameter b is the shifting parameter
)(
1
)(, a
bt
atba
=
Haar wavelet
t
0
-
1
10.5
1D Continuous wavelet transform (CWT)
y
= dxxxfbaF baW )()(),( ,*
Freque
n
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 58
Time
Two Band Subband Decomposition
-
7/27/2019 DFT Domain Image
59/65
Two Band Subband Decomposition
H0: Lowpass filter, y0: approximation of x11
==
Haar Transform
Spring 2010 ELEN E4830 Digital Image Processing Lecture 11, Page 59
,22
10
Wavelet Transform = Subband Tree
-
7/27/2019 DFT Domain Image
60/65
Wavelet Transform Subband Tree
N N/2
N/4
N/2J
N/2J
The above structure can be applied to rows of an image first, and then columns,
Spring 2010 ELEN E4830 Digital Image Processing Lecture 11, Page 60
forming 2D wavelet decomposition
2D Wavelet Transform for Images
-
7/27/2019 DFT Domain Image
61/65
2D Wavelet Transform for Images
2D wavelet transform is accomplished by applying the 1D decomposition along rows
of an image first, and then columns.
H0 2
H0 2
H1 2In ut
RowsLL
LH
H1 2H0 2
H1 2
Image
(NxN) HL
HH
Spring 2010 ELEN E4830 Digital Image Processing Lecture 11, Page 61
Wavelet Decomposition
-
7/27/2019 DFT Domain Image
62/65
Wavelet Decomposition
LH: low pass for horizontal direction, high pass in vertical directionHL: low pass for vertical direction, high pass in horizontal direction
HH: high pass in both horizontal and vertical directions
LL
LH
HL
HH
Spring 2010 ELEN E4830 Digital Image Processing Lecture 11, Page 62
Reading
-
7/27/2019 DFT Domain Image
63/65
Reading
R. Gonzalez, Digital Image Processing,
. . . . .
A. Jain, Fundamentals of Digital Image, .
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 63
Homework (1)
-
7/27/2019 DFT Domain Image
64/65
( )
1. Find the NxN point DFT of the following 2D image f(m, n), 0 m, n N:
a) f(m, n) = 1, n = 0; f(m, n) = 0; n 0. b) f(m, n) = 1, m = 0; f(m, n) = 0, m 0.
c) f(m, n) = 1, m = n; f(m, n) = 0, otherwise. d) f(m, n) = 1, m = N 1- n; f(m, n) = 0,
otherwise.
From the result, what can you say about the relation between the directionality of an
mage w a o s
2. One can use the DFT algorithms to compute the linear convolution of an image F(m,
n) with a filter H(m, n). Let the convolved image be denoted by Y(m, n).
i) Suppose the image size is 256x256 and the filter size is 11x11: What is the
required size of the DFT to obtain the convolution of these two? Explain the exact
steps to obtain the convolution result.
, , ,
obtain Z(m, n) as follows: Z = IDFT (DFT(X)DFT(H)). The DFT and IDFT in the aboveequation are both 256x256 points. For what values of (m, n) does Z(m, n) equal Y(m,
n) ?
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 64
Homework (2)
-
7/27/2019 DFT Domain Image
65/65
( )
3. Perform DFT (using the fft2 function in Matlab) on several test images of your choice(sample images are available at the Matlab image toolbox directory. Display themagnitude of the DFT image with and without shifting (using shift) and logarithmicmapping, to see the effect of shifting and logarithmic mapping. Include the printouts inyour submission. Also, examine in which frequency range the DCT coefficients havelarge magnitudes and explain why. Note that you may want to work on a small portion
of your image (say 256x256 or less), to save computation time.Note that if your image is an RGB image, you should convert it to a grayscale image
" "only. If the original image is an index image, you should not apply DFT to the indeximage directly, rather you should derive the grayscale image from it, using the"ind2gray" function.
4. Write a program (in Matlab or C) which filters an image by zeroing out certain DFT.
1) performing DFT (you can use the fft2" function in Matlab);
2) zeroing out the coefficients at certain frequencies (see below);
3) performing inverse DFT to get back a filtered image. Truncate or scale the imagero erl such that its ran e is between 0 and 255.
For part 2, try the following two types of filters: (a) let F(k, l) = 0 for TN < k, l < (1 - T)N, T = 1/4, 1/8 (i.e., low-pass filtering); (b) let F (k, l) = 0 for 0 k, l TN and (1 - T)N k, l N -1, T=1/4, 1/8 (i.e., high pass filtering);
Compare the original and processed images. Comment on the function of the two
Spring 2010 ELEN E4830 Digital Image Processing Lecture 6, Page 65
.