Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

39
Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu

Transcript of Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Page 1: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Image Enhancement in the Frequency Domain

Spring 2006, Jen-Chang Liu

Page 2: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Outline Introduction to the Fourier Transform and

Frequency Domain Magnitude of frequencies Phase of frequencies Fourier transform and DFT

Filtering in the frequency domain Smoothing Frequency Domain Filters Sharpening Frequency Domain Filters Homomorphic Filtering Implementation of Fourier transform

Page 3: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Background

1807, French math. Fourier Any function that periodically repeats itself

can be expressed as the sum of of sines and/or cosines of different frequencies, each multiplied by a different coefficient (Fourier series)

Page 4: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Periodic function

f(t) = f(t+T), T: period (sec.) 1/T: frequency (cycles/sec.)

Page 5: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Periodic function f

Frequency Weightf1 w1

f2 w2

f3 w3

f4 w4

Page 6: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.
Page 7: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

How to measure weights? Assume f1 , f2 , f3 , f4 are known

How to measure w1 , w2 , w3 , w4 ?

)()()()()( 44332211 tfwtfwtfwtfwtf

min dttfwtfwtfwtfwtf ))]()()()(()([ 244332211

Minimize squared error

Page 8: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Minimize MSE calculation

dttfwtfwtfwtfwtf ))]()()()(()([ 244332211

min ),,,( 4321 wwwwF

dtffw

ffwwffw

ffwwffwwffw

ffwwffwwffwwffw

fwfwfwfwf

)2

22

222

2222

(

44

343433

2442233222

14411331122111

24

24

23

23

22

22

21

21

2

Page 9: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Orthogonal condition

f1 and f2   are orthogonal if

f1 , f2 , f3 , f4 are orthogonal to each other

正交

0)()(, 2121 dttftfff

),,,( 4321 wwwwF

dtffwffwffwffw

fwfwfwfwf

)2-2-2-2

(

44332211

24

24

23

23

22

22

21

21

2

Page 10: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Minimization calculation To satisfy min ),,,( 4321 wwwwF

We have 022 12

111

fffww

F

dtffwffwffwffw

fwfwfwfwf

)2-2-2-2

(

44332211

24

24

23

23

22

22

21

21

2

=>

21

1

1f

ffw

2

1

1,

f

ff

Recall in linear algebra: projection

Page 11: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Weight = Projection magnitude

Represent input f(x) with another basis functions

v

Vector space

(1,0)

projection

Functional space

f

f1

Page 12: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Summary 1

A function f can be written as sum of f1 , f2 , f3 , …

i

ii tfwtf )()(

If f1 , f2 , f3 , … are orthogonal to each other

2

,

i

ii

f

ffw Weight (magnitude)

Page 13: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Summary 1: sine, cosine bases

Let f1 , f2 , f3 , … carry frequency information Let them be sines and cosines

otherwise 0

0 if 2

1 if

)cos()cos( kn

kn

dtktntn, k:integers

otherwise 0

1 if )sin()sin(

kndtktnt

kndtktnt , integers allfor 0)cos()sin(

=> They all satisfy orthogonal conditions

Page 14: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Summary 1: orthogonal

Page 15: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Fourier series For 20 ),( ttf (Assume periodic outside)

)sin()cos()(1

0 ktbktaatf kk

k

,...,,,,,, 3322110 bababaa

DC頻率 =1 頻率 =2 頻率 =3

Page 16: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Outline Introduction to the Fourier Transform and

Frequency Domain Magnitude of frequencies Phase of frequencies Fourier transform and DFT

Filtering in the frequency domain Smoothing Frequency Domain Filters Sharpening Frequency Domain Filters Homomorphic Filtering Implementation of Fourier transform

Page 17: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Correlation with different phase

Weight calculation2

1

11

,

f

ffw

相關係數

f1

f

相位

Page 18: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Correlation with different phase (cont.)

Weight calculation2

1

11

,

f

ffw

相關係數 ?

f1

f

Page 19: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Deal with phase: method 1

For example, expand f(t) over the cos(wt) basis function Consider different phases )cos( wt

dtwttfCorr )cos()()(

0 2

Corr(

Problem: weight(w, )

Page 20: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Deal with phase: method 2

Complex exponential as basis

)sin()cos( tjte jt

j

1

cos

sinrealWith frequency w:

)sin()cos( wtjwte jwt

Advantage: Derive magnitude and phase simultaneously

1j

Page 21: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Deal with phase 2: example

Input )cos()( ttf

2

0)cos( dtet jt

dtetdtet jtjt

2

0

2

0)sin()sin()cos()cos(

jtetw ),cos(

dtttjdttt

2

0

2

0)sin()sin()sin()cos()cos()cos(

jej )sin()cos(magnitude

phase

Page 22: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Fourier series with phase For 20 ),( ttf (Assume periodic outside)

00

)sin(cos)(k

kk

jktk ktjktwewtf

,...,,, 3210 wwww

DC

頻率 k=1 k=2k=3

Complex weight

Page 23: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Outline Introduction to the Fourier Transform and

Frequency Domain Magnitude of frequencies Phase of frequencies Fourier transform and DFT

Filtering in the frequency domain Smoothing Frequency Domain Filters Sharpening Frequency Domain Filters Homomorphic Filtering Implementation of Fourier transform

Page 24: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Fourier transform

Functions that are not periodic can be expressed as the integral of sines and/or cosines multiplied by a weighting functions Frequency up to infinity

Perfect reconstructionFunctions -- Fourier transform

Operation in frequency domainwithout loss of information

Page 25: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

1-D Fourier Transform

Fourier transform F(u) of a continuous function f(x) is:

dxexfuF uxj 2)()(

dueuFxf uxj 2)()(

Inverse transform:

1j

Forward Fourier transform:

Page 26: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

2-D Fourier Transform

Fourier transform F(u,v) of a continuous function f(x,y) is:

dudvevuFyxf vyuxj )(2),(),(

Inverse transform:

x

y

u

vF

Page 27: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Future development

1950, fast Fourier transform (FFT) Revolution in the signal processing

Discrete Fourier transform (DFT) For digital computation

Page 28: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

1-D Discrete Fourier Transform

f(x), x=0,1,…,M-1 . discrete function F(u), u=0,1,…,M-1. DFT of f(x)

1

0

2)(

1)(

M

x

xM

uj

exfM

uF

1

0

2)()(

M

u

xM

ujeuFxf

Inverse transform:

Forward discrete Fourier transform:

Page 29: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Frequency Domain 頻率域 Where is the frequency domain?

sincos je j

j

1

cos

sin

]2sin2)[cos(1

)(1

0

xM

ujx

M

uxf

MuF

M

x

Euler’s formula:

frequency

u

F(u)

Page 30: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Fouriertransform

Page 31: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.
Page 32: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Physical analogy

Mathematical frequency splitting Fourier transform

Physical device Galss prism 三稜鏡 Split light into frequency components

Page 33: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

F(u) Complex quantity? Polar coordinate

real

imaginary

m

)()(

)()()(ujeuF

ujIuRuF

2/122 )]()([)( uIuRuF

])(

)([tan)( 1

uR

uIu

magnitude

phase

)()()()( 222uIuRuFuP Power spectrum

Page 34: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Some notes about sampling in time and frequency axis

Time index

Frequency index

Also follow reciprocal property

1,...,1,0 )()( 0

Mxxxxfxf

])1( ...., , , [ 000 xMxxxx

1,...,1,0 )()(

MuuuFuF

xu 1

Page 35: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Extend to 2-D DFT from 1-D

2-D: x-axis then y-axis

1

0

1

0

)(2),(

1),(

N

y

M

x

yM

vx

M

uj

eyxfMN

vuF

1

0

1

0

)(2),(),(

M

u

N

v

yM

vx

M

ujevuFyxf

Page 36: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Complex Quantities to Real Quantities

Useful representation2/122 )],(),([),( vuIvuRvuF

]),(

),([tan),( 1

vuR

vuIvu

magnitude

phase

),(),(),(),( 222vuIvuRvuFvuP

Power spectrum

Page 37: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

DFT: example

log(F)

Page 38: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

Properties in the frequency domain

Fourier transform works globally No direct relationship between a specific

components in an image and frequencies Intuition about frequency

Frequency content

Rate of change of gray levels in an image

Page 39: Image Enhancement in the Frequency Domain Spring 2006, Jen-Chang Liu.

+45,-45 degree

artifacts