0% found this document useful (0 votes)
550 views110 pages

Fourier Transform, in 1D and in 2D

The document discusses the Fourier transform in 1D and 2D. It defines the Fourier transform as a transformation from the time domain to the frequency domain. The Fourier transform allows for frequency analysis of signals and is suitable for periodic signals. Key properties of the Fourier transform are discussed, including linearity, time/frequency shifts, and Parseval's theorem relating energy in the time and frequency domains. Basic Fourier transform pairs such as Dirac delta functions, sines, and cosines are presented.

Uploaded by

Maram Shbair
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
550 views110 pages

Fourier Transform, in 1D and in 2D

The document discusses the Fourier transform in 1D and 2D. It defines the Fourier transform as a transformation from the time domain to the frequency domain. The Fourier transform allows for frequency analysis of signals and is suitable for periodic signals. Key properties of the Fourier transform are discussed, including linearity, time/frequency shifts, and Parseval's theorem relating energy in the time and frequency domains. Basic Fourier transform pairs such as Dirac delta functions, sines, and cosines are presented.

Uploaded by

Maram Shbair
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 110

Fourier transform, in 1D and in 2D

Václav Hlaváč

Czech Technical University in Prague


Faculty of Electrical Engineering, Department of Cybernetics
Center for Machine Perception
http://cmp.felk.cvut.cz/˜hlavac, [email protected]

Outline of the talk:


Fourier tx in 1D, computational complexity, FFT.


Fourier tx in 2D, centering of the spectrum.




Examples in 2D.

Initial idea, filtering in frequency domain
2/56
Image processing ≡ filtration of 2D signals.
input spatial output
image filter image

direct frequency inverse


transformation filter transformation

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

Fourier transforme is one of the most commonly




used techniques in (linear) signal processing and


control theory.
It provides one-to-one transform of signals


from/to a time-domain representation f (t)


to/from a frequency domain representation F (ξ).
It allows a frequency content (spectral) analysis of


a signal.
FT is suitable for periodic signals. Joseph Fourier


1768-1830
If the signal is not periodic then the Windowed FT


or the linear integral transformation with time


(spatially in 2D) localized basis function, e.g.,
wavelets, Gabor filters can be used.
Odd, even and complex conjugate functions
4/56

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

f ∗ denotes a complex conjugate function.




i is a complex unit.

Any function can be decomposed
as a sum of the even and odd part 5/56

f (t) = fe(t) + fo(t)

f (t) + f (−t) f (t) − f (−t)


fe(t) = fo(t) =
2 2

f(t) fe(t) fo(t)

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.

Fourier Tx Inverse Fourier Tx


R∞ R∞
F (ξ) = f (t) e−2πiξt dt f (t) = F (ξ) e2πiξt dξ
−∞ −∞

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 + . . . ∆ξ ,

kde ∆ξ = ξk+1 − ξk pro ∀ k .

⇒ Any 1D function can be expressed as a the weighted sum (integral) of many


different complex exponentials (because of Euler’s formula ejξ = cos ξ + j sin ξ,
also of cosinusoids and sinusoids).
Existence conditions of Fourier Tx
7/56

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

Symmetry with regards to the complex conjugate part, i.e.,




F (−iξ) = F ∗(iξ).
|F (iξ)| is always even.


The phase of F (iξ) is always odd.




Re{F (iξ)} is always even.




Im{F (iξ)} is always odd.




The even part of f (t) transforms to the real part of F (iξ).




The odd part of f (t) transforms to the imaginary part of F (iξ).



Convolution, definition, continuous case
9/56
Convolution (in functional analysis) is an operation on two functions f and


h which produces a third function (f ∗ h), often used to create a


modification of one of the input functions.
Convolution is an integral ‘mixing’ values of two functions, i.e., of the


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


values of functions for the negative argument


Z t Z t
(f ∗ h)(t) = (h ∗ f )(t) ≡ f (τ ) h(t − τ ) dτ = f (t − τ ) h(τ ) dτ .
0 0
Convolution, discrete approximation
10/56

