Lecture 7
Lecture 7
We We We
learnt the equivalence between convolution and linear ltering. reviewed two dimensional Fourier transforms of 2-d sequences.
discussed various properties of Fourier transforms and in particular we saw that the Fourier transform converts convolution to multiplication. the Fourier transform properties of Kronecker and Dirac delta functions we learnt about sampling and aliasing.
Using
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
A(m, n)ej(mw1+nw2)
w1 , w 2 <
(1)
(2)
A(m, n): two dimensional discrete sequence, m, n vary over integers FA(w1, w2): two dimensional 2 periodic function, w1, w2 vary in a continuum.
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
C=AB C(m, n) =
+ +
k= k=
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
sampled sequence:
C(m, n) = A(S1m, S2n) (4)
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
2-D Fourier transform has many useful properties for the analysis of 2-D sequences and convolution. this Fourier transform can be computed explicitly for only some simple sequences.
The
Unfortunately
Fourier transform variables w1, w2 vary in a continuum. Thus the Fourier transform FA(w1, w2) of a sequence A(m, n) cannot be directly computed by a digital computer.
We and
will now dene another Fourier transform which is computable enjoys similar nice properties.
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
= 0, 0 m M1 1, 0 n N1 1 = 0 otherwise
The [M1, N1] point 2-D Discrete Fourier Transform (DFT) of A is dened as:
DFA(k, l) = A(m, n)
M1 1 N1 1 m=0 n=0
A(m, n)e
j( 2k m+ 2l n) M N
1 1
, k = 0, . . . , M1 1, l = 0, . . . , N1 1 (7)
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
A(m, n)e
j( 2k m+ 2l n) M N
1 1
, k = 0, . . . , M1 1, l = 0, . . . , N1 1 w1 , w 2 <
A(m, n)ej(mw1+nw2)
Example
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
Note that the Fourier transform and its inverse are dened for any sequence whereas the DFT is only dened for nite extent sequences. Using the inverse DFT and noting that
1 j e M1 2M
=1
2M 2N 1 M11 N11 j( 2m k+ 2n l) j M 1 j N 1 M1 N1 DFA(k, l)e A(m, n) = e 1 e 1 M1N1 k=0 l=0 2[n+N ] 2[m+M ] 1 M11 N11 j( M 1 k+ N 1 l) 1 1 = DFA(k, l)e M1N1 k=0 l=0 = A(m + M1, n + N1) !
(10)
i.e., if we forget that A is nite extent, then the inverse DFT will reconstruct a periodic sequence which is called the periodic extension of A.
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
9
periodic extension property is normally not a problem since we can always do an inverse DFT for 0 m < M1, 0 n < N1. however the DFT and its inverse for C = A B.
We already know that if A and B are nite extent (A (M1 N1), B (M2 N2)) then C is nite extent (M1 + M2 1 N1 + N2 1). DFC (k, l)
Consider
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
10
(If A and B are matrices, the [M1 + M2 1, N1 + N2 1] point DFT of A can be computed by extending or padding A with zeros and similarly for B). Will
suppress the DFX (k, l)[M1+M21,N1+N21] notation with the understanding that the various DFTs are computed to the required point. caused by not computing the DFTs to the required point are due to time aliasing.
Artifacts
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
11
DFT can be computed by a fast algorithm known as the FFT (Fast Fourier Transform). In matlab:
>> DF A = t2(A, M 1, N 1);
and
where it2 denotes the inverse t algorithm and M 1 = M1, N 1 = N1, etc.
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
12
The [M1, N1] DFT of an M1 N1 image will have the low frequencies around k = 0, k = N1 1 and l = 0, l = M1 1 (see also earlier plot). When This
we plot image DFTs as images it is convenient to have the low frequencies at the center of the plot. shift for viewing convenience can be done via the tshift command in matlab.
13
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
tshift
nience.
Note that DF A2 = DF A and thus it2(DF A2, M 1, N 1) = it2(DF A, M 1, N 1). DF A
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
14
Example
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
15
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
16
be M1 N1. Let
R1 = {i|(0 i W1) or (M1 W1 i M1 1)} R2 = {i|(0 i W2) or (N1 W2 i N1 1)}.
1 k R1 and l R2 0 otherwise
(12)
This keeps (2W1 + 1) (2W2 + 1) DFT coecients and zeros out the rest. error given by
We are interested in the mean squared M1 1 1/(M1N1) m=0 N11(A(m, n) C(m, n))2. n=0 Note
that as W1, W2 increase we are adding more and more high coefcients to the set of coecients that we keep.
17
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
Given DFC (k, l) = DFA(k, l)w(k, l), matlab may make small numerical errors in the inverse transform leading to complex valued images. C(m, n) is best reconstructed via:
>> C = real( it2(w. DF A));
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
18
Example
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
19
Example
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
20
Convolution by DFTs
Since
the DFT can be computed with a fast algorithm it may be benecial to do the convolution of two sequences A (M1 N1) and B (M2 N2) via [M1 + M2 + 1, N1 + N2 + 1] point DFTs. speed improvements are only possible if both sequences have large dimensions. Otherwise convolutions are better implemented via the convolution sum.
However,
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
21
Summary
In
this lecture we learnt the 2-D DFT of two dimensional nite extent sequences. learnt how to calculate convolutions using DFTs. learnt about basic properties of the DFTs of natural images.
We We
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
22
Homework VII
1. Calculate the DFT of your image. Show the magnitude and phase both before and after using tshift. Use the log10 point function on magnitude plots and normalize as necessary. 2. Subsample your image by 2 in each direction and calculate the DFT of the result in two ways: (a) Since the subsampled image has half the dimensions of the original, calculate the DFT to the point of the reduced dimensions. (b) Calculate the DFT to the point of the original dimensions. Show magnitude and phase plots for both. Compare the results to 1. above. Can you explain the dierences? 3. Calculate the convolution of your image with itself by using DFTs. 4. Do the processing I did on Pages 19-20. Show the resulting images and the mse plot.
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
23
References [1] A. K. Jain, Fundamentals of Digital Image Processing. Englewood Clis, NJ: Prentice Hall, 1989.
c Onur G. Guleryuz, Department of Electrical and Computer Engineering, Polytechnic University, Brooklyn, NY
24