You are on page 1of 96

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 2012

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.
image

sound

code

01101000101101110110010110001
2013-03-08

1999-2013 by Richard Alan Peters II

Signals: Space-Time vs. FrequencyDomain 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 theyd contain
no information).
Frequency-domain representation: an exact
description of a signal in terms of its undulations.

2013-03-08

1999-2013 by Richard Alan Peters II

Origin of Sounds

2013-03-08

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-2013 by Richard Alan Peters II

Vibratory Modes / Standing Waves: Examples

displacement from rest position

internal pressure

string modes

pipe modes

2013-03-08

Note that
the modes
are all
sinusoids.

1999-2013 by Richard Alan Peters II

Note that
the negatives
of these also
will occur

Sound Waves:

Emerge from the superposition of the modes.

1999-2013 by Richard Alan Peters II

pipe sound

string sound

2013-03-08

Sound Waves:

The vibratory modes


add up to one complex
motion that pushes
the air around the
vibrating object

1999-2013 by Richard Alan Peters II

Odd-order
harmonics

pipe sound

2013-03-08

string sound

Even-order
harmonics

Emerge from the superposition of the modes.

Fact: Any Real Signal has


a Frequency-Domain
Representation

Odd-order harmonics
sq (t ) =

2p

1
sin
2
n
1
t
+
(
)

+
2
n
1
l

n=-

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).
2013-03-08

1999-2013 by Richard Alan Peters II

Frequency-Domain Representation
Any periodic signal can be described by a sum of sinusoids.
sq (t ) =

2p

1
n
t
sin
2
1
+
(
)

n=- 2n + 1

The sinusoids are called


basis functions.
The multipliers are called
Fourier coefficients.
2013-03-08

1999-2013 by Richard Alan Peters II

Frequency-Domain Representation
Any periodic signal can be described by a sum of sinusoids.
sq (t ) =

2p

1
n
t
sin
2
1
+
(
)

n=- 2n + 1

The sinusoids are called


basis functions.
The multipliers are called
Fourier coefficients.
2013-03-08

Basis
functions

1999-2013 by Richard Alan Peters II

10

Frequency-Domain Representation
Any periodic signal can be described by a sum of sinusoids.
sq (t ) =

2p

1
n
t
sin
2
1
+
(
)

n=- 2n + 1

The sinusoids are called


basis functions.
The multipliers are called
Fourier coefficients.
2013-03-08

The Fourier
coefficients
(of a square
wave).

1999-2013 by Richard Alan Peters II

11

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

the limit as n
approaches
infinity of the
sum of n sines.
1

8 sines
2013-03-08

16 sines
1999-2013 by Richard Alan Peters II

32 sines

12

Anatomy of a Sinusoid
f (t)

2p

f (t ) = A sin t - f
l

2013-03-08

1999-2013 by Richard Alan Peters II

13

The Inner Product: a Measure of Similarity


The similarity between functions f and g on the interval (- / 2, / 2)
can be defined by
l /2

f,g =

f (t ) g * (t ) dt

-l /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.
2013-03-08

1999-2013 by Richard Alan Peters II

14

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

2013-03-08

1999-2013 by Richard Alan Peters II

15

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

2013-03-08

1999-2013 by Richard Alan Peters II

16

Inner Product of a Periodic Function and a Sinusoid

3 different
representations

2013-03-08

1999-2013 by Richard Alan Peters II

17

Inner Product of a Periodic Function and a Sinusoid

real number results


yield the amplitude
of that sinusoid in
the function.

2013-03-08

1999-2013 by Richard Alan Peters II

18

Inner Product of a Periodic Function and a Sinusoid

Complex number result


yields the amplitude and
phase of that sinusoid in
the function.

2013-03-08

1999-2013 by Richard Alan Peters II

19

The Fourier Series

f (t ) = A0 +

n=1

is the decomposition of a -periodic


signal into a sum of sinusoids.

2p n
2p n

An cos
t + Bn sin
t
l
l

periodic : $l such that f (t nl ) = f (t )

2
An =
l
2
Bn =
l
2013-03-08

l /2

-l /2
l /2

-l /2

The representation of a
function by its Fourier
Series is the sum of sinusoidal basis functions
multiplied by coefficients.