X X
(f ∗ h)(i) = (h ∗ f )(i) ≡ h(i − m) f (m) = h(i) f (i − m) ,
m∈O m∈O

where O is a local neighborhood of a ‘current position’ i and h is the convolution


kernel (also convolution mask).
Fourier Tx, properties (1)
11/56

Property f (t) F (ξ)

Linearity af1(t) + bf2(t) a F1(ξ) + b F2(ξ)


Duality F (t) f (−ξ)
Convolution (f ∗ g)(t) F (ξ) G(ξ)
Product f (t) g(t) (F ∗ G)(ξ)
Time shift f (t − t0) e−2πiξt0 F (ξ)
Frequency shift e2πiξ0tf (t) F (ξ − ξ0)
df (t)
Differentiation dt 2πiξF (ξ)
i dF (ξ)
Multiplication by t t f (t) 2π dξ

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

Dirac constant ∞ sequence of Diracs


Basic Fourier Tx pairs (2)
14/56

f(t)=cos(2px0 t) f(t)=sin(2px0 t) f(t)=cos(2px0 t) + cos(4px0 t)

f(t)
t t t

Re F(x) Im F(x) Re F(x)

F(x) -x0
-x0 0 x0 x 0 x0 x -2x0 -x0 0 x0 2x0 x

sine cosine two cosines mixture


Basic Fourier Tx pairs (3)
15/56

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

rectangle in t rectangle in ξ Gaussian


Uncertainty principle
16/56

All Fourier Tx pairs are constrained by the uncertainty principle.




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.


The principle is an instance of the general uncertainty principle introduced




by Werner Heisenberg in quantum mechanics.


Non-periodic signals
17/56

Fourier transform assumes a periodic signal. What if a non-periodic signal has to


be processed? There are two common approaches.
1. To process the signal in small chunks (windows) and assume that the signal
is periodic outside the windows.
The approach was introduced by Dennis Gabor in 1946 and it is named Short time


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


at windows limits cause unwanted high frequencies.


This is the reason why the signal is convolved by a dumping weight function, often


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

Let f (n) be an input signal (a sequence), n = 0, . . . , N − 1.




Let F (k) be a Frequency spectrum (the result of the discrete Fourier




transformation) of a signal f (n).


Discrete Fourier transformation


N −1
X −2πikn
F (k) ≡ f (n) e N

k=0

Inverse discrete Fourier transformation




N −1
1 X 2πikn
f (n) ≡ F (k) e N
N
k=0
Computational complexity,
a reminder of a notation 19/56

While considering complexity, it is abstracted from a specific computer and




only asymptotic behavior of algorithms is concerned.


An asymptotic upper bound for the magnitude of a function (i.e., its


growth) in terms of another, usually simpler, function is sought.


‘Big O’ notation; for example, O(n2) means that the number of algorithm


steps will be roughly proportional to the square of the number of samples in


the worst case.
Additional terms and multiplicative constants are not taken into account


because a qualitative comparison is sought.


The quadratic complexity O(n2) is worse than say O(n) (linear) or O(1)


