Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis Functions • Fourier Coefficients • Fourier Transform - 1D • Fourier Transform - 2D Fourier Transform - Part I
Image Processing - Lesson 5
• Introduction to Fourier Transform
• Image Transforms
• Basis to Basis
• Fourier Basis Functions
• Fourier Coefficients
• Fourier Transform - 1D
• Fourier Transform - 2D
Fourier Transform - Part I
The Fourier Transform
Jean Baptiste Joseph Fourier
Efficient Data Representation
• Data can be represented in many ways.
• There is a great advantage using an appropriate representation.
• It is often appropriate to view images as combinations of waves.
How can we enhance such an image?
Solution: Image Representation
2 1 3
5 8 7
0 3 5
= 1 0 0
0 0 0
0 0 0
2 + 1
0 1 0
0 0 0
0 0 0
0 0 1
0 0 0
0 0 0
+ 3 + 5
0 0 0
1 0 0
0 0 0
+
+ ...
= 3 + 5 +
+ 10 + 23 + ...
The inverse Fourier Transform
• For linear-systems we saw that it is convenient to represent a signal f(x) as a sum of scaled and shifted sinusoids.
( ) ωωω
πω deFxf xi∫= 2)(
How is this done?
X Coordinate
Grayscale Image
[ a1 a2 a3 a4 ] =
a1 [ 1 0 0 0 ] + a2 [ 0 1 0 0 ] + a3 [ 0 0 1 0 ] + a4 [ 0 0 0 1 ]
Hadamard Transform:
1. Basis Functions.2. Method for finding the image given the transform coefficients. 3. Method for finding the transform coefficients given the image.
Standard Basis:
Transforms: Change of Basis
Frequency Coordinate
Fourier Image
Standard Basis New Basis
[ 2 1 0 1 ] =
= 1 [ 1 1 1 1 ] + 1/2 [ 1 1 -1 -1 ] - 1/2 [ -1 1 1 -1 ] + 0 [ -1 1 -1 1 ]
= [ 1 1/2 -1/2 0 ]Hadamard
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Wave Number
Hadamard Basis Functions - 1D
N = 16
X = [ 2 1 0 1 ] standard
New Basis:
Finding the transform coefficients
T0 = [ 1 1 1 1 ]T1 = [ 1 1 -1 -1 ]T2 = [ -1 1 1 -1 ]T3 = [ -1 1 -1 1 ]
Signal:
New Coefficients:
a0 = <X,T0 > =< [ 2 1 0 1 ] , [ 1 1 1 1 ] > /4 = 1a1 = <X,T1 > =< [ 2 1 0 1 ] , [ 1 1 -1 -1 ] > /4 = 1/2
a2 = <X,T2 > =< [ 2 1 0 1 ] , [ -1 1 1 -1 ] > /4 = -1/2
a3 = <X,T3 > =< [ 2 1 0 1 ] , [ -1 1 -1 1 ] > /4 = 0
X = [ 1 1/2 -1/2 0 ] newSignal:
1. Basis Functions.2. Method for finding the image given the transform coefficients. 3. Method for finding the transform coefficients given the image.
X Frequency
Y F
requ
ency
X Coordinate
Y C
oord
inat
e
Grayscale Image
FourierImage
1 00 0[ ]a11 a12
a21 a22[ ] 0 1
0 0[ ] 0 01 0[ ] 0 0
0 1[ ]+ a22+ a21+ a12= a11
Hadamard Transform:
1 11 1[ ]2 1
1 0[ ] 1 -11 -1[ ] -1 -1
1 1[ ] -1 11 -1[ ]+ 0- 1/2+ 1/2= 1
1 1/2-1/2 0[ ]=
Standard Basis:
Hadamard
Transforms: Change of Basis - 2D
[1 11 1[ ] 1 -1
1 -1[ ]-1 -11 1[ ] -1 1
1 -1[ ]1 1/2
-1/2 0 ][
Hadamard Transform:
1 11 1[ ]1 1/2
-1/2 0 ] 1 -11 -1[ ] -1 -1
1 1[ ] -1 11 -1[ ]+ 0- 1/2+ 1/2= 1
1 00 0[ ]2 1
1 0[ ] 0 10 0[ ] 0 0
1 0[ ] 0 00 1[ ]+ 0+ 1+ 1= 2
Standard Basis:
[[
[1 00 0[ ] 0 1
0 0]0 01 0] 0 0
0 1]2 1
1 0[ ]
Hadamard
Hadamard
Standardcoefficients
Basis Elements
Basis Elements
coefficients
Hadamard Basis Functions
size = 8x8 Black = +1 White = -1
For continuous images/signals f(x):
1) The number of Basis Elements Bi is ∞.
<f(x),Bi(x)> = dx
x
(x)iBf(x)∫
diBxf ii∫=i
(x)a)(
2) The dot product:
Fourier Transform
Basis Functions are sines and cosines
sin(x)
cos(2x)
sin(4x)
The transform coefficients determine the amplitude:
a sin(2x) 2a sin(2x) -a sin(2x)
3 sin(x)
+ 1 sin(3x)
+ 0.8 sin(5x)
+ 0.4 sin(7x)
=
A
B
C
D
A+B
A+B+C
A+B+C+D
Every function equals a sum of sines and cosines
The Fourier Transform
• The inverse Fourier Transform composes a signal f(x) given ( )ωF
( ) ωωω
πω deFxf xi∫= 2)(
• The Fourier Transform finds the given the signal f(x):
( ) dx∫ −=x
xi2f(x)eF πωω
( )ωF
• F(ω) is the Fourier transform of f(x):
• f(x) is the inverse Fourier transform of F(ω):
• f(x) and F(ω) are a Fourier transform pair.
( ){ } ( )ωFxfF =~
( ){ } ( )xfFF =− ω1~
• The Fourier transform F(ω) is a function over the complex numbers:
– Rω tells us how much of frequency ωis needed.
– θω tells us the shift of the Sine wave with frequency ω.
• Alternatively:
– aω tells us how much of cos with frequency ω is needed.
– bω tells us how much of sin with frequency ω is needed.
( ) ωθωω ieRF =
( ) ωωω ibaF +=
• Rω - is the amplitude of F(ω).
• θω - is the phase of F(ω).
• |Rω|2=F*(ω) F(ω) - is the power
spectrum of F(ω) .
• If a signal f(x) has a lot of fine details
F(ω) will be high for high ω.
• If the signal f(x) is "smooth" F(ω) will
be low for high ω.
Problem in Frequency
Space
Original Problem
Solution in Frequency
Space
Solution of Original Problem
Relatively easy solution
Difficult solution
Fourier Transform
Inverse Fourier
Transform
Why do we need representation in the frequency domain?
Examples:
• Let ( )xxf δ=)(
( ) ( ) 12 =⋅= −∞
∞−∫ xiexF πωδω
Fourier
x
f(x)
The Delta Function:
0
• Let 1)( =xf
( ) ( )ωδω πω == ∫∞
∞−
− xieF 2
Fourier
ω
x
f(x)
Rω
ω
θω
ω
Real
ω
Imag
The Constant Function:
0
0
0
• Let ( )xxf 02cos)( πω=
( ) ( ) =⋅+= −∞
∞−
−∫ dxeeeF xixixi πωπωπωω 222 00
21
x
ω
Rω
ω
θω
( ) ( )[ ]0021
ωωδωωδ ++−=
f(x)
Fourier
ω0-ω0ω
Real
ω
Imag
ω0-ω0
The Cosine wave:
• Let
<=
otherwise021if1)(
21
xxrect
( ) ( ) ( )πωπω
πωω πω sincsin5.0
5.0
2 === ∫−
− dxeF xi
x
f(x)
Fourier
Rω
ω
The Window Function (rect):
-0.5 0.5
Proof:
f(x) = rect1/2(x) ={1 |x| ≤ 1/2
0 otherwise1
-1/2 1/2
dxedxexfuF iuxiux ∫∫−
−∞
∞−
− ==2/1
2/1
22)()( ππ
[ ] 2/12/1
2
21
−−
−= iuxe
iuπ
π[ ]iuiu ee
iuππ
π −−
= −
21
[ ])sin()cos()sin()cos(21
uiuuiuiu
πππππ
−−−−
=
uu
ππ )sin(
= = sinc(u)
sinc(u)
u
F(u)
• Let2
)( xexf π−=
( ) 2πωω −=eF
x
f(x)
Fourier
Rω
ω
The Gaussian:
x
f(x)
Fourier
Rω
ω
k
1/k
The bed of nails function:
ck(x)
C1/k(ω)
{ } dxdyeyxfvuFyxfF vyuxi∫ ∫∞
∞−
∞
∞−
+−== )(2),(),(),(~ π
Fourier Transform - 2D
Given a continuous real function f(x,y),its Fourier transform F(u,v) is defined as:
The Inverse Fourier Transform:
F(u,v) = a(u,v) + ib(u,v) =|F(u,v)|eiφ(u,v)
Phase =
Spectrum (Amplitude) =
φ(u,v) = tg-1(b(u,v)/a(u,v))
|F(u,v)| = a2(u,v) + b2(u,v)
|F(u,v)|2 = a2(u,v) + b2(u,v)
√Power Spectrum =
{ } dudvevuFyxfvuFF vyuxi∫ ∫∞
∞−
∞
∞−
+− == )(21 ),(),(),(~ π
Fourier Wave Functions - 2D
F(u,v) is the coefficient of the sine wave e2πi(ux+vy)
1/u
1v
x
y
lines of (real) value 1
e2πi(ux+vy) = cos(2π(ux+vy)) + isin(2π(ux+vy))
The ratio determines the Direction.uv
The size of u,v determines the Frequency.
u = 0 direction of waves
v = 0
direction of waves
22
1
vu +
u=0, v=0 u=1, v=0 u=2, v=0u=-2, v=0 u=-1, v=0
u=0, v=1 u=1, v=1 u=2, v=1u=-2, v=1 u=-1, v=1
u=0, v=2 u=1, v=2 u=2, v=2u=-2, v=2 u=-1, v=2
u=0, v=-1 u=1, v=-1 u=2, v=-1u=-2, v=-1 u=-1, v=-1
u=0, v=-2 u=1, v=-2 u=2, v=-2u=-2, v=-2 u=-1, v=-2
U
V
Fourier Transform 2D - Example
2D Function
2D Fourier Transform
Fourier Transform 2D - Example
x
y
f(x,y)
1/2
1/2
1
f(x,y) = rect(x,y) = {1 |x| ≤ 1/2, |y| ≤ 1/2
0 otherwise
|F(u,v)|
F(u,v) = sinc(u) ⋅ sinc(v) = sinc(u,v)
Proof of Fourier of Rect = sinc in 2D
),()sin()sin(
vuSincv
vu
u==
ππ
ππ
∫ ∫∫ ∫− −
+−∞
∞−
∞
∞−
+− ==2/1
2/1
2/1
2/1
)(2)(2),()( dxdyedxdyeyxfuF vyuxivyuxi ππ
dyedxe ivyiux ∫∫−
−
−
−=2/1
2/1
22/1
2/1
2 ππ
Image Domain Frequency Domain
Fourier Transform Examples