2p n

f (t ) cos
t - jn dt for n 0

Fourier coefficients are


generated by taking the
inner product of the
function with the basis.

2p n

f (t ) sin
t - jn dt for n 0

The basis functions


correspond to modes
of vibration.

1999-2013 by Richard Alan Peters II

20

can also be written in terms


of complex exponentials

The Fourier Series


f (t ) =

Ce
n

n=-

i 2lpn t

Cn e

2 pn

+
+fn
l

n=-

2pn

2pn

+
+
+
cos
f
sin
f
C
t
C
t

n
n
n
n
l
l

n=-

Cn = Cn e

+ ifn

l /2
2 pn
-i
t
1
l
dt
= f (t ) e
l -l /2

l /2

2p n

2p n

1
= f (t ) cos
t + fn + Cn sin
t + fn dt

l
l -l /2

2013-03-08

i = -1

1999-2013 by Richard Alan Peters II

Cn = Cn e+ifn
eix = cos x + i sin x
f (t + nl ) = f (t )
for all integers n

21

The Fourier Series

Contd. on next page.

Relationship between the real and the complex Fourier Series

f (t ) = [ An cos wnt + Bn sin wnt ], where wn =


n=0

2pn
l

l /2
l /2

2
= f (h ) cos wn h d h cos wnt + f (h ) sin wn h d h sin wn t
l n=0 -l /2
-l /2

l /2

2
= f (h )[cos wn h cos wnt + f (h ) sin wn h sin wnt ] d h
l n=0 -l /2
l /2
The sine-plus-cosine
1
= f (h ) cos (wn h - wnt ) d h
form results from the
l n=0 -l /2
projection of f onto a
cosine that is in phase
with the current time.
2013-03-08

1999-2013 by Richard Alan Peters II

22

Relationship between the real and the


complex Fourier Series (contd.)
Claim:

0=

sin (w h - w t ).
n

n=-
l /2

Therefore:

-l /2

Thus:

Contd. on next page.

f (h ) sin (wn h - wnt ) d h = 0.

n=-

l /2

1
-i f (h ) sin (wn h - wn t ) d h = 0.
l n=- -l /2

Then add
zero to the
equation at
the end of
the previous
page:

l /2
l /2

1
1

f (t ) = f (h ) cos (wn h - wnt ) d h - i f (h ) sin (wn h - wnt ) d h .


l n=- -l /2
l n=- -l /2

2013-03-08

1999-2013 by Richard Alan Peters II

23

Relationship between the real and the


complex Fourier Series (contd.)
l /2
l /2

1
1

f (t ) = f (h ) cos (wn h - wnt ) d h - i f (h ) sin (wn h - wnt ) d h


l n=- -l /2
l n=- -l /2

l /2

1
= f (h )[cos wn (h - t ) - i sin wn (h - t )] d h
l n=- -l /2
l /2

1
= f (h ) e-iwn (h-t )d h
l n=- -l /2

l /2

Then some algebraic


manipulations lead to
the result.

2 pn
2 pn
h
-i
+i
t
1
l
l
h
h
f
e
d
e
=
(
)

n=- l -l /2

Ce
n

n=-

2013-03-08

i 2lpn t

n=-

ifn

Cn e e

i 2lpn t

Cn e

t f

2 pn

+
+ n
l

n=-

1999-2013 by Richard Alan Peters II

24

Relationship between the real and the


complex Fourier Series (contd.)
l /2
l /2

1
1

f (t ) = f (h ) cos (wn h - wnt ) d h - i f (h ) sin (wn h - wnt ) d h


l n=- -l /2
l n=- -l /2

l /2

1
= f (h )[cos wn (h - t ) - i sin wn (h - t )] d h
l n=- -l /2
l /2

1
= f (h ) e-iwn (h-t )d h
l n=- -l /2

l /2

Then some algebraic


manipulations lead to
the result.

2 pn
2 pn
h
-i
+i
t
1
l
l
h
h
f
e
d
e
=
(
)

n=- l -l /2

Ce
n

n=-

2013-03-08

i 2lpn t

n=-

ifn

Cn e e

i 2lpn t

Cn e

t f

2 pn

+
+ n
l

n=-

1999-2013 by Richard Alan Peters II

