Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 102

EECE\CS 253 Image Processing

Lecture Notes: The 1&2-Dimensional


Lecture Notes Fourier Transforms

Richard Alan Peters II

Department of Electrical Engineering and


Computer Science

Fall Semester 2007

This work is licensed under the Creative Commons Attribution-Noncommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or
send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
Signal:
A measurable phenomenon that changes over time
or throughout space.
sound image

code

01101000101101110110010110001

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 2
II
2
Signals: Space-Time vs. Frequency-Domain
Representation

Space/time representation: a graph of the


measurements with respect to a point in time and/or
positions in space.
Fact: signals undulate (otherwise they’d contain
no information).
Frequency-domain representation: an exact
description of a signal in terms of its undulations.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 3
II
2
Origin of Sounds
 The mechanical vibrations of an object in an atmosphere.
 Vibrations: internal elastic motions of the material.

The surface of the object undulates causing
compressions and rarefactions in the air which propagate
through the air away from the surface.
 An object vibrates with different modes.

A mode is a vibratory pattern with a distinctive shape —
part of the object surface moves out while another part
moves in — a standing wave.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 4
II
2
Vibratory Modes / Standing Waves: Examples

displacement from rest position internal pressure

string modes pipe modes

Note that Note that


the modes the negatives
are all of these also
sinusoids.
Saturday, April 23, 202
2022
1999-2007 by Richard Alan Peters will occur 5
II
2
Sound Waves: Emerge from the superposition of the modes.

string sound

pipe sound
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 6
II
2
Sound Waves: Emerge from the superposition of the modes.

string sound

pipe sound
The vibratory modes
add up to one complex
Even-order Odd-order
motion that pushes
harmonics harmonics
the air around the
vibrating object

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 7
II
2
Fact: Any Real Signal has Odd-order harmonics

a Frequency-Domain sq t  


1  2
sin  2n  1 t 
Representation n   2n  1  

The modes shown (blue)


sum to the rippling
square wave (black).

As the number of modes


in the sum becomes large,
it approaches a square
wave (red).

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 8
II
2
Frequency-Domain Representation
Any periodic signal can be described by a sum of sinusoids.

1 2
sin  2n  1 t 

sq t   
n   2n  1  

The sinusoids are called


“basis functions”.

The multipliers are called


“Fourier coefficients”.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 9
II
2
Frequency-Domain Representation
Any periodic signal can be described by a sum of sinusoids.

1 2
sin  2n  1 t 

sq t   
n   2n  1  

The sinusoids are called


“basis functions”.

The multipliers are called Basis


“Fourier coefficients”. functions

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 10
II
2
Frequency-Domain Representation
Any periodic signal can be described by a sum of sinusoids.

1 2
sin  2n  1 t 

sq t   
n   2n  1  

The sinusoids are called


“basis functions”.

The multipliers are called The Fourier


“Fourier coefficients”. coefficients
(of a square
1999-2007wave).
by Richard Alan Peters
Saturday, April 23, 2022
202 11
II
2
Example: Partial Sums of a Square Wave

The limit of the


given sequence
of partial sums1
is exactly a
square wave
1 sine 2 sines 4 sines

1
the limit as n
approaches
infinity of the
sum of n sines.
8 sines 16 sines 32 sines

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 12
II
2
Anatomy of a Sinusoid
f (t)

2 1 / is the frequency of the sinusoid (Hz).


f t   A sin  t   

  2 / is the angular frequency (radians/s ).

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 13
II
2
The Inner Product: a Measure of Similarity
The similarity between functions f and g on the interval -λ / 2 , λ / 2
can be defined by
 /2
f,g   f t  g * t  dt
 /2

where g * t  is the complex conjugate of g t .


This number, called the inner product of f and g , can also be
thought of as the amount of g in f or as the projection of f onto g.
If f and g have the same energy, then their inner product is
maximal if f  g. On the other hand if f , g  0, then f and g
have nothing in common.
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 14
II
2
Inner Products