(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


complex constant W to the power N · k.


This has the computational complexity O(N 2).

Fast Fourier transform
21/56

A fast Fourier transform (FFT) is an efficient algorithm to compute the




discrete Fourier transform and its inverse.


Statement: FFT has the complexity O(N log2 N ).


Example (according to Numerical recepies in C):




• A sequence of N = 106, 1 µsecond computer.


• FFT 30 seconds of CPU time.
• DFT 2 weeks of CPU time, i.e., 1,209,600 seconds, which is about
40.000 × more.
A FFT idea (Danielson, Lanczos, 1942): The DFT of length N can be


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

The key idea: recursiveness and N is power of 2.




Only log2 N iterations needed.



FFT, THE PROOF (2)
23/56

Spectra F e(k) and F o(k) are periodic in k with length N/2.




What is Fourier transform o length 1? It is just identity.




For every pattern of log2 N e’s and o’s, there is a one-point transform that


is just one of input numbers f (n),

F eoeeoeo...oee(k) = f (n) for some n .

The next trick is to utilize partial results =⇒ butterfly scheme of




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

The idea. The image function f (x, y) is decomposed to a linear combination of


harmonic (sines and cosines, more generally orthogonal) functions.

Definition of the direct transform. u, v are spatial frequencies.

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
−∞ −∞

f (x, y) is a linear combination of simple harmonic functions (components)




e2πi(xu+uv).
Thanks to Euler formula (eiz = cos z + i sin z), cos corresponds to the real


part and sin corresponds to the imaginary part.


Function F (u, v) (complex spectrum) gives weights of harmonic


components in the linear combination.


Illustration of 2D FT bases vectors
27/56

Analogy – corrugated iron.

sin(3x + 2y) cos(x + 4y)


Linear combination of base vectors
28/56

sin(3x + 2y)+ cos(x + 4y) different display only


2D discrete Fourier transform
29/56

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

2D direct FT can be modified to


−1
M
" N −1   #  
1 X 1 X −2πinv −2πimu
F (u, v) = exp f (m, n) exp ,
M m=0 N n=0 N M

u = 0, 1, . . . , M − 1 , v = 0, 1, . . . , N − 1 .

The term in square brackets corresponds to the one-dimensional Fourier




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


discrete Fourier transform of each column is computed.


Spatial frequencies spectrum
31/56

The outcome of the Fourier transform F (u, v) is a function of complex variables.

(Complex) spectrum F (u, v) = R(u, v) + i I(u, v)

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)

Power spectrum P (u, v) = |F (u, v)|2 = R2(u, v) + I 2(u, v)


Displaying spectra, 2D Gaussian example
32/56

Gaussian is selected for illustration because it has a smooth spectrum, cf.


uncertainty principle.
Input intensity image, coordinate system
33/56

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

real part, image real part, mesh


Imaginary part of the spectrum, image and mesh
35/56

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

imaginary part, image imaginary part, mesh


Log power of the spectrum, image and mesh
36/56

log power spectrum

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

It is useful to visualize a centered spectrum




with the origin of the coordinate system A D


(0, 0) in the middle of the spectrum.
B C
Assume the original spectrum is divided into


four quadrants. The small gray-filled


original spectrum
squares in the corners represent positions of
low frequencies in corners
low frequencies.
Due to the symmetries of the spectrum the


quadrant positions can be swapped C B


diagonally and the low frequencies locations
appear in the middle of the image. D A
MATLABu provides function fftshift


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

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

real part, image real part, mesh


Imaginary part of the centered spectrum
image and mesh 39/56

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

imaginary part, image imaginary part, mesh


Log power of the centered spectrum
image and mesh 40/56

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

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

Real part of the spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u

real part, image real part, mesh


Imaginary part of the centered spectrum
image and mesh 43/56

Imaginary part of the spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u

imaginary part, image imaginary part, mesh


Log power of the centered spectrum
image and mesh 44/56

log power spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u

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

Real part of the spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u

real part, image real part, mesh


Imaginary part of the centered spectrum
image and mesh 47/56

Imaginary part of the spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u

imaginary part, image imaginary part, mesh


Log power of the centered spectrum
image and mesh 48/56

log power spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u

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

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

real part, image real part, mesh


Imaginary part of the centered spectrum
image and mesh 55/56

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

imaginary part, image imaginary part, mesh


Log power of the centered spectrum
image and mesh 56/56

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

image mesh
input spatial output
image filter image

direct frequency inverse


transformation filter transformation
f(t)
t
f(t)
t
f(t) fe(t) fo(t)

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

Re F(x) Im F(x) Re F(x)

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 0 50 100


Spatial frequency u
Imaginary part of the spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u
log power spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u
200

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 0 50 100


Spatial frequency u
Imaginary part of the spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u
log power spectrum, centered

−100

−50
Spatial frequency v

50

100

−100 −50 0 50 100


Spatial frequency u
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 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

You might also like