25

Why are Fourier Coefficients Complex Numbers?


f (t ) =

Cn e

+i

2 pn
t
l

where Cn = Cn e +ifn .

n=-

Cn represents the
amplitude, A=|Cn|, and
relative phase, , of
that part of the original
signal, f (t), that is a
sinusoid of frequency
n = 2n / .

2013-03-08

intensity

0
0

frequency, = 1/

1999-2013 by Richard Alan Peters II

26

What about real + imaginary?

F (w ) = ( N2A co s )[d (w + N l ) + d (w - N l )]
+ i ( N2A sin )[- d (w + N l ) + d (w - N l )]

The FS of a cosine is a pair of


impulses with complex amplitudes
2013-03-08

1999-2013 by Richard Alan Peters II

27

The real and imaginary


parts at the positive
frequency, N/ ...

Real + Imaginary to
Magnitude & Phase

form a magnitude, NA/2, and a phase, 0.


2013-03-08

1999-2013 by Richard Alan Peters II

28

The real and imaginary


parts at the negative
frequency, -N/ ...

Real + Imaginary to
Magnitude & Phase

form a magnitude, NA/2, and a phase, -0.


2013-03-08

1999-2013 by Richard Alan Peters II

29

Fourier Series of a Square Wave


Time-domain
signal

Fourier
magnitude

Fourier
phase

2013-03-08

1999-2013 by Richard Alan Peters II

30

The Fourier Transform


is the decomposition of a nonperiodic signal into a
continuous sum* of sinusoids.

F ( w ) = F (w ) e

iF(w )

= f (t ) e i 2 p w t dt
-

= f (t )[cos ( 2pw t ) + i sin ( 2pw t )] dt


-

f (t ) = F (w ) e

-i 2 p w t

d w = F (w ) e-i(2 p w t +F(w)) d w
-

= F (w ) [cos ( 2pw t ) - i sin (2pw t )] d w


-

= F (w ) [cos ( 2pw t +F (w )) - i sin (2pw t +F (w ))] d w


-

2013-03-08

1999-2013 by Richard Alan Peters II

i.e., an integral.

31

Mammals Use the FT in Hearing

2013-03-08

1999-2013 by Richard Alan Peters II

32

The Discrete Fourier Transform


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 coefficients


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
2013-03-08

1999-2013 by Richard Alan Peters II

33

The Two-Dimensional Fourier Transform


Primary Uses of the FT in Image Processing:

2013-03-08

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-2013 by Richard Alan Peters II

34

The Fourier Transform: Discussion


The expressions

F (w ) = f (t ) e-i 2 p w t dt = f (t ) , e+ i 2 p w t
-

continuous signals
defined over all
real numbers

and
1
Hn =
N

N -1

he

-i 2 p k n / N

= hk , e

+i 2 p k n /N

n= 0

discrete signals
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
N -1
+ i 2 p k n / N N -1
{ hk } k =0 and { e
} k =0 .
2013-03-08

1999-2013 by Richard Alan Peters II

35

The Fourier Transform:


Discussion (contd.)
In the context of inner products, the complex exponentials