a function, f pointwise product f(t)g(t)

1024

g is a component of f  f t  g t dt  0.12


0

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 15
II
2
Inner Products

a function, f pointwise product f(t)h(t)

1024

h is a not a comp. of f  f t ht dt  0


0

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 16
II
2
Inner Product of a Periodic Function and a Sinusoid
 /2  /2
f,g   f t  sin  t dt
2

f,g   f t  cos  t dt
2

 /2  /2

 /2

 f t  cos t   i sin  t dt


2 2
3 different
f,g    representations
 /2
 /2 2 2
 t   i sin  t 
i t
f t  e
i t
  
dt 2 2
e 
 cos  
 /2
 /2
  f t  e i t dt 

 /2
λ

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 17
II
2
Inner Product of a Periodic Function and a Sinusoid
 /2  /2
f,g   f t  sin  t dt
2

f,g   f t  cos  t dt
2

 /2  /2
real number results
 /2 yield the amplitude
f , g  f t of    
costhat  
2 sinusoid2in

t  i sin  t dt
 / 2
the function.
 /2 2
i t
  f t e
 /2

dt

 /2
  f t  e i t dt
 /2

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 18
II
2
Inner Product of a Periodic Function and a Sinusoid
 /2  /2
f,g   f t  sin  t dt
2

f,g   f t  cos  t dt
2

 /2  /2

 /2
f,g     t  i sin  t dt
f t  cos 2

2

 /2
 /2 2
i t Complex number result
  f t  e 
dt yields the amplitude and
 /2
phase of that sinusoid in
 /2
the function.
  f t  e i t dt
 /2

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 19
II
2
is the decomposition of a -periodic
The Fourier Series signal into a sum of sinusoids.


 2 n   2 n  The representation of a
f t   A0   An cos  t   Bn sin  t function by its Fourier
n 1       Series is the sum of sinu-
soidal “basis functions”
periodic :    such that f (t  n )  f (t ). multiplied by coefficients.

 /2
Fourier coefficients are
2    2 n  dt for n  0
An  f t  cos  t   n 
generated by taking the
 
 
    inner product of the
 / 2 function with the basis.
/2
2    2 n 
t  n  dt for n  0
The basis functions
Bn   f t  sin  correspond to modes
     
 / 2 of vibration.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 20
II
2
can also be written in terms
The Fourier Series of complex exponentials

 2 n  2 n
i  t n 
i  1
i t
f t    Cn e    Cn e   
n   n  

 2 n   2 n
  Cn cos  t  n   i  Cn sin  t  n  Cn  Cn e  i n
n        

1
 /2
i
2 n
t e i x  cos x  i sin x
Cn  Cn e i n 
  / 2 
f t  e  dt

/2 f ( t  n )  f ( t )
1    2 n   2 n 
  f t  cos  t   n   i  sin  t  n  dt for all intergers n
        
 / 2

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 21
II
2
The Fourier Series Cont’d. on next page.

Relationship between the real and the complex Fourier Series



2 n
f t    An cos n t  Bn sin n t , where n 
n 0 
2    /2  /2
   f   cos n d cos n t   f   sin  n d sin n t 
 n 0    / 2  / 2

2   /2
   f  cos n cos n t  sin n sin  n t d
 n 0  / 2
 The sine-plus-cosine
1 /2
   f  cos n   n t  d form results from the
 n     / 2 projection of f onto a
cosine that is in phase
with the current time.
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 22
II
2
Relationship between the real and the Cont’d. on next page.

complex Fourier Series (cont’d.)



0   sin  n   n t  .
Claim:
n  
 /2
 Then add

 f    sin  n   n t  d  0. zero to the
Therefore:
 n  
 / 2 equation at
the end of
1 
Thus: /2
-i 
 n  
 f  sin n   n t  d  0
 / 2
the previous
page:

