2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied...

19
ECE/OPTI533 Digital Image Processing class notes 188 Dr. Robert A. Schowengerdt 2003 2-D DISCRETE FOURIER TRANSFORM DEFINITION forward DFT inverse DFT The DFT is a transform of a discrete, complex 2-D array of size M x N into another discrete, complex 2-D array of size M x N Approximates the Continuous Fourier Transform (CFT) under certain conditions Both f(m,n) and F(k,l) are 2-D periodic Alternate definitions: in inverse definition instead, or in forward and inverse definitions (“unitary”) • doesn’t matter as long as consistent Fkl , ( ) 1 MN --------- fmn , ( ) e j –2 π mk M ------ nl N ---- + n 0 = N 1 m 0 = M 1 = fmn , ( ) Fkl , ( ) e + j 2 π mk M ------ nl N ---- + l 0 = N 1 k 0 = M 1 = 1 MN --------- 1 MN -------------

Transcript of 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied...

Page 1: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 188 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

DEFIN

ITION

forw

ard

DFT

invers

e D

FT

•Th

e D

FT is

a tra

nsfo

rm o

f a d

iscre

te, c

om

ple

x 2

-D a

rray o

f siz

e M

x

N in

to a

noth

er d

iscre

te, c

om

ple

x 2

-D a

rray o

f siz

e M

x N

Ap

pro

xim

ate

s th

e C

on

tinu

ou

s F

ou

rier Tra

nsfo

rm (C

FT) u

nd

er c

erta

in c

on

ditio

ns

Both

f(m,n

) an

d F

(k,l) a

re 2

-D p

erio

dic

Alte

rna

te d

efin

ition

s:

in in

vers

e d

efin

ition

inste

ad

, or

in fo

rwa

rd a

nd

invers

e d

efin

ition

s (“

un

itary

”)

• d

oesn

’t ma

tter a

s lo

ng

as c

on

sis

ten

t

Fk

l,(

)1MN

---------f

mn,

()

ej

–2π

mk

M -------n

lN -----+

⋅n

0=

N1

∑m

0=

M1

∑=

fm

n,(

)F

kl,

()

e+

j2πm

kM -------

nlN -----

+

⋅l

0=

N1

∑k

0=

M1

∑=

1MN

---------1M

N--------------

Page 2: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 189 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

RELA

TION

OF TH

E D

FT TO

THE C

FT

•O

ne v

iew

of th

e D

FT is

as a

n a

pp

roxim

atio

n to

the C

FT

•“ re

cip

e” to

con

vert C

FT to

DFT:

1. s

am

ple

f(x,y

)

2. tru

nca

te to

MX

x N

Y

3. m

ake p

erio

dic

, i.e. th

e p

erio

dic

exte

nsio

n o

f a 2

-D a

rray f(m

,n) w

ith s

am

ple

inte

rva

ls X

=Y=

1

fx

y,(

)1XY

-------com

bx

Xy

Y⁄,

⁄(

)⋅

fx

y,(

)1XY

-------com

bx

Xy

Y⁄,

⁄(

)rect

xM

X⁄

yN⁄

Y,

()

⋅⋅

fx

y,(

)1XY

-------com

bx

Xy

Y⁄,

⁄(

)rect

xM

X⁄

yN

Y⁄

,(

)⋅

❉ ❉

1

MX

NY

⋅----------------------co

mb

xM

Xy

NY

⁄,

⁄(

)f

pm

n,(

)=

Page 3: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 190 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

4. ta

ke C

FT

, i.e. th

e p

erio

dic

exte

nsio

n o

f a 2

-D a

rray F

(k,l) w

ith s

am

ple

inte

rva

ls 1

/X=

1/Y

=1

•Th

e a

rrays f a

nd

F a

re b

oth

dis

cre

te a

nd

perio

dic

in s

pa

ce a

nd

sp

atia

l freq

uen

cy, re

sp

ectiv

ely

rep

lica

te (a

liasin

g

occu

rs h

ere

)sm

ooth

(lea

ka

ge

occu

rs h

ere

)sa

mp

le

Fu

v,(

) ❉ ❉

