Fourier Transform
Fourier Transform
Lexing Xie
real(g(x)) imag(g(x))
1D – DFT of length N
=0
=7
x x
1-D DFT in as basis expansion
Forward transform
real(A) imag(A)
u=0
Inverse transform
basis
u=7
n n
1-D DFT in matrix notations
real(A) imag(A)
u=0
N=8
u=7
n n
1-D DFT of different lengths
real(A) imag(A)
n
u
N=32
N=8
N=16 N=64
performing 1D DFT
real-valued input
Note: the coefficients in x and y on this slide are only meant for illustration purposes, which are not numerically accurate.
another illustration of 1D-DFT
real-valued input
?
Computing 2D-DFT
DFT
IDFT
real imag
real( ) imag( )
2-D FT illustrated
real-valued
real
imag
notes about 2D-DFT
Output of the Fourier transform is a complex number
Decompose the complex number as the magnitude and phase
components
In Matlab: u = real(z), v = imag(z), r = abs(z), and
theta = angle(z)
Explaining 2D-DFT
fft2
ifft2
circular convolution and zero padding
zero padded filter and response
zero padded filter and response
observation 1: compacting energy
observation 2: amplitude vs. phase
A = “Aron” P = “Phyllis”
FA = fft2(A) FP = fft2(P)
log(abs(FA)) log(abs(FP))
angle(FA) angle(FP)
1-D DFT
of f(m,n)
w.r.t n
1-D DFT
of F(m,v)
w.r.t m
1D FFT: O(N¢log2N)
2D DFT naïve implementation: O(N4)
2D DFT as 1D FFT for each row and then for
each column
Implement IDFT as DFT
DFT2
IDFT2
Properties of 2D-DFT
duality result
outline
why transform
2D Fourier transform
a picture book for DFT and 2D-DFT
properties
implementation
applications
discrete cosine transform (DCT)
definition & visualization
implementation
DFT application #1: fast Convolution
? ?
O(N2)
Spatial filtering
f(x.y)*h(x.y)
?
DFT application #1: fast convolution
Spatial filtering
f(x.y)*h(x.y)
O(N4)
DFT application #2: feature correlation
Find letter “a” in the following image
bw = imread('text.png'); a = imread(‘letter_a.png');
% Convolution is equivalent to correlation if you rotate the
convolution kernel by 180deg
C = real(ifft2(fft2(bw) .*fft2(rot90(a,2),256,256)));
text enhancement
smoothing filter application 2
beautify a photo
high-pass filters
sobel operator in frequency domain
Question:
Sobel vs. other high-pass
filters?
Spatial vs frequency
domain implementation?
high-pass filter examples
outline
why transform
2D Fourier transform
a picture book for DFT and 2D-DFT
properties
implementation
applications in enhancement, correlation
discrete cosine transform (DCT)
definition & visualization
implementation
Is DFT a Good (enough) Transform?
Theory
Implementation
Application
The Desirables for Image Transforms
Theory DFT ???
Inverse transform available X
Energy conservation (Parsevell) X
Good for compacting energy ?
Orthonormal, complete basis
(sort of) shift- and rotation invariant
X
Implementation X
Real-valued x
Separable X
Fast to compute w. butterfly-like structure X
Same implementation for forward and
inverse transform X
Application
Useful for image enhancement X
Capture perceptually meaningful structures X
in images
DFT vs. DCT
1D-DCT 1D-DFT
a real(a) imag(a)
u=0 u=0
u=7 u=7
n=7
1-D Discrete Cosine Transform (DCT)
N 1
( 2n 1) k
Z ( k )
n 0
z ( n ) ( k ) cos
2N
z ( n)
N 1
( 2n 1) k
k 0
Z ( k ) ( k ) cos
2N
1 2
(0) , (k )
N N
Transform matrix A
a(k,n) = (0) for k=0
0.0 0.0 0 0
n 0.0 0.0 0 0
0.0 0.0 0 0
k 0.0 0.0 0 0
1D-DCT 1D-DFT
u=0
u=7
n=7
Shift low-freq
to the center
Coming in Lecture 6:
Unitary transforms, KL transform, DCT
examples and optimality for DCT and KLT, other transform flavors,
Wavelets, Applications
Readings: G&W chapter 4, chapter 5 of Jain has been posted on
Courseworks