1  /2 1   /2
f t     f  cos n   n t d  i   f  sin n   n t  d .
 n   / 2  n    / 2

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 23
II
2
Relationship between the real and the
complex Fourier Series (cont’d.)
1   /2 1  /2
f t     f  cos n   n t  d  i   f  sin n   n t  d
 n     / 2  n    / 2
1   /2
   f  cos n   t   i sin n   n t d
 n     / 2
1   /2
   f   e i n  t  d Then some algebraic
 n     / 2 manipulations lead to

1  /2 2 n 2 n the result.
   i  i t
  f  e  d  e 
n     / 2
 2 n  2 n   2 n
i t i t i  t n 
 C e
n  
n
  C
n  
n e i n e   C
n  
n e   

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 24
II
2
Relationship between the real and the
complex Fourier Series (cont’d.)
1   /2 1  /2
f t     f  cos n   n t  d  i   f  sin n   n t  d
 n     / 2  n    / 2
1   /2
   f  cos n   t   i sin n   n t d
 n     / 2
1   /2
   f   e i n  t  d Then some algebraic
 n     / 2 manipulations lead to

1  /2 2 n 2 n the result.
   i  i t
  f  e  d  e 
n     / 2
 2 n  2 n   2 n
i t i t i  t n 
 C e
n  
n
  C
n  
n e i n e   C
n  
n e   

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 25
II
2
Why are Fourier Coefficients Complex Numbers?
 2 n
i t
f (t )  C n e  where Cn  Cn e i n .
n  

Cn represents the
amplitude, A=|Cn|,
and relative phase, f ,
of that part of the
original signal, f (t), 0

that is a sinusoid of
frequency wn = n / l.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 26
II
2
What about real + imaginary?

 F     NA2 cos    N       N  


 i  NA2 sin     N       N  

The FS of a cosine is a pair of


impulses with complex amplitudes

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 27
II
2
The real and imaginary Real + Imaginary to
parts at the positive Magnitude & Phase
frequency, N/l ...

… form a magnitude, NA/2, and a phase, f0.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 28
II
2
The real and imaginary Real + Imaginary to
parts at the negative Magnitude & Phase
frequency, -N/l ...

… form a magnitude, NA/2, and a phase, -f0.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 29
II
2
Fourier Series of a Square Wave

Time-domain
signal

Fourier
magnitude

Fourier
phase

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 30
II
2
The Fourier Transform
is the decomposition of a nonperiodic
signal into a continuous sum* of sinusoids.

F    F   e i     f t  e i 2  t dt


  f t cos 2  t   i sin 2  t dt


 
f t    F   e  i 2  t d   F   e i 2  t     d
 

  F   cos 2  t   i sin 2  t  d


  F   cos 2  t      i sin 2  t     d


1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202
II
*
i.e., an integral. 31
2
Mammals Use the FT in Hearing

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 32
II
2
The Discrete Fourier Transform DFT
A discrete signal,  hk k  0,1, 2,  , N  1 , of finite length N can be repre -

sented as a weighted sum of N sinusoids, e i 2 k n /N n  0,1, 2,  , N  1 
through
N 1
hk   H n e i 2 k n /N
n 0

where the set, H n n  0,1, 2,  , N  1, are the Fourier coefficien ts


defined as the projection of the original signal onto sinusoid, n, given by :

1 N 1
Hn   hk e i 2 k n /N
N k0
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 33
II
2
The Two-Dimensional Fourier Transform

Primary Uses of the FT in Image Processing:



Explains why down-sampling can add distortion to an
image and shows how to avoid it.
 Useful for certain types of noise reduction, deblurring,
and other types of image restoration.

For feature detection and enhancement, especially
edge detection.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 34
II
2
The Fourier Transform: Discussion
The expressions
continuous signals
 defined over all
F     f t  e
 i 2  t
dt  f t , e  i 2  t real numbers


and
N 1
1 discrete signals
Hn 
N
he
n 0
k
 i 2 k n / N
 hk , e  i 2 k n / N
with N terms or
samples.

for the Fourier coefficients are “inner products” which can be