com

bu

XvY

,(

) ❉ ❉

MX

NY

⋅sinc

uM

XvN

Y,

()

[]

com

bu

MX

vNY

,(

)⋅

Fp

kl,

()

=

Page 4: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 191 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

CA

LCU

LA

TION

OF D

FT

•B

oth

arra

ys f(m

,n) a

nd

F(k

,l) are

perio

dic

(perio

d =

M x

N) a

nd

sa

mp

led

(X x

Y in

sp

ace, 1

/MX

x 1

/NY in

freq

uen

cy)

•In

the C

FT, if o

ne fu

nctio

n h

as c

om

pa

ct s

up

port (i.e

. it is s

pa

ce- o

r fre

qu

en

cy-lim

ited

), the o

ther m

ust h

ave

su

pp

ort

•Th

ere

fore

, alia

sin

g w

ill occu

r with

the D

FT, e

ither in

sp

ace o

r fre

qu

en

cy. If w

e w

an

t the D

FT to

clo

sely

ap

pro

xim

ate

the C

FT,

alia

sin

g m

ust b

e m

inim

ized

in b

oth

dom

ain

s

•Th

e F

ast F

ou

rier Tra

nsfo

rm (F

FT) is

an

effic

ien

t alg

orith

m to

ca

lcu

late

the D

FT th

at ta

kes a

dva

nta

ge o

f the p

erio

dic

ities in

the

com

ple

x e

xp

on

en

tial

Ca

n u

se 1

-D F

FT fo

r 2-D

DFT (la

ter)

Page 5: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 192 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

AR

RA

Y C

OO

RD

INA

TES

•Th

e D

C te

rm (u

=v=

0) is

at (0

,0) in

the ra

w o

utp

ut o

f the D

FT (e

.g.

the M

atla

b fu

nctio

n “

fft2”)

•R

eord

erin

g p

uts

the s

pectru

m in

to a

“p

hysic

al”

ord

er (th

e s

am

e

as s

een

in o

ptic

al F

ou

rier tra

nsfo

rms) (e

.g. th

e M

atla

b fu

nctio

n

“ffts

hift”

)

•N

an

d M

are

com

mon

ly p

ow

ers

of 2

for th

e F

FT. Th

ere

fore

, the D

C

term

is a

t (M/2

,N/2

) in th

e re

ord

ere

d fo

rma

t for (0

,0) in

dexin

g

an

d a

t (M/2

+1

,N/2

+1

) for (1

,1) in

dexin

g

Quad I

IIIIIIV

IIIIV

III

raw

ou

tpu

t of D

FT

reord

ere

d o

utp

ut o

f DFT

DC

DC

Page 6: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 193 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

SA

MPLE IN

TER

VA

LS

•Con

stra

ints

pro

du

ct o

f ph

ysic

al s

am

ple

inte

rva

ls in

x a

nd

u, y

an

d v

:X

U =

1/M

, YV

= 1

/N

sa

mp

ling (re

plic

atio

n) fre

qu

en

cy in

u a

nd

v:

u

s

= 1

/X, v

: v

s

= 1

/Y

fold

ing fre

qu

en

cy in

u a

nd

v:

u

f

= 1

/2X

, v

f

= 1

/2Y

•For im

ag

es, a

con

ven

ien

t, norm

aliz

ed

set o

f un

its is

X =

Y =

1 p

ixel

•Th

ere

fore

,

U =

1/M

cycle

s/p

ixel, u

s = 1

cycle

/pix

el, u

f = 1

/2 c

ycle

/pix

el

V =

1/N

cycle

s/p

ixel, v

s = 1

cycle

/pix

el, v

f = 1

/2 c

ycle

/pix

el

•N

ote

, in re

od

ere

d D

FT fo

rma

t, uf a

nd

vf a

re a

lon

g th

e firs

t row

an

d c

olu

mn

s o

f the a

rray

Page 7: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 194 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

Reord

erin

g th

e 2

-D D

FT

•“orig

in-c

en

tere

d” d

isp

lay k

l

123

4 432

010

2030

40

0

10

20

30

40 0 5 10 15 20 25

f(m,n

)