{ e-i2pw t

} and { e-i 2pk n/N

w and w (- , )

, -2, -1, 0,1, 2,

are called orthogonal sets since they have the property:

e-i 2 p w 1 t , e-i 2p w 2 t = e-i 2 p w 1 t e+ i 2 p w 2 t dt = { 0,

, if w 1= w 2
if w 1 w 2

-i 2 p j n / N

-i 2 p k n / N

, e

= e-i 2 p j n /N e+i 2 p k n /N = { 0,
N -1

c , if j = k
if j k

n= 0

The function
sets are called
orthogonal
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 ) = F (w ) e

-i 2 p w t

2013-03-08

N -1

d w and hk = H n e-i 2p k n /N .
n= 0

1999-2013 by Richard Alan Peters II

1 with

finite energy.
36

The Fourier Transform:


Discussion (contd.)
Consider the 2-dimensional functions

{e

-i 2 p ( ux + vy )

u , v, x, y }

and

{e

jm
-i 2 p ( M
+ kn
)
N

j , m 0, ..., M - 1, k , n 0,..., N- 1

These are, likewise, orthogonal:


e-i 2 p(u1x+v1 y) , e-i 2 p (u2 x+v2 y)

e-i 2 p (u1x+v1 y) e+ i 2 p (u2 x+v2 y) dxdy

- -

=
j m k n
-i 2 p 1 + 1
M
N

j m k n
-i 2 p 2 + 2
M
N

, e

M -1 N -1
m= 0 n= 0

( jMm + kNn) e+i 2p( jMm + kNn)

-i 2 p

= e
=

2013-03-08

, if u1 =u2 and v1 =v2


0, otherwise

c , if j1 = j2 and k1 = k2
0, otherwise

1999-2013 by Richard Alan Peters II

.
37

The Fourier Transform:


Discussion (contd.)
Therefore

{e

- i 2 p ( ux + vy )

u , v, x, y } and

{e

-i2p(

jm
M

kn
N

j, k , m , n, M

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,

f ( x, y ) =

M - 1N - 1

F (u , v) e+i 2 p ( ux+vy ) dudv and hmn = H jk e

jm kn
+i 2 p +
M
N

j= 0 k = 0

- -

where the Fourier coefficients are given by


F (u , v) =

M -1 N -1

jm kn
-i 2 p +
M
N

f ( x, y) e-i 2 p ( ux+vy ) dxdy and H jk = hmn e


m=0 n=0

- -

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


2013-03-08

1999-2013 by Richard Alan Peters II

38

Continuous Fourier Transform

The continuous Fourier


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

2013-03-08

1999-2013 by Richard Alan Peters II

39

Discrete Fourier Transform


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

The BoingBoing Bloggers

2013-03-08

1999-2013 by Richard Alan Peters II

40

Discrete Fourier Transform


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

The BoingBoing Bloggers

2013-03-08

1999-2013 by Richard Alan Peters II

41

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
R-1 C -1

I ( r , c ) = I ( v ,u ) e

vr uc
+ i 2 p +
R C

u =0 v=0

where
R-1 C -1

these complex
exponentials are
2D sinusoids.

vr uc
-i 2 p +
R C

I (v,u ) = RC1 I(r ,c) e


r =0

c=0

are the R x C Fourier coefficients.


2013-03-08

1999-2013 by Richard Alan Peters II

42

What are 2D sinusoids?


To simplify the situation assume R = C = N. Then

i 2

vr
R

+ uc
C

=e

2
(vr + uc)
N

=e

2
( r sin + c cos)
N

where

v = w sin , u = w cos , w = v 2 + u 2 , and


Write

Note: since images are indexed


by row & col with r down and c
to the right, is positive in the
clockwise direction.

N
= ,
w

Then by Eulers relation,

i 2 p l1 (r sin + c cos)

= tan -1 ( uv ) .

= cos [ 2lp (r sin + c cos )] i sin [ 2lp (r sin + c cos )].


Contd. on next page.

2013-03-08

1999-2013 by Richard Alan Peters II

43

What are 2D sinusoids? (contd.)


Both the real part of this,

Re e

i 2 p l1 (r sin + c cos)

} = + cos[

2p
l

(r sin + c cos )]

2p
l

(r sin + c cos )]

and the imaginary part,

Im e

i 2 p l1 (r sin + c cos)

} = sin [

are sinusoidal gratings of unit amplitude, period and direction .


Then

w
2pw
is the radian frequency, and
the frequency, of the wavefront
N
N

and =
2013-03-08

N
is the wavelength in pixels in the wavefront direction.
w
1999-2013 by Richard Alan Peters II

44

2D Sinusoids:

I ( r , c) =

2p

A
cos (r sin + c cos ) + j + 1
l

... are plane waves with


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

orientation

= phase shift
2013-03-08

1999-2013 by Richard Alan Peters II

45

2D Sinusoids:

2013-03-08

... specific orientations,


and phase shifts.

1999-2013 by Richard Alan Peters II

46

The Fourier Transform of an Image


c

I
2013-03-08

Re[F{I}]
1999-2013 by Richard Alan Peters II

Im[F{I}]
47

Points on the Fourier Plane


If R=C=N the point at
column freq. u and row
freq. v represents a
sinusoid with freq. and
orientation .
If R C then = 1/
where is the length of
vector (C/u, R/v) and the
wavefront orientation is
= tan-1[(v/R)/(u/C)].

2013-03-08

1999-2013 by Richard Alan Peters II

48

Points on the Fourier Plane (of a Digital Image)


In the Fourier transform of an RC digital image,
positions u and v indicate the number of repetitions
of the sinusoid in those directions. Therefore the
wavelengths along the column and row axes are

u = Cu

and v =

R
v

-v direction

pixels,

and the wavelength in the wavefront direction is

wf

More about
this later
(pp. 66-87).

of a digital image

-1

2
2 2
= RC (uR) + (vC ) .

wf =

v
R

, and

1
2
2
(uR) + (vC ) cycles.
RC

(0,0)

The wavefront direction is given by

wf = tan -1 ( v ) = tan -1 ( vu CR ).
u

2013-03-08

row freq.

column freq.
1999-2013 by Richard Alan Peters II

u direction

u = Cu , v =

- direction

The frequency is the fraction of the sinusoid


traversed over one pixel,

Note that the wave


front direction =
only if R=C.
49

Points on the Fourier Plane

Note that is the wavefront


direction only if R=C.

x
This point represents this particular sinusoidal grating
2013-03-08

1999-2013 by Richard Alan Peters II

50

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, ,
..these represent the amplitude
and offset of the sinusoid with
frequency and direction .*
2013-03-08

1999-2013 by Richard Alan Peters II

*See

p. 49.

51

The Value of a Fourier Coefficient


The magnitude and phase
representation makes
more sense physically
since the Fourier magnitude, A (,), at point (,)
represents the amplitude
of the sinusoid
and the phase, (,),
represents the offset of the
sinusoid relative to origin.
2013-03-08

1999-2013 by Richard Alan Peters II

52

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 amplitude, A, and the phase
offset, , of the sinusoid.

2013-03-08

1999-2013 by Richard Alan Peters II

*See

p. 49.

53

The Sinusoid from the Fourier Coeff. at (u,v)

Note that the wave


front direction =
only if R=C.
2013-03-08

1999-2013 by Richard Alan Peters II

54

FT of an Image (Magnitude + Phase)

I
2013-03-08

log{|F{I}|2+1}
1999-2013 by Richard Alan Peters II

[F{I}]
55

FT of an Image (Real + Imaginary)

I
2013-03-08

Re[F{I}]
1999-2013 by Richard Alan Peters II

Im[F{I}]
56

The Power Spectrum


The power spectrum of a signal is the square of
the magnitude of its Fourier Transform.

For display,
the log of
the power
spectrum is
often used.

I (u ,v) = I (u ,v) I*(u ,v)


= [ Re I (u ,v) + i Im I (u ,v)][ Re I (u ,v) - i Im I (u ,v)]
2

= [ Re I (u ,v)] + [ Im I (u ,v)] .

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


frequency component with period l = 1 / u 2 + v 2 and orientation
q = tan -1 (v / u ).

For display in Matlab:


PS = fftshift(2*log(abs(fft2(I))+1));
2013-03-08

1999-2013 by Richard Alan Peters II

57

On the Computation of the Power Spectrum


The power spectrum (PS) is defined by PS( I ) = F {I(u, v )} .
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)));
2

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;