thought of as measures of the similarity between the functions
f t  and e  i 2  t for t   ,   or between the sequences
 hk  N 1
k 0
and e   i 2 k n / N

N 1
.
k 0

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 35
II
2
The Fourier Transform:
Discussion (cont’d.)

In the context of inner products, the complex exponentials


e i 2  t
 and   ,   and  e i 2 k n /N
 ,  2, 1, 0,1, 2, 
are called “orthogonal sets” since they have the property:



 , if  1  2
e  i 2  1 t
, e  i 2  2 t
  e  i 2  1 t  e  i 2  2 t dt  The function
0 , if  1  2

sets are called
“orthogonal
e  i 2 j n / N
, e  i 2 k n / N
N 1
  e i 2 j n /N e i 2 k n /N 
n 0
 c , if j  k
0 , if j  k , basis sets”

They are called “basis sets” since for any function1, f (t), of a real variable
there exists a complex-valued function F(w), and for any sequence1, hk , there
exist complex numbers, Hn , such that

f t    
N 1


 i 2  t
F  e d hk   H n e i 2 k n /N .
 n 0
1
with finite energy.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 36
II
2
The Fourier Transform:
Discussion (cont’d.)
Consider the 2-dimensional functions

e i 2 ( ux  vy )
u, v , x , y    and e  jm
i 2 ( M  knN )

j , m  0,..., M  1, k , n  0,..., N  1

These are, likewise, orthogonal:


 

e  i 2 u1x  v1 y  , e  i 2 u2 x v2 y     e  i 2 u1 x  v1 y 


 e  i 2 u2 x  v2 y 
dxdy
  

   , if u1  u2 and v1  v2
0 , otherwise ,

e
 j m k n
 i 2  1  1 
 M N 
, e
 j m k n
 i 2  2  2 
 M N 
M 1 N 1

  e
 i 2  j1 m k1 n
M

N
 e 
 i 2
j2 m k 2 n
M

N

m 0 n 0

  c , if j1  j2 and k1  k 2
0, otherwise .

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 37
II
2
The Fourier Transform:
Discussion (cont’d.)
Therefore

e i 2 ( ux  vy )
u, v, x, y   and e
   i 2
jm kn

M N
 j, k , m, n, M  integers 
are orthogonal basis sets. This suggests that function f (x,y) defined on the
real plane, and sequence {{ hmn }} for integers m and n have analogous
Fourier representations,
   jm kn 
M  1N  1  i 2   
f x, y     F u , v  e  i 2 ( ux  vy )
dudv and hmn    H jk e M N 

   j0 k 0

where the Fourier coefficients are given by


   jm kn 
M 1 N 1  i 2  
F u , v     f x , y  e
 i 2 ( ux  vy ) 
dxdy and H jk    hmn e M N 
   m 0 n 0

(True for finite energy functions f (x,y) and {{ hmn }}.)

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 38
II
2
Continuous Fourier Transform

 
I r, c     I v, u  e
 i 2 ( vr  uc )
dudv
  

 

I v, u     Ir, c e
i 2 ( vr  uc )
dcdr
  

The continuous Fourier


transform assumes a
continuous image exists
in a finite region of an
infinite plane.

The BoingBoing Bloggers

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 39
II
2
Discrete Fourier Transform

The discrete Fourier


transform assumes a
digital image exists on a
closed surface, a torus.

 vr uc 
R  1C  1  i 2   
I( r,c )    I v,u e  R C
v 0 u 0

 rv cu 
R 1C 1  i 2   
I v, u     Ir,c e  R C 
r 0 c 0

The BoingBoing Bloggers

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 40
II
2
Discrete Fourier Transform

The discrete Fourier


transform assumes a
digital image exists on a
closed surface, a torus.

 vr uc 
R  1C  1  i 2   
I( r,c )    I v,u e  R C
v 0 u 0

 rv cu 
R 1C 1  i 2   
I v, u     Ir,c e  R C 
r 0 c 0

The BoingBoing Bloggers

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 41
II
2
The 2D Fourier Transform of a Digital Image