orig

in-c

en

tere

d

|F(k

,l)|

010

2030

40

0

10

20

30

40 0 5 10 15 20 25

010

2030

40

0

10

20

30

40 0

0.2

0.4

0.6

0.8 1

|F(k

,l)|

Page 8: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 195 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

Alia

sin

g in

the fre

qu

en

cy d

om

ain

•D

FT o

f dis

cre

te a

pp

roxim

atio

n to

a re

ct(x

/W,y

/W) fu

nctio

n

010

2030

40

0

10

20

30

40 0

0.2

0.4

0.6

0.8 1

010

2030

40

0

10

20

30

40 0

0.2

0.4

0.6

0.8 1

010

2030

40

0

10

20

30

40 0

0.2

0.4

0.6

0.8 1

010

2030

40

0

10

20

30

40 0 2 4 6 8 10

010

2030

40

0

10

20

30

40 0 20 40 60 80

100

010

2030

40

0

10

20

30

40 0 5 10 15 20 25

5 x

5

9 x

90

1020

3040

0

10

20

30

40 0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

010

2030

40

0

10

20

30

40 0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

010

2030

40

0

10

20

30

40 0

0.02

0.04

0.06

0.08

0.1

0.12

0.14

f(m,n

)|F

(k,l)|

|F(k

,l)| - |F(u

,v)|

3 x

3

Page 9: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 196 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

Dig

ital im

ag

e p

ow

er s

pectru

m (s

qu

are

d a

mp

litud

e o

f F) c

oord

ina

tes

(0,0

)(u

,v)=

(-0.5

,-0.5

)cycle

s/p

ixel

(M/2

,N)

(u,v

) = (+

0.5

-1/N

,0)

cycle

s/p

ixel

(M,N

/2), (u

,v) =

(0,+

0.5

-1/M

) cycle

s/p

ixel

(M,N

)(u

,v)=

(+0

.5-1

/N,

+0

.5-1

/M)

cycle

s/p

ixel

Page 10: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 197 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

EX

AM

PLES O

F IM

AGE P

OW

ER

SPECTR

A

desert

field

s

stre

ets

railro

ad

Page 11: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 198 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

DIS

PLA

Y O

F P

OW

ER

SPECTR

A

•La

rge d

yn

am

ic ra

ng

e

am

plitu

de a

t zero

-freq

uen

cy d

om

ina

tes

Pow

er S

pectra

Dis

pla

y

• M

ask z

ero

-freq

uen

cy te

rm to

zero

• C

on

trast s

tretc

h w

ith s

qu

are

-root tra

nsfo

rm

• R

ep

ea

t con

stra

st s

tretc

h a

s n

eed

ed

Page 12: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 199 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

Exa

mp

le

pow

er s

pectru

mD

C m

asked

22

24

28

du

e to

p

erio

dic

b

ord

er

at n

=0

a

nd

N-1

du

e to

p

erio

dic

b

ord

er

at m

=0

a

nd

M-1

n=

0

m=

0

m=

M-1

n=

N-1

Page 13: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 200 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

MA

TRIX

REPR

ESEN

TATIO

N

This

sectio

n is

from

lectu

re n

ote

s b

y m

y la

te frie

nd

an

d c

olle

ag

ue, P

rofe

ssor S

teve

Pa

rk, o

f the C

olle

ge o

f Willia

m a

nd

Ma

ry, V

irgin

ia

•Com

pa

ct n

ota

tion

•Gen

era

liza

ble

to o

ther tra

nsfo

rms

•D

FT d

efin

ition

let

, wh

ere

WM

is M

x M

, WN is

N x

N

then

,

wh

ich

is th

e fo

rwa

rd tra

nsfo

rm

Fk

l,(

)1MN

---------f

mn,

()

ej

–2π

mk

M -------n

lN -----+

⋅n

0=

N1

∑m

0=

M1

∑=

WM

mk,

()

ej

–2π

mk

M -------

=

WN

nl,

()

ej

–2π

nlN -----

=

Fk

l,(

)1MN

---------W

Mm

k,(

)f

mn,

()W

Nn

l,(

)n

0=