2013-03-08

1999-2013 by Richard Alan Peters II

58

The Uncertainty Relation


space

frequency

FT

If x y is the extent of
the object in space and
if u v is its extent in
frequency then,
x y u v

space

frequency

FT

2013-03-08

1
16 2

A small object in space


has a large frequency
extent and vice-versa.
1999-2013 by Richard Alan Peters II

59

The Uncertainty Relation


small extent

IFT

small extent

large extent

space

IFT

2013-03-08

A symmetric pair of
lines in the frequency
domain becomes a
sinusoidal line in the
spatial domain.

large extent

frequency

small extent

Recall: a symmetric
pair of impulses in the
frequency domain
becomes a sinusoid in
the spatial domain.

small extent

space
large extent

frequency

large extent
1999-2013 by Richard Alan Peters II

60

The Fourier Transform of an Edge

edge

2013-03-08

Power Spectrum

1999-2013 by Richard Alan Peters II

Phase Spectrum

61

The Fourier Transform of a Bar

bar

2013-03-08

Power Spectrum

1999-2013 by Richard Alan Peters II

Phase Spectrum

62

Coordinate Origin of the FFT

Center =
(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

2013-03-08

1999-2013 by Richard Alan Peters II

63

Matlabs fftshift and ifftshift


I = ifftshift(J):

J = fftshift(I):

origin

origin

from FFT2
or ifftshift

after fftshift

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.


2013-03-08

1999-2013 by Richard Alan Peters II

64

Matlabs fftshift and ifftshift


J = fftshift(I):

I (1,1) J ( R/2 +1, C/2 +1)


2

I = ifftshift(J):
J ( R/2 +1, C/2 +1) I (1,1)

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


2013-03-08

1999-2013 by Richard Alan Peters II

65

Points on the Fourier Plane (of a Digital Image)


In the Fourier transform of an RC digital image,
positions u and v indicate the number of repetitions
of the sinusoid in those directions. Therefore the
wavelengths along the column and row axes are

u = Cu

and v =

R
v

-v direction

pixels,

and the wavelength in the wavefront direction is

wf

of a digital image

-1

2
2 2
= RC (uR) + (vC ) .

wf =

v
R

, and

1
2
2
(uR) + (vC ) cycles.
RC

(0,0)

The wavefront direction is given by

wf = tan -1 ( v ) = tan -1 ( vu CR ).
u

2013-03-08

row freq.

column freq.
1999-2013 by Richard Alan Peters II

u direction

u = Cu , v =

- direction

The frequency is the fraction of the sinusoid


traversed over one pixel,

Note that the wave


front direction =
only if R=C.
66

Geometrical Derivation of Wavelength


Since the wavelength of a horizontal* wave
is R/v and that of a vertical is C/u, the line
segment, h, that connects the two distances
is parallel to the wavefront. The wavelength
is the altitude of the triangle w.r.t. h (the
perpendicular to h that intersects the origin).
The area of the triangle, one half of base
times height, is independent of the leg that is
taken to be the base. Equate the expression
with base C/u to that with base h, to find
w.r.t R, C, v, u, & h. Then replace h with its
expression as a function of R, C, v, & u to
get the final expression.
*The equivalue lines are horizontal in a wave with a vertical wave front and vice versa.

2013-03-08

1999-2013 by Richard Alan Peters II

67

Coordinates and Directions in the Fourier Plane


decreasing rows
(-r,-c)

(-r,+c)

(-r,-c)
>0

<0
<0
(+r,-c)

(-r,+c)

increasing cols
(+r,+c)

decreasing cols
(+r,-c)

>0
(+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.
2013-03-08

1999-2013 by Richard Alan Peters II

68

Inverse FFTs of Impulses


horizontal is the
wavefront direction.

fftshifted

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


2013-03-08

1999-2013 by Richard Alan Peters II

69

Inverse FFTs of Impulses


vertical is the
wavefront direction.

fftshifted

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


2013-03-08

1999-2013 by Richard Alan Peters II

70

Inverse FFTs of Impulses


a checker-board
pattern.

fftshifted

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


2013-03-08

1999-2013 by Richard Alan Peters II

71

Inverse FFTs of Impulses


horizontal is the
wavefront direction.

fftshifted

lowest-possible-frequency horizontal sinusoid


2013-03-08

1999-2013 by Richard Alan Peters II

72

Inverse FFTs of Impulses


vertical is the
wavefront direction.

fftshifted

lowest-possible-frequency vertical sinusoid


2013-03-08

1999-2013 by Richard Alan Peters II

73

Inverse FFTs of Impulses


negative diagonal is
the wavefront direction.

fftshifted

lowest-possible-frequency negative diagonal sinusoid


2013-03-08

1999-2013 by Richard Alan Peters II

74

Inverse FFTs of Impulses


positive diagonal is
the wavefront direction.

fftshifted

lowest-possible-frequency positive diagonal sinusoid


2013-03-08

1999-2013 by Richard Alan Peters II

75

Frequencies and Wavelengths in the Fourier Plane


512 columns

384 rows

+u direction

+v direction

Note this

and this.

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


How can that be?
2013-03-08

1999-2013 by Richard Alan Peters II

76

Frequencies and Wavelengths in the Fourier Plane

u = C / u

384 rows

512 columns

u = # of complete cycles
in the horizontal direction

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


2013-03-08

1999-2013 by Richard Alan Peters II

77

Frequencies and Wavelengths in the Fourier Plane

v = # of complete
cycles in the
vertical direction

v = R / v

384 rows

512 columns

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


2013-03-08

1999-2013 by Richard Alan Peters II

78

Frequencies and Wavelengths in the Fourier Plane

u = C / u

384 rows

512 columns

u = # of complete cycles
in the horizontal direction

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


2013-03-08

1999-2013 by Richard Alan Peters II

79

Frequencies and Wavelengths in the Fourier Plane

v = # of complete
cycles in the
vertical direction

v = R / v

384 rows

512 columns

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


2013-03-08

1999-2013 by Richard Alan Peters II

80

Frequencies and Wavelengths in the Fourier Plane

u = C / u

384 rows

512 columns

u = # of complete cycles
in the horizontal direction

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


2013-03-08

1999-2013 by Richard Alan Peters II

81

Frequencies and Wavelengths in the Fourier Plane

v = # of complete
cycles in the
vertical direction

v = R / v

384 rows

512 columns

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


2013-03-08

1999-2013 by Richard Alan Peters II

82

In the Fourier plane of a


square image, the orientation
of the line through the point
pair = the orientation of the
wave front in the image. Not
so for a non-square image.

In the F plane the angle is -45


in this image its about -53
(yellow line). Thats because
the fraction of R covered by
one pixel is 4/3 the fraction of
C covered by one pixel.

Frequencies and Wavelengths in the Fourier Plane

384 rows

512 columns

Also as a result, the


wavelength is 102.4.

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


2013-03-08

1999-2013 by Richard Alan Peters II

83

In general the slope of the


wavefront direction in the
image is given by (v/R) / (u/C).
Therefore its angle is

Frequencies
and
vC Wavelengths in the Fourier Plane
= tan ,
-1

wf

uR

512 columns

wf

wf

384 rows

wf

and the wavelength is:

frequencies: (u,v) = (3,3);


2013-03-08

-1

2
2 2
wavelengths: wf(=u, RC
v)(uR
= )(170
,128)
+ (vC
) .

1999-2013 by Richard Alan Peters II

84

Frequencies and Wavelengths in the Fourier Plane

384 rows

512 columns

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


2013-03-08

1999-2013 by Richard Alan Peters II

85

Frequencies and Wavelengths in the Fourier Plane

384 rows

512 columns

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


2013-03-08

1999-2013 by Richard Alan Peters II

86

The ratio R/C = in this image. Therefore at


frequency (4,3) the wave front angle is
-1 3 512
-1 3 4

= tan -1 (in

tan
tan
1
45
,Fourier
=
=
=
)
Frequencies
and
Wavelengths
the

wf
4 384
4 3

Plane

512 columns

wf
wf

384 rows

wf

and the wavelength is

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


wf

2013-03-08

2
2
= 384 512 (3 384) + (4 512)

1999-2013 by Richard Alan Peters II

1
2

83.67,
87

Power Spectrum of an Image

2013-03-08

1999-2013 by Richard Alan Peters II

88

Relationship between Image and FT


phase

power spectrum

power spectrum

2013-03-08

1999-2013 by Richard Alan Peters II

phase

89

Features in the FT and in the Image


Lines in
the Power
Spectrum
are
perpendicular to
lines in the
image.

2013-03-08

1999-2013 by Richard Alan Peters II

90

Fourier Magnitude and Phase

2013-03-08

1999-2013 by Richard Alan Peters II

91

Fourier Magnitude

log

F {I}

2013-03-08

1999-2013 by Richard Alan Peters II

92

Fourier Phase

F { I}

2013-03-08

1999-2013 by Richard Alan Peters II

93

Q: Which contains more visually relevant


information; magnitude or phase?

original image

2013-03-08

Fourier log
magnitude
1999-2013 by Richard Alan Peters II

Fourier phase

94

Magnitude Only Reconstruction

2013-03-08

1999-2013 by Richard Alan Peters II

95

Phase Only Reconstruction

2013-03-08

1999-2013 by Richard Alan Peters II

96

You might also like