Let I(r,c) be a single-band (intensity) digital image with R


rows and C columns. Then, I(r,c) has Fourier representation
 vr uc 
R 1C 1  i 2   
I r , c     I v,u e R C 
,
u 0 v 0 these complex
exponentials are
where
2D sinusoids.
 vr uc 
R 1 C 1  i 2   
I v,u  RC1   I ( r,c) e R C 
r 0 c 0

are the R x C Fourier coefficients.


1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 42
II
2
What are 2D sinusoids?
To simplify the situation assume R = C = N. Then
2 2
 i 2  vr
 uCc  i vr  uc  i r sinθ  c sinθ 
e R
e N
e N
,
where
v   sin θ, u   cos θ,   v 2  u 2 , and θ  tan 1 uv .
Write
Note: since images are indexed
N by row & col with r  down and c
λ ,
 to the right, θ, is positive in
the counterclockwise direction.
Then by Euler’s relation,

 cos 2 r sin θ  c cos θ  i sin 2 r sin θ  c cos θ.
 i 2 1 r sin θ  c cos θ 
e
Cont’d. on next page.
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 43
II
2
What are 2D sinusoids? (cont’d.)
Both the real part of this,

Re e   i 2 1 r sin θ  c cos θ 
  cos  2
 r sin θ  c cos θ
and the imaginary part,

Im e  i 2 1 r sinθ  c cos θ 
  sin  2
 r sin θ  c cos θ
are sinusoidal “gratings” of unit amplitude, period  and direction .
2 
Then is the radian frequency, and the frequency, of the wavefront
N N
N
and λ  is the wavelength in pixels in the wavefront direction.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 44
II
2
A   2  
2D Sinusoids: I r, c   cos
2   
r  sin θ  c  cos θ      1

... are plane waves with


grayscale amplitudes,
periods in terms of lengths, ...
q
orientation

f = phase shift

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 45
II
2
... specific orientations,
2D Sinusoids: and phase shifts.

on
e ntati
ori

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 46
II
2
The Fourier Transform of an Image

c v v

u u

r
I Re[F{I}] Im[F{I}]

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 47
II
2
Points on the Fourier Plane

The point at column


freq. u and row freq. v
represents a sinusoid
with wavelength w and
orientation q (if R=C=N).

w = N/l, where l is the


wavelength and R=C=N.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 48
II
2
Points on the Fourier Plane (of a Digital Image) More about
this later
In the Fourier transform of an R×C digital (pp. 66-86).
-v direction
image the wavelengths, u and  v represent a
fraction of the R and C values. That is,
C R
λu  u
and λ v  v
pixels.
The wavefront direction is given by of a digital image
θ wf  tan 1  ,
vC
uR

and the wavelength is

-θ direction
λ wf      .
C 2 R 2

u direction
u v

The frequencies represent fractions of R & C,


(0,0)
ωu  u
C
, ω v  , and
v
R

ω wf  1   
C 2
u

R 2
v
cycles.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 49
II
2
Points on the Fourier Plane
y

This point represents this particular sinusoidal grating

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 50
II
2
The Value of a Fourier Coefficient …
… is a complex
number with a
real part and an
imaginary part.

If you represent
that number as a
magnitude, A, and
a phase, f, …

..these represent the amplitude


and offset of the sinusoid with
frequency w and direction q.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 51
II
2
The Value of a Fourier Coefficient
The magnitude and phase
representation makes
more sense physically…

…since the Fourier magni-


tude, A (w,q), at point (w,q)
represents the amplitude
of the sinusoid…

and the phase, f(w,q),


represents the offset of the
sinusoid relative to origin.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 52
II
2
The Fourier Coefficient at (u,v)
So, the point (u,v) on the
Fourier plane…

…represents a sinusoidal
grating of frequency 
and orientation .

The complex value, F(u,v),


of the FT at point (u,v)…

…represents the ampli-


