fourier transform - part i - haifadkeren/ip/lecture5.pdf · image processing - lesson 5 •...

34
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

Upload: buique

Post on 03-Jul-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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

Page 2: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

The Fourier Transform

Jean Baptiste Joseph Fourier

Page 3: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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.

Page 4: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

How can we enhance such an image?

Page 5: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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

Page 6: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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?

Page 7: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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

Page 8: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Wave Number

Hadamard Basis Functions - 1D

N = 16

Page 9: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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:

Page 10: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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

Page 11: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

[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

Page 12: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

Hadamard Basis Functions

size = 8x8 Black = +1 White = -1

Page 13: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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:

Page 14: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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)

Page 15: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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

Page 16: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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

Page 17: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

• 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~

Page 18: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

• 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 +=

Page 19: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

• 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 ω.

Page 20: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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?

Page 21: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

Examples:

• Let ( )xxf δ=)(

( ) ( ) 12 =⋅= −∞

∞−∫ xiexF πωδω

Fourier

x

f(x)

The Delta Function:

0

Page 22: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

• Let 1)( =xf

( ) ( )ωδω πω == ∫∞

∞−

− xieF 2

Fourier

ω

x

f(x)

ω

θω

ω

Real

ω

Imag

The Constant Function:

0

0

0

Page 23: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

• Let ( )xxf 02cos)( πω=

( ) ( ) =⋅+= −∞

∞−

−∫ dxeeeF xixixi πωπωπωω 222 00

21

x

ω

ω

θω

( ) ( )[ ]0021

ωωδωωδ ++−=

f(x)

Fourier

ω0-ω0ω

Real

ω

Imag

ω0-ω0

The Cosine wave:

Page 24: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

• Let

<=

otherwise021if1)(

21

xxrect

( ) ( ) ( )πωπω

πωω πω sincsin5.0

5.0

2 === ∫−

− dxeF xi

x

f(x)

Fourier

ω

The Window Function (rect):

-0.5 0.5

Page 25: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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)

Page 26: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

• Let2

)( xexf π−=

( ) 2πωω −=eF

x

f(x)

Fourier

ω

The Gaussian:

Page 27: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

x

f(x)

Fourier

ω

k

1/k

The bed of nails function:

ck(x)

C1/k(ω)

Page 28: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

{ } 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 ),(),(),(~ π

Page 29: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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 +

Page 30: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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

Page 31: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

Fourier Transform 2D - Example

2D Function

2D Fourier Transform

Page 32: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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)

Page 33: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

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 ππ

Page 34: Fourier Transform - Part I - Haifadkeren/ip/lecture5.pdf · Image Processing - Lesson 5 • Introduction to Fourier Transform • Image Transforms • Basis to Basis • Fourier Basis

Image Domain Frequency Domain

Fourier Transform Examples