N1

∑m

0=

M1

∑1MN

---------WM

fWN

==

Page 14: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 201 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

•N

ote

tha

t

then

,

, wh

ich

is th

e in

vers

e tra

nsfo

rm

WM *

WM

WM

WM *

MI

M (M

x M identity m

atrix)=

=

WN *

WN

WN W

N *N

IN (N

x N identity m

atrix)=

=

WM *

FW

N *1MN

---------W

M *W

M(

)fW

N WN *

()

=

1MN

---------M

IM

()f

NI

N(

)=

f=

Page 15: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 202 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

Ma

trix D

imen

sio

na

lity D

iag

ram

(M > N

)

•D

iag

ram

for in

vers

e tra

nsfo

rm is

sim

ilar, e

xcep

t no 1

/MN

facto

r

•N

ote

, this

rep

resen

tatio

n is

possib

le b

eca

use th

e 2

-D D

FT k

ern

el is

sep

ara

ble

, i.e.

F

M x

N

=W

M

M x

M

f

M x

N

WNN

x N

1MN

---------

F1MN

---------WM

fWN

=

ej

–2π

mk

M -------n

lN -----+

ej2π

mk

M -------

ej2π

nlN -----

=

Page 16: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 203 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

CA

LCU

LA

TING TH

E 2

-D D

FT

•Ste

p 1

write

ima

ge a

s

wh

ere

f1, f

2, . . . f

N a

re th

e im

ag

e c

olu

mn

s o

f

len

gth

M

then

,

wh

ere

ea

ch

colu

mn

is a

1-D

DFT o

f len

gth

M o

f the im

ag

e c

olu

mn

s

F1MN

---------WM

fWN

=

ff

1f

2 . . .

fN

[]

=

F1N ----

1M -----WM

f1

1M -----WM

f2

. . . 1M -----W

Mf

NW

N=

1N ----F

1F

2 . . .

FN

[]W

N=

Page 17: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 204 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

•Ste

p 2

form

ma

trix tra

nsp

ose

note

, W is

sym

metric

•Ste

p 3

pa

rtition

ima

ge m

atrix

by c

olu

mn

s

, wh

ere

ea

ch

colu

mn

is a

n a

rray o

f len

gth

N

Ft

1N ----WN t

F1 t

F2 t

…FN t

=W

N tW

N=

F1 t

F2 t

…FN t

g1

g2

. . . g

M[

]=

Page 18: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 205 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

then

wh

ere

ea

ch

colu

mn

is a

1-D

DFT o

f len

gth

N

there

fore

•Ste

p 4

tran

sp

ose F

t to g

et F

Ft

1N ----WN g

11N ----W

N g2

. . . 1N ----W

N gN

=

Ft

G1

G2

. . . G

M[

]=

Page 19: 2-D DISCRETE FOURIER TRANSFORMdial/ece533/notes9.pdf2-D DISCRETE FOURIER TRANSFORM f 1-D DFT applied to each column matrix transpose applied to each column matrix transpose F M(Nlog

EC

E/O

PT

I533 Digital Im

age Processing class notes 206 D

r. Robert A

. Schowengerdt 2003

2-D

DIS

CR

ETE

FO

UR

IER

TRA

NSFO

RM

Ca

lcu

latin

g th

e 2

-D D

FT - S

um

ma

ry

f

1-D

DFT

ap

plie

d to

ea

ch

colu

mn

ma

trix

tran

sp

ose

1-D

DFT

ap

plie

d to

ea

ch

colu

mn

ma

trix

tran

sp

ose

F

M 1

-D D

FTs

of le

ng

th N

M(N

log

2N

) op

era

tion

sN

1-D

DFTs

of le

ng

th M

N(M

log

2M

) op

era

tion

s

•N

(Mlo

g2M

) + M

(Nlo

g2N

) = M

Nlo

g2(M

N) to

tal o

pera

tion

s

assu

mes 1

-D F

FT is

used

an

d M

,N a

re p

ow

ers

of 2

•Com

pa

res to

M2N

2 to

tal o

pera

tion

s fo

r “b

rute

forc

e” 2

-D D

FT