tude, A, and the phase
offset, f, of the sinusoid.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 53
II
2
The Sinusoid from the Fourier Coeff. at (u,v)

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 54
II
2
FT of an Image (Magnitude + Phase)

I log{|F{I}|2+1} Ð[F{I}]

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 55
II
2
FT of an Image (Real + Imaginary)

I Re[F{I}] Im[F{I}]

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 56
II
2
The Power Spectrum For display,
the log of
the power
The power spectrum of a signal is the square of spectrum is
the magnitude of its Fourier Transform. often used.

I u, v   I u, v I * u, v 


2

 Re I u, v   i Im I u, v Re I u, v   i Im I u, v 


 Re I u, v   Im I u, v  .
2 2

At each location (u,v) it indicates the squared intensity of the


frequency component with period   1 / u 2  v 2 and orientation
  tan 1 v / u . For display in Matlab:
PS = fftshift(2*log(abs(fft2(I))+1));

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 57
II
2
On the Computation of the Power Spectrum
The power spectrum (PS) is defined by PS I   FIu, v  .
2

We take the base-e logarithm of the PS in order to view it. Otherwise its dynamic range could be
too large to see everything at once. We add 1 to it first so that the minimum value of the result is
0 rather than –infinity, which it would be if there were any zeros in the PS. Recall that
log( f 2) = 2log( f ).
Multiplying by 2 is not necessary if you are generating a PS for viewing, since you'll probably
have to scale it into the range 0-255 anyway. It is much easier to see the structures in a Fourier
plane if the origin is in the center. Therefore we usually perform an fftshift on the PS before it is
displayed.
>> PS = fftshift(log(abs(fft2(I))+1));
>> M = max(PS(:));
>> image(uint8(255*(PS/M)));
If the PS is being calculated for later computational use -- for example the autocorrelation of a
function is the inverse FT of the PS of the function -- it should be calculated by
>> PS = abs(fft2(I)).^2;

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 58
II
2
The Uncertainty Relation
space frequency If  x  y is the extent of
the object in space and
FT
if  u  v is its extent in
frequency then,
1
 x  y  u  v 
space frequency 16 2

FT A small object in space


has a large frequency
extent and vice-versa.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 59
II
2
The Uncertainty Relation
frequency space
Recall: a symmetric

 large extent 
 small extent 

pair of impulses in the


IFT frequency domain
becomes a sinusoid in
the spatial domain.
 small extent   large extent 

frequency space
A symmetric pair of

 small extent 
 large extent 

lines in the frequency


IFT domain becomes a
sinusoidal line in the
spatial domain.
 small extent   large extent 

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 60
II
2
The Fourier Transform of an Edge

edge Power Spectrum Phase Spectrum

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 61
II
2
The Fourier Transform of a Bar

bar Power Spectrum Phase Spectrum

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 62
II
2
Coordinate Origin of the Center =

FFT (floor(R/2)+1, floor(C/2)+1)

Even Odd Even Odd

Image Origin Image Origin Weight Matrix Origin Weight Matrix Origin

After FFT shift After FFT shift After IFFT shift After IFFT shift

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 63
II
2
Matlab’s fftshift and ifftshift
I = ifftshift(J): J = fftshift(I):

origin origin

from FFT2
after fftshift
or ifftshift

J ( R/2 +1, C/2 +1)  I (1,1) I (1,1)  J ( R/2 +1, C/2 +1)

where x = floor(x) = the largest integer smaller than x.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 64
II
2
Matlab’s fftshift and ifftshift

J = fftshift(I):
5 6 4

8 9 7 1 2 3

4 5 6
I (1,1)  J ( R/2 +1, C/2 +1) 7 8 9

2 3 1

I = ifftshift(J):
5 6 4

1 2 3 8 9 7

4 5 6
J ( R/2 +1, C/2 +1)  I (1,1) 7 8 9

2 3 1

where x = floor(x) = the largest integer smaller than x.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 65
II
2
Coordinates and Directions in the Fourier Plane

po
sit decreasing rows

