Unformatted text preview: EECE\CS 253 Image Processing
Lecture Notes: The 1&2Dimensional Fourier Transforms
Lecture Notes Richard Alan Peters II
Department of Electrical Engineering and
Computer Science
Fall Semester 2011 This work is licensed under the Creative Commons AttributionNoncommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/bync/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
20110927 19992011 by Richard Alan Peters II 2 Signals: SpaceTime 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 they’d contain
no information).
Frequencydomain representation: an exact
description of a signal in terms of its undulations. 20110927 19992011 by Richard Alan Peters II 3 Origin of Sounds 20110927 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.
19992011 by Richard Alan Peters II 4 Vibratory Modes / Standing Waves: Examples displacement from rest position internal pressure string modes pipe modes 20110927 Note that
the modes
are all
sinusoids. 19992011 by Richard Alan Peters II Note that
the negatives
of these also
will occur 5 Sound Waves: Emerge from the superposition of the modes. 19992011 by Richard Alan Peters II pipe sound string sound 20110927 6 Sound Waves: The vibratory modes
add up to one complex
motion that pushes
the air around the
vibrating object 19992011 by Richard Alan Peters II Oddorder
harmonics pipe sound 20110927 string sound Evenorder
harmonics Emerge from the superposition of the modes. 7 Fact: Any Real Signal has
a FrequencyDomain
Representation Oddorder harmonics
sq (t ) = é 2p
ù
1
sin ê (2n + 1) t ú
å 2n +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).
20110927 19992011 by Richard Alan Peters II 8 FrequencyDomain Representation
Any periodic signal can be described by a sum of sinusoids.
sq (t ) = é 2p
ù
1
sin ê (2n + 1) t ú
å 2n +1 êë l
úû
n=¥
¥ The sinusoids are called
“basis functions”.
The multipliers are called
“Fourier coefficients”.
20110927 19992011 by Richard Alan Peters II 9 FrequencyDomain Representation
Any periodic signal can be described by a sum of sinusoids.
sq (t ) = é 2p
ù
1
sin ê (2n + 1) t ú
å 2n +1 êë l
úû
n=¥
¥ The sinusoids are called
“basis functions”.
The multipliers are called
“Fourier coefficients”.
20110927 Basis
functions 19992011 by Richard Alan Peters II 10 FrequencyDomain Representation
Any periodic signal can be described by a sum of sinusoids.
sq (t ) = é 2p
ù
1
sin ê (2n + 1) t ú
å 2n +1 êë l
úû
n=¥
¥ The sinusoids are called
“basis functions”.
The multipliers are called
“Fourier coefficients”.
20110927 The Fourier
coefficients
(of a square
wave). 19992011 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
20110927 16 sines
19992011 by Richard Alan Peters II 32 sines 12 Anatomy of a Sinusoid
f (t) 0 æ 2p
ö
ç
f (t ) = A sin ç t  f÷
÷
÷
èl
ø 20110927 19992011 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.
20110927 19992011 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 0 20110927 19992011 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 0 20110927 19992011 by Richard Alan Peters II 16 Inner Product of a Periodic Function and a Sinusoid 3 different
representations 20110927 19992011 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. 20110927 19992011 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. 20110927 19992011 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 ö
÷ + Bn sin æ 2p n t ö
ç
ç
An cos ç
t÷
÷
çl ÷
÷
÷
èl ø
è
ø periodic : $l Î such that f (t nl ) = f (t ) 2
An =
l
2
Bn =
l
20110927 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
÷
÷ú
è
øû
êë ç l 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
÷
÷ú
è
øû
êë ç l The basis functions
correspond to modes
of vibration. 19992011 by Richard Alan Peters II 20 can also be written in terms
of complex exponentials The Fourier Series
f (t ) = ¥ åCe
n n=¥ = p
i 2l n t + = ¥ å Cn e æ 2 pn
ö
÷
ç
+ç
+fn ÷
÷
çl
è
ø i t n=¥ æ 2pn
ö
æ 2p n
ö
Cn cos ç
t + fn ÷ + Cn sin ç
t + fn ÷
÷
÷
å
ç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 l /2 20110927 i = 1 19992011 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 Cont’d. 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 sinepluscosine
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.
20110927 19992011 by Richard Alan Peters II 22 Relationship between the real and the
complex Fourier Series (cont’d.)
Claim: 0= ¥ å sin (w h  w t ).
n n n=¥
l /2 Therefore: ò l /2 Thus: Cont’d. 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 ¥ éê
ú i å
ú
f (t ) = å ê ò f (h ) cos (wn h  wnt ) d h ú
ê ò f (h ) sin (wn h  wnt ) d h ú.
l n=¥ êël /2
úû l n=¥ êël /2
úû 20110927 19992011 by Richard Alan Peters II 23 Relationship between the real and the
complex Fourier Series (cont’d.)
l /2
l /2
ù
ù
1 ¥ éê
1 ¥ éê
ú i å
ú
f (t ) = å ê ò f (h ) cos (wn h  wnt ) d h ú
ê ò 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 ) eiwn (ht )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
f (h ) e l d h e l
=å
ò
n=¥ l l /2 = åCe
n n=¥ 20110927 p
i 2l n t = ¥ å n=¥ ifn Cn e e p
i 2l n t + = ¥ å Cn e tf æ 2 pn
ö
÷
+ç
ç
÷
ç l + n÷
è
ø i n=¥ 19992011 by Richard Alan Peters II 24 Relationship between the real and the
complex Fourier Series (cont’d.)
l /2
l /2
ù
ù
1 ¥ éê
1 ¥ éê
ú i å
ú
f (t ) = å ê ò f (h ) cos (wn h  wnt ) d h ú
ê ò 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 ) eiwn (ht )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
f (h ) e l d h e l
=å
ò
n=¥ l l /2 = åCe
n n=¥ 20110927 p
i 2l n t = ¥ å n=¥ ifn Cn e e p
i 2l n t + = ¥ å Cn e tf æ 2 pn
ö
÷
+ç
ç
÷
ç l + n÷
è
ø i n=¥ 19992011 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 = n / λ. 20110927 intensity 0
0 frequency, ω = 1/λ 19992011 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
20110927 19992011 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.
20110927 19992011 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.
20110927 19992011 by Richard Alan Peters II 29 Fourier Series of a Square Wave
Timedomain
signal Fourier
magnitude Fourier
phase 20110927 19992011 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 ) ei(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
¥ 20110927 19992011 by Richard Alan Peters II * i.e., an integral. 31 Mammals Use the FT in Hearing 20110927 19992011 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
20110927 19992011 by Richard Alan Peters II 33 The TwoDimensional Fourier Transform
Primary Uses of the FT in Image Processing: 20110927 Explains why downsampling 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. 19992011 by Richard Alan Peters II 34 The Fourier Transform: Discussion
The expressions
¥ F (w ) = ò f (t ) ei 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 k = 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 .
20110927 19992011 by Richard Alan Peters II 35 The Fourier Transform:
Discussion (cont’d.)
In the context of inner products, the complex exponentials { ei2pw t } and { ei 2pk n/N w ÎÂ and w Î(¥ , ¥) , 2, 1, 0,1, 2, } are called “orthogonal sets” since they have the property:
¥ ei 2 p w 1 t , ei 2p w 2 t = ò ei 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 e i 2 p k n / N ,e = å ei 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 complexvalued 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 ¥ 20110927 N 1 d w and hk = å H n ei 2p k n /N .
n= 0 19992011 by Richard Alan Peters II 1 with finite energy.
36 The Fourier Transform:
Discussion (cont’d.)
Consider the 2dimensional 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:
¥¥ =ò ei 2 p(u1x+v1 y) , ei 2 p (u2 x+v2 y) ò ei 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ø e æ 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
= 20110927 { ¥ , if u1 =u2 and v1 =v2
0, otherwise 1 1 c , if j1 = j2 and k1 = k2
0, otherwise 19992011 by Richard Alan Peters II 2 2 .
37 The Fourier Transform:
Discussion (cont’d.)
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) ei 2 p ( ux+vy ) dxdy and H jk = å å hmn e
m=0 n=0 ¥ ¥ . (True for finite energy functions f (x,y) and {{ hmn }}.)
20110927 19992011 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 20110927 19992011 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 20110927 19992011 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 20110927 19992011 by Richard Alan Peters II 41 The 2D Fourier Transform of a Digital Image
Let I(r,c) be a singleband (intensity) digital image with R
rows and C columns. Then, I(r,c) has Fourier representation
R1 C 1 I ( r , c ) = å å I ( v ,u ) e æ vr uc ö
+i 2 p ç + ÷
ç
÷
çR C ÷
è
ø u =0 v=0 , where
R1 C 1 these complex
exponentials are
2D sinusoids. æ vr uc ö
÷
i 2 p ç + ÷
ç
ç
èR C ÷
ø 1
I (v,u ) = RC å å I(r ,c) e
r =0 c=0 are the R x C Fourier coefficients.
20110927 19992011 by Richard Alan Peters II 42 What are 2D sinusoids?
To simplify the situation assume R = C = N. Then e ± i 2π ( vr
R + uc
C ) =e ±i 2π
(vr + uc)
N =e ±i 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 Euler’s relation, e 1 i 2 p l (r sin θ + c cos θ) v
θ = tan 1 ( u ) . = cos [ 2lp (r sin θ + c cos θ)] i sin [ 2lp (r sin θ + c cos θ)].
Cont’d. on next page. 20110927 19992011 by Richard Alan Peters II 43 What are 2D sinusoids? (cont’d.)
Both the real part of this, { Re e 1
i 2 p l (r sin θ + c cos θ) } = + cos[ 2p
l (r sin θ + c cos θ)] 2p
l (r sin θ + c cos θ)] and the imaginary part, { Im e 1
i 2 p l (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 λ =
20110927 N
is the wavelength in pixels in the wavefront direction.
w
19992011 by Richard Alan Peters II 44 2D Sinusoids: I ( r , c) = { } é 2p
ù
A
cos ê (r ⋅ sin θ + c ⋅ cos θ) + j ú + 1
êë l
úû
2 ... are plane waves with
grayscale amplitudes,
periods in terms of lengths, ... θ
orientation A φ = phase shift
20110927 19992011 by Richard Alan Peters II 45 2D Sinusoids: 20110927 ... specific orientations,
and phase shifts. 19992011 by Richard Alan Peters II 46 The Fourier Transform of an Image
c v v u u r I
20110927 Re[F{I}]
19992011 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
θ = tan1[(v/R)/(u/C)]. 20110927 19992011 by Richard Alan Peters II 48 Points on the Fourier Plane (of a Digital Image)
In the Fourier transform of an R×C 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 = C
u and λ v = R
v v direction pixels, and the wavelength in the wavefront direction is of a digital image ( ) +( ) .
C2
u λ wf = R2
v v
, ω v = R , and ω wf = 1 ()()
C2
+
u R2
v cycles. (0,0) The wavefront direction is given by
ω
θ wf = tan 1 ( ω v ) = tan 1 ( v C ).
uR
u 20110927 row freq.
────────
column freq.
19992011 by Richard Alan Peters II u direction u
C θ direction The frequency is the fraction of the sinusoid
traversed over one pixel, ωu = More about
this later
(pp. 6686). 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. y x
This point represents this particular sinusoidal grating
20110927 19992011 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 θ.*
20110927 19992011 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.
20110927 19992011 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. 20110927 19992011 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.
20110927 19992011 by Richard Alan Peters II 54 FT of an Image (Magnitude + Phase) I
20110927 log{F{I}2+1}
19992011 by Richard Alan Peters II ∠[F{I}]
55 FT of an Image (Real + Imaginary) I
20110927 Re[F{I}]
19992011 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. 2 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 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));
20110927 19992011 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 basee 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 0255 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; 20110927 19992011 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 20110927 1
16π 2 A small object in space
has a large frequency
extent and viceversa.
19992011 by Richard Alan Peters II 59 The Uncertainty Relation
→ small extent ← IFT → small extent ← ← large extent → space IFT 20110927 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 →
19992011 by Richard Alan Peters II 60 The Fourier Transform of an Edge edge 20110927 Power Spectrum 19992011 by Richard Alan Peters II Phase Spectrum 61 The Fourier Transform of a Bar bar 20110927 Power Spectrum 19992011 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 20110927 19992011 by Richard Alan Peters II 63 Matlab’s 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.
20110927 19992011 by Richard Alan Peters II 64 Matlab’s fftshift and ifftshift
5 6 4 8 J = fftshift(I): 9 7 1 3 5 6 7
2 3 4 I (1,1) → J ( R/2 +1, C/2 +1) 2 8 9 1 5
1 J ( R/2 +1, C/2 +1) → I (1,1) 2 3 4 5
8 4 8 9 7 3
1 6 7 6 2 I = ifftshift(J): 9 where x = floor(x) = the largest integer smaller than x.
20110927 19992011 by Richard Alan Peters II 65 Points on the Fourier Plane (of a Digital Image)
In the Fourier transform of an R×C 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 = C
u and λ v = R
v v direction pixels, and the wavelength in the wavefront direction is of a digital image ( ) +( ) .
C2
u λ wf = R2
v u
C v
, ω v = R , and ω wf = 1 ()()
C2
+
u R2
v cycles. (0,0) The wavefront direction is given by
ω
θ wf = tan 1 ( ω v ) = tan 1 ( v C ).
uR
u 20110927 row freq.
────────
column freq.
19992011 by Richard Alan Peters II u direction ωu = θ direction The frequency is the fraction of the sinusoid
traversed over one pixel, Note that the wave
front direction = θ
only if R=C.
66 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 righthanded coordinate system.
20110927 19992011 by Richard Alan Peters II 67 Inverse FFTs of Impulses
“horizontal” is the
wavefront direction. fftshifted highestpossiblefrequency horizontal sinusoid (C is even)
20110927 19992011 by Richard Alan Peters II 68 Inverse FFTs of Impulses
“vertical” is the
wavefront direction. fftshifted highestpossiblefrequency vertical sinusoid (R is even)
20110927 19992011 by Richard Alan Peters II 69 Inverse FFTs of Impulses
a checkerboard
pattern. fftshifted highestpossiblefreq horizontal+vertical sinusoid (R & C even)
20110927 19992011 by Richard Alan Peters II 70 Inverse FFTs of Impulses
“horizontal” is the
wavefront direction. fftshifted lowestpossiblefrequency horizontal sinusoid
20110927 19992011 by Richard Alan Peters II 71 Inverse FFTs of Impulses
“vertical” is the
wavefront direction. fftshifted lowestpossiblefrequency vertical sinusoid
20110927 19992011 by Richard Alan Peters II 72 Inverse FFTs of Impulses
“negative diagonal” is
the wavefront direction. fftshifted lowestpossiblefrequency negative diagonal sinusoid
20110927 19992011 by Richard Alan Peters II 73 Inverse FFTs of Impulses
“positive diagonal” is
the wavefront direction. fftshifted lowestpossiblefrequency positive diagonal sinusoid
20110927 19992011 by Richard Alan Peters II 74 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?
20110927 19992011 by Richard Alan Peters II 75 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
20110927 19992011 by Richard Alan Peters II 76 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
20110927 19992011 by Richard Alan Peters II 77 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
20110927 19992011 by Richard Alan Peters II 78 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
20110927 19992011 by Richard Alan Peters II 79 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 ⅔
20110927 19992011 by Richard Alan Peters II 80 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
20110927 19992011 by Richard Alan Peters II 81 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 nonsquare image. In the F plane the angle is 45˚
in this image it’s about 53˚
(yellow line). That’s 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 213⅓. frequencies: (u,v) = (3,3); wavelengths: (λu, λv) = (170 ⅔,128)
20110927 19992011 by Richard Alan Peters II 82 In general the slope of the
wavefront direction in the
image is given by (v/R) / (u/C).
Therefore its angle is Frequencies and , Wavelengths in the Fourier Plane
æ vC ö
θ = tan ç ÷
1 wf ç uR ÷
è÷
ø 512 columns λwf
θ 384 rows θ θwf
θwf and the wavelength is: frequencies: (u,v) = (3,3); wavelengths:
20110927 19992011 by Richard Alan Peters II 2 2 æ Rö
C
(λwf, =v)æ= ö(170 ⅔,128)
λu λ ç ÷ +ç ÷ ,
çu÷ çv÷
è÷ è÷
ø
ø
83 Frequencies and Wavelengths in the Fourier Plane 384 rows 512 columns frequencies: (u,v) = (3,3); wavelengths: (λu, λv) = (170 ⅔,128)
20110927 19992011 by Richard Alan Peters II 84 Frequencies and Wavelengths in the Fourier Plane 384 rows 512 columns frequencies: (u,v) = (4,3); wavelengths: (λu, λv) = (128,128)
20110927 19992011 by Richard Alan Peters II 85 The ratio R/C = ¾ in this image. Therefore at
frequency (4,3) the wave front angle is æ 3 ⋅ 512 ö
æ 3⋅ 4 ö
÷ Wavelengths1 (1) = 45 ,Fourier
÷
ç
ç
θ wf = tan 1 ç and= tan 1 ç
Frequencies⋅ 384 ÷
÷ = tan in the
÷
÷
è4
ø
è 4 ⋅ 3ø Plane 512 columns θwf
θwf 384 rows λwf and the wavelength is frequencies: (u,v) = (4,3); wavelengths: (λöu, λv) = (128,128)
2
2
æ
öæ 512 ÷
384 ÷
2
λ wf = ç
÷ +ç
ç 4 ø è 3 ÷ = 2 ⋅128 = 128 2,
ç
÷
÷
è
ø 20110927 19992011 by Richard Alan Peters II 86 Power Spectrum of an Image 20110927 19992011 by Richard Alan Peters II 87 Relationship between Image and FT
phase power spectrum power spectrum 20110927 19992011 by Richard Alan Peters II phase 88 Features in the FT and in the Image
Lines in
the Power
Spectrum
are …
… perpendicular to
lines in the
image. 20110927 19992011 by Richard Alan Peters II 89 Fourier Magnitude and Phase I 20110927 19992011 by Richard Alan Peters II 90 Fourier Magnitude log F {I} 20110927 19992011 by Richard Alan Peters II 91 Fourier Phase F { I} 20110927 19992011 by Richard Alan Peters II 92 Q: Which contains more visually relevant
information; magnitude or phase? original image 20110927 Fourier log
magnitude
19992011 by Richard Alan Peters II Fourier phase 93 Magnitude Only Reconstruction 20110927 19992011 by Richard Alan Peters II 94 Phase Only Reconstruction 20110927 19992011 by Richard Alan Peters II 95 ...
View
Full Document
 Summer '07
 AlanPeters
 Electrical Engineering, Image processing, Fourier Series, Richard Alan Peters II, Richard Alan Peters

Click to edit the document details