Fourier Transform, in 1D and in 2D
Fourier Transform, in 1D and in 2D
Václav Hlaváč
Examples in 2D.
Initial idea, filtering in frequency domain
2/56
Image processing ≡ filtration of 2D signals.
input spatial output
image filter image
Filtration in the spatial domain. We would say in time domain for 1D signals. It
is a linear combination of the input image with coefficients of (often local)
filter. The basic operation is called convolution.
Filtration in the frequency domain. Conversion to the ‘frequency domain’,
filtration there, and the conversion back.
We consider Fourier transform, but there are other linear integral transforms
serving a similar purpose, e.g., cosine, wavelets.
1D Fourier transform, introduction
3/56
a signal.
FT is suitable for periodic signals. Joseph Fourier
1768-1830
If the signal is not periodic then the Windowed FT
f(t)
Even f (t) = f (−t) t
f(t)
t
Odd f (t) = −f (−t)
Conjugage ∗ f ( 5) = 2 + 3i
f (ξ) = f (−ξ)
symmetric f (−5) = 2 − 3i
i is a complex unit.
Any function can be decomposed
as a sum of the even and odd part 5/56
t = t + t
Fourier Tx definition: continuous cased
6/56
F{f (t)} = F (ξ), where ξ [Hz=s−1] is a frequency and2πξ [s−1] is the angular
frequency.
What is the meaning of the inverse Fourier Tx? Express it as a Riemann sum:
. 2πiξ0t 2πiξ1t
f (t) = . . . + F (ξ0) e + F (ξ1) e + . . . ∆ξ ,
R∞
1. | f (t) | dt < ∞, i.e. f (t) has to grow slower than an exponential curve.
−∞
2. f (t) can have only a finite number of discontinuities and maxima, minima in
any finite rectangle.
3. f (t) need not have discontinuities with the infinite amplitude.
Fourier transformation exists always for digital images as they are limited and
have finite number of discontinuities.
Fourier Tx, symmetries
8/56
F (−iξ) = F ∗(iξ).
|F (iξ)| is always even.
function h(t), which is shifted and overlayed with the function f (t) or
vice-versa.
Consider first the continuous case with general infinite limits
Z ∞ Z ∞
(f ∗ h)(t) = (h ∗ f )(t) ≡ f (τ ) h(t − τ ) dτ = f (t − τ ) h(τ ) dτ .
−∞ −∞
The limits can be constraint to the interval [0, t], because we assume zero
X X
(f ∗ h)(i) = (h ∗ f )(i) ≡ h(i − m) f (m) = h(i) f (i − m) ,
m∈O m∈O
1
Time scaling f (a t) |a| F (ξ/a)
Fourier Tx, properties (2)
12/56
R∞
Area in time F (0) = f (t)dt Area function f (t).
−∞
R∞
Area in freq. f (0) = F (jξ)dξ Area under F (jξ)
−∞
R∞ R∞
Parseval’s th. |f (t)|2dt = |F (jξ)|2dξ f energy = F energy
−∞ −∞
Basic Fourier Tx pairs (1)
13/56
d(t) 1 f(t)
f(t)
0 t 0 t -2T -T 0 T 2T t
Re F(x) d(x)
F(x)
1
0 x 1 1 1 x
x 0 0 1
-2T -T T 2T
f(t)
t t t
F(x) -x0
-x0 0 x0 x 0 x0 x -2x0 -x0 0 x0 2x0 x
F(x)
0 x 0 x0 x 0 x
The signal of short duration must have wide Fourier spectrum and vice versa.
1
(signal duration) (frequency bandwith) ≥
−t2
Observation: Gaussian e has the smallest duration-bandwidth product.
Fourier transform.
Dennis Gabor, 1900-1979, inventor of holography, Nobel price for physics in 1971,
studied in Budapest, PhD in Berlin in 1927, fled Nazi persecution to Britain in 1933.
Mere cutting of the signal to rectangular windows is not good because discontinuities
Gaussian or Hamming function ensuring the zero signal value at the limits of the
window and beyond it.
2. Use of more complex basis function, e.g., wavelets in the wavelet transform.
Discrete Fourier transform
18/56
N −1
X −2πikn
F (k) ≡ f (n) e N
k=0
N −1
1 X 2πikn
f (n) ≡ F (k) e N
N
k=0
Computational complexity,
a reminder of a notation 19/56
(constant, independent of the length n), but is better than O(n3) (cubic).
If the complexity is exponential, e.g., O(2n), then it often means that the
algorithm cannot be applied to larger problems (in practical terms).
Computational complexity of
the discrete Fourier transform 20/56
−2πi
Let W be a complex number, W ≡ e N .
N −1 N −1
X −2πikn X
F (k) ≡ f (n) e N = W nk f (n)
n=0 n=0
The vector f (n) is multiplied by the matrix whose element (n, k) is the
expressed as sum of two DFTs of length N/2, the first one consisting of odd
and the second of even samples. Note: FFT exists also for a general
length N .
FFT, the proof
22/56
N −1
X −2πikn
F (k) = e N f (n)
n=0
(N/2)−1 (N/2)−1
X −2πik(2n) X −2πik(2n+1)
= e N f (2n) + e N f (2n + 1)
n=0 n=0
(N/2)−1 (N/2)−1
X −2πikn X −2πikn
n
= e N/2 f (2n) + W e N/2 f (2n + 1)
n=0 n=0
= F (k) + W n F o(k) ,
e
k = 1, . . . , N
For every pattern of log2 N e’s and o’s, there is a one-point transform that
computations.
FFT butterfly scheme
24/56
f0 f1 f2 f3 f4 f5 f6 f7
Iteration
1
2
3
F0 F1 F2 F3 F4 F5 F6 F7
2D Fourier transform
25/56
Z∞ Z∞
F (u, v) = f (x, y) e−2πi(xu+yv) dx dy
−∞ −∞
Inverse Fourier tranform
26/56
Z∞ Z∞
f (x, y) = F (u, v) e2πi(xu+yv) du dv
−∞ −∞
e2πi(xu+uv).
Thanks to Euler formula (eiz = cos z + i sin z), cos corresponds to the real
Direct transform
M −1 N −1
1 X X h mu nv i
F (u, v) = f (m, n) exp −2πi + ,
M N m=0 n=0 M N
u = 0, 1, . . . , M − 1 , v = 0, 1, . . . , N − 1 ,
Inverse transform
M −1 N −1 mu
X X h nv i
f (m, n) = F (u, v) exp 2πi + ,
u=0 v=0
M N
m = 0, 1, . . . , M − 1 , n = 0, 1, . . . , N − 1 .
2D Fourier Tx as twice 1D Fourier Tx
30/56
u = 0, 1, . . . , M − 1 , v = 0, 1, . . . , N − 1 .
transform of the mth line and can be computed using the standard fast
Fourier transform (FFT).
Each line is substituted with its Fourier transform, and the one-dimensional
p
Amplitude spectrum |F (u, v)| = R2(u, v) + I 2(u, v)
h i
I(u,v)
Phase spectrum φ(u, v) = tan−1 R(u,v)
250
50
100 200
150
200 150
250
300
100
350
400
50
450
500
0
100 200 300 400 500
Real part of the spectrum, image and mesh
34/56
Problem with the image related coordinate system related to the image:
interesting information is in corners, moreover divided into quarters. Due to
spectrum periodicity it can be arbitrarily shifted.
Real part of the spectrum
50
100
150
Spatial frequency v
200
250
300
350
400
450
500
100 200 300 400 500
Spatial frequency u
50
100
150
Spatial frequency v
200
250
300
350
400
450
500
100 200 300 400 500
Spatial frequency u
50
100
150
Spatial frequency v
200
250
300
350
400
450
500
100 200 300 400 500
Spatial frequency u
image mesh
Centered spectra
37/56
shifted spectrum
which converts nencentered ←→ centered
with the origin at (0, 0)
spectra by switching quadrants diagonally.
Real part of the centered spectrum, image and
mesh 38/56
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
image mesh
Prague Castle example, input image 265×256
41/56
200
50
150
100
100
150
200 50
250
0
50 100 150 200 250
Real part of the centered spectrum, image and
mesh 42/56
−100
−50
Spatial frequency v
50
100
−100
−50
Spatial frequency v
50
100
−100
−50
Spatial frequency v
50
100
image mesh
Rice example, input image 265×256
45/56
200
180
50
160
100 140
120
150
100
80
200
60
250
40
50 100 150 200 250
Real part of the centered spectrum, image and
mesh 46/56
−100
−50
Spatial frequency v
50
100
−100
−50
Spatial frequency v
50
100
−100
−50
Spatial frequency v
50
100
image mesh
Horizontal line example, input image 265×256
49/56
Horizontal line example, real part of the spectrum
50/56
Horizontal line example,
imaginary part of the spectrum 51/56
Horizontal line example, power spectrum
52/56
Rectangle example, input image 512×512
53/56
200
50 180
100 160
150 140
200 120
250 100
300 80
350 60
400 40
450 20
500
0
100 200 300 400 500
Real part of the centered spectrum, image and
mesh 54/56
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
image mesh
input spatial output
image filter image
t = t + t
d(t) 1 f(t)
f(t)
0 t 0 t -2T -T 0 T 2T t
Re F(x) d(x)
F(x)
1
0 x 1 1 1 x
x 0 0 1
-2T -T T 2T
f(t)=cos(2px0 t) f(t)=sin(2px0 t) f(t)=cos(2px0 t) + cos(4px0 t)
f(t)
t t t
F(x) -x0
-x0 0 x0 x 0 x0 x -2x0 -x0 0 x0 2x0 x
f(t) f(t)=(sin 2px0t)/pt f(t)=exp(-t2)
1
f(t)
-T 0 T t 0 t 0 t
2 2
Re F(x)=(sin 2pxT)/px Re F(x) Re F(x)= p exp(-p x )
1
F(x)
0 x 0 x0 x 0 x
f0 f1 f2 f3 f4 f5 f6 f7
Iteration
1
2
3
F0 F1 F2 F3 F4 F5 F6 F7
250
50
100 200
150
200 150
250
300
100
350
400
50
450
500
0
100 200 300 400 500
Real part of the spectrum
50
100
150
Spatial frequency v
200
250
300
350
400
450
500
100 200 300 400 500
Spatial frequency u
Imaginary part of the spectrum
50
100
150
Spatial frequency v
200
250
300
350
400
450
500
100 200 300 400 500
Spatial frequency u
log power spectrum
50
100
150
Spatial frequency v
200
250
300
350
400
450
500
100 200 300 400 500
Spatial frequency u
A D
B C
C B
D A
Real part of the spectrum, centered
−250
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
Imaginary part of the spectrum, centered
−250
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
log power spectrum, centered
−250
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
200
50
150
100
100
150
200 50
250
0
50 100 150 200 250
Real part of the spectrum, centered
−100
−50
Spatial frequency v
50
100
−100
−50
Spatial frequency v
50
100
−100
−50
Spatial frequency v
50
100
180
50
160
100 140
120
150
100
80
200
60
250
40
50 100 150 200 250
Real part of the spectrum, centered
−100
−50
Spatial frequency v
50
100
−100
−50
Spatial frequency v
50
100
−100
−50
Spatial frequency v
50
100
50 180
100 160
150 140
200 120
250 100
300 80
350 60
400 40
450 20
500
0
100 200 300 400 500
Real part of the spectrum, centered
−250
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
Imaginary part of the spectrum, centered
−250
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u
log power spectrum, centered
−250
−200
−150
−100
Spatial frequency v
−50
50
100
150
200
250
−200 −100 0 100 200
Spatial frequency u