pe
iv
lo
es
(-r,-c) es (-r,+c) (-r,-c) lo (-r,+c)
tiv
pe
ga
ne

q<0 q>0

q<0 increasing cols q>0


decreasing cols
(+r,-c) (+r,+c) (+r,-c) (+r,+c)
increasing rows

Since rows increase down and columns to the right, slopes and
angles are opposite those of a right-handed coordinate system.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 66
II
2
Points on the Fourier Plane (of a Digital Image)
In the Fourier transform of an R×C digital
-v direction
image the wavelengths, u and  v represent a
fraction of the R and C values. That is,
C R
λu  u
and λ v  v
pixels.
The wavefront direction is given by of a digital image

θ wf  tan 1  ,
vC
uR

and the wavelength is

-θ direction
λ wf      .
C 2
u
R 2
v

u direction
The frequencies represent fractions of R & C,
(0,0)
ωu  u
C
, ω v  , and
v
R

ω wf  1   
C 2
u

R 2
v
cycles.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 67
II
2
Inverse FFTs of Impulses
“horizontal” is the
wavefront direction.

fftshifted

highest-possible-frequency horizontal sinusoid (C is even)


1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 68
II
2
Inverse FFTs of Impulses
“vertical” is the
wavefront direction.

fftshifted

highest-possible-frequency vertical sinusoid (R is even)


1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 69
II
2
Inverse FFTs of Impulses
a checker-board
pattern.

fftshifted

highest-possible-freq horizontal+vertical sinusoid (R & C even)


1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 70
II
2
Inverse FFTs of Impulses
“horizontal” is the
wavefront direction.

fftshifted

lowest-possible-frequency horizontal sinusoid


1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 71
II
2
Inverse FFTs of Impulses
“vertical” is the
wavefront direction.

fftshifted

lowest-possible-frequency vertical sinusoid


1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 72
II
2
Inverse FFTs of Impulses
“negative diagonal” is
the wavefront direction.

fftshifted

lowest-possible-frequency negative diagonal sinusoid


1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 73
II
2
Inverse FFTs of Impulses
“positive diagonal” is
the wavefront direction.

fftshifted

lowest-possible-frequency positive diagonal sinusoid


1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 74
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

+u direction

384 rows
+v direction

Note this … … and this.

frequencies: (u,v) = (4,3); wavelengths: (λu, λv) = (128,128)


How can that be?
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 75
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

384 rows
λu = C / u

u = # of complete cycles
in the horizontal direction

frequencies: (u,v) = (1,0); wavelength: λu= 512

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 76
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

v = # of complete
cycles in the λv = R / v

384 rows
vertical direction

frequencies: (u,v) = (0,1); wavelength: λv= 384

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 77
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

384 rows
λu = C / u

u = # of complete cycles
in the horizontal direction

frequencies: (u,v) = (2,0); wavelength: λu= 256

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 78
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

v = # of complete
cycles in the λv = R / v

384 rows
vertical direction

frequencies: (u,v) = (0,2); wavelength: λv= 192

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 79
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

384 rows
λu = C / u

u = # of complete cycles
in the horizontal direction

frequencies: (u,v) = (3,0); wavelength: λu= 170 ⅔

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 80
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

v = # of complete
cycles in the λv = R / v

384 rows
vertical direction

frequencies: (u,v) = (0,3); wavelength: λv= 128

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 81
II
2
In the Fourier plane of a In the F plane the angle is -45˚
square image, the orientation in this image it’s about -53˚
of the line through the point (yellow line). That’s because
pair = the orientation of the the fraction of R covered by
wave front in the image. Not one pixel is 4/3 the fraction of
Frequencies and Wavelengths in the Fourier Plane
so for a non-square image. C covered by one pixel.

512 columns

 

384 rows
 

Also as a result, the


wavelength is 213⅓.

frequencies: (u,v) = (3,3); wavelengths: (λu, λv) = (170 ⅔,128)

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 82
II
2
In general the slope of the
wavefront direction in the
image is given by (v/R) / (u/C).
Therefore its angle is
Frequencies and
θ  tan 
vC  Wavelengths in the Fourier Plane
,
1
wf
 uR 
512 columns

lwf
 wf

384 rows
 wf

and the wavelength is:


2 2
frequencies: (u,v) = (3,3); wavelengths: (λ  C   R⅔,128)

λ wfu, λv) =(170
  ,
 u  v

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 83
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

384 rows
frequencies: (u,v) = (3,3); wavelengths: (λu, λv) = (170 ⅔,128)

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 84
II
2
Frequencies and Wavelengths in the Fourier Plane

512 columns

384 rows
frequencies: (u,v) = (4,3); wavelengths: (λu, λv) = (128,128)

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 85
II
2
The ratio R/C = ¾ in this image. Therefore at
frequency (4,3) the wave front angle is
1  3  512  1  3  4 
Frequencies and Wavelengths   tan in
1  the Fourier Plane
1
θ wf  tan    tan  45 ,
 4  384   4  3

512 columns

lwf
wf

384 rows
wf

and the wavelength is


frequencies: (u,v) = (4,3); wavelengths:
512
2 (λ 2, λ ) = (128,128)
384 u v    2
λ wf       2  128  128 2 ,
 4   3 
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 86
II
2
Power Spectrum of an Image

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 87
II
2
Relationship between Image and FT
phase power spectrum

power spectrum phase

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 88
II
2
Features in the FT and in the
Image

Lines in
the Power
Spectrum
are …

… perpen-
dicular to
lines in the
image.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 89
II
2
Fourier Magnitude and Phase

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 90
II
2
Fourier Magnitude

log FI 

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 91
II
2
Fourier Phase

 FI 

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 92
II
2
Q: Which contains more visually relevant
information; magnitude or phase?

original image Fourier log Fourier phase


magnitude
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 93
II
2
Magnitude Only Reconstruction

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 94
II
2
Phase Only Reconstruction

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 95
II
2
The figure below shows four sinusoidal brightness images of spatial frequency 1, 3, 5, and 7. The first one,
of frequency 1, is the fundamental, and the others are higher harmonics on that fundamental, because they
are integer multiples of the fundamental frequency. These are in fact the "odd harmonics" on the
fundamental, and each one exhibits a bright vertical band through the center of the image. The Fourier
transform for each of these patterns is shown below.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 96
II
2
The next table shows the result of progressively adding higher harmonics to the fundamental.
Note how the central vertical band gets sharper and stronger with each additional higher
harmonic, while the background drops down towards a uniform dark field. Note also how the
higher harmonics produce peaks in the Fourier images that spread outward from the fundamental,
defining a periodic pattern in frequency space.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 97
II
2
The images below show what would happen if this process were continued all the way out to the Nyquist
frequency - it would produce a thin vertical stripe in the brightness image, with sharp boundaries, i.e. a
"square wave" in brightness along the x dimension. The Fourier transform of this image exhibits an "infinite"
series of harmonics or higher order terms, although these do not actually go out to infinity due to the finite
resolution of the original image. This is how the Fourier transform encodes sharp square-wave type features
as the sum of a series of smooth sinusoids.

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 98
II
2
Combine Signals

The combined brightness image shown above could have been produced by a pixel-for-pixel
adding of the two brightness images, or by a pixel-for-pixel addition of the corresponding Fourier
transforms, followed by an inverse transform to go back to the brightness domain. Either way the
result would be exactly identical. (Super Position – Linearity ?!)
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 99
II
2
Fourier Says:
any well-behaved function can be represented by a superposition of sinusoidal waves".
In other words by adding together a sufficient number of sine waves of just the right frequency
and amplitude

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 100
II
2
Butterworth Filter Orders (Ref: Wikipedia)

1999-2007 by Richard Alan Peters


Saturday, April 23, 2022
202 101
II
2
1999-2007 by Richard Alan Peters
Saturday, April 23, 2022
202 102
II
2

You might also like