# Discrete Fourier TransformDiscrete Fourier Transform

of 35
/35

Embed Size (px)

### Transcript of Discrete Fourier TransformDiscrete Fourier Transform

Microsoft PowerPoint - DFT.ppt [Compatibility Mode]Nuno Vasconcelos
UCSD

The Discrete-Space Fourier Transform • as in 1D, an important concept in linear system analysis

is that of the Fourier transform • the Discrete-Space Fourier Transform is the 2D

extension of the Discrete-Time Fourier Transform 2211][)( ωω ωω eennxX njnj∑∑ −−

2121

2211

2211

2121221 ),( )2(

],[ ωωωω π

ddeeXnnx ∫∫=

q y – inconvenient to evaluate numerically in DSP hardware – we need a discrete version

this is the 2D Discrete Fourier Transform (2D DFT)

2

• before that we consider the sampling problem

Sampling in 2D

• consider an analog signal xc(t1,t2) and let its analog Fourier transform be X (1 2)Fourier transform be Xc(1,2) – we use capital to emphasize that this is analog frequency

• sample with period (T1,T2) to obtain a discrete-space signal

222111 ;2121 ),(],[ TntTntc ttxnnx

Sampling in 2D

∑ ∑ ∞ ∞

−∞= −∞= 1 2 2121 r r TTTT

“discrete spectrum” “analog spectrum”

• Discrete Space spectrum is sum of replicas of analog• Discrete Space spectrum is sum of replicas of analog spectrum – in the “base replica” the analog frequency 1 (2) is mapped

i t th di it l f T ( T ) 4

into the digital frequency 1T1 (2T2) – discrete spectrum has periodicity (2π,2π)

For example 2

ω1

2π⇔

is the critical sampling frequency

• below it we have aliasing

ω2

aliasing

ω1

• this is just like the 1D case, but now there are morenow there are more possibilities for overlap

6

Reconstruction • if there is no aliasing we can recover the signal in a way

similar to the 1D case

( ) ( ) ∑ ∑ ∞ ∞

−− =

( ) ( ) ∑ ∑ −∞= −∞= −−1 2

222 2

111 1

ππ

• note: in 2D there are many more possibilities than in 1D – e.g. the sampling grid does not have to be rectangular, e.g.

hexagonal sampling when T2 = T1/sqrt(3) and

= ==

21 ,),(

7– in practice, however, one usually adopts the rectangular grid

• a sequence of images obtained by down- sampling without any filteringg

• aliasing: the low- frequency parts are

li t d th h t th 8

replicated throughout the low-res image

The role of smoothing

l ta lot

9 • too little leads to aliasing • too much leads to loss of information

Aliasing in video • video frames are the result of temporal sampling

– fast moving objects are above the critical frequency – above a certain speed they are aliased and appear to move

backwards – this was common in old western movies and become known as

the “wagon wheel” effect – here is an example: super-resolution increases the frame rate

and eliminates aliasing

from “Space-Time Resolution in Video” by y E. Shechtman, Y. Caspi and M. Irani

(PAMI 2005).

10

2D-DFT • the 2D-DFT is obtained by sampling the DSFT at regular

frequency intervals

2 2

21 1

1 2,22121 ),(],[

k N

k N

== =

• this turns out to make the 2D-DFT somewhat harder to work with than the DSFT

it i th i 1D– it is the same as in 1D – you might remember that the inverse transform of the product of

two DFTs is not the convolution of the associated signals – but, instead, the “circular convolution” – where does this come from?

• it is better understood by first considering the 2D

11

it is better understood by first considering the 2D Discrete Fourier Series (2D-DFS)

[ ] [ ] [ ]

−−= 1 2

21 212121 ],[),(

n n

jnjn rrnnxrrX

• makes no sense for a periodic signal – the sum will be infinite for any pair r1,r2

ith th 2D DSFT th Z t f ill k h

12

– neither the 2D DSFT or the Z-transform will work here

2D-DFS • the 2D-DFS solves this problem • it is based on the observation that

– any periodic sequence can be represented as a weighted sum of complex exponentials of the form

22 2211 nkjnkj ππ

10 22 ≤≤ Nk

22 kk ππ

is an orthonormal basis of the space of periodic sequences

10 ,10 , 2211

– is an orthonormal basis of the space of periodic sequences

2D-DFS • the 2D-DFS relates x[n1,n2] and X[k1,k2]

( ) [ ] 22111 2 221 1 nkjnkjN N ππ

−−− −

1010 ≤≤≤≤ NkNk • like the DSFT,

properties of the 2D DFS are identical to those of the 1D DFS

10 ,10 2211 −≤≤−≤≤ NkNk

14

– properties of the 2D-DFS are identical to those of the 1D-DFS – with the straightforward extension of separability

Periodic convolution • like the Fourier transform,

– the inverse transform of multiplication is convolution

[ ] [ ] ( ) ( )2121

×↔∗

– however, we have to be careful about how we define convolution – since the sequences have no end, the standard definition

],[],[],[ 22112121 1 2

knknhkkxnny k k

−−= ∑ ∑ ∞

−∞=

∞

−∞=

makes no sense – e.g. if x and h are both positive sequences, this will allways be

infinite

15

infinite

Periodic convolution • to deal with this, we introduce the idea of periodic

convolution • instead of the regular definition

],[],[* 221121 knknhkkxyx −−= ∑ ∑ ∞ ∞

• which, from now on, we refer to as linear convolution

],[],[ 221121 1 2

y k k ∑ ∑

1 11 2N N− −

],[ ],[ 2211

1

0

1

• the only difference is in the summation limits

Periodic convolution • this is simple, but produces a convolution which is

substantially different • let’s go back to our example, now assuming that the

sequences have period (N1=3,N2=2) n2 n2

(1) (2)* (3) (4)

• as before we need four steps ],[ 21 nnx ],[ 21 nnh

17

• as before, we need four steps

Periodic convolution • step 1): express sequences in terms of (k1, k2), and

consider one period only

],[ 21 kkx ],[ 21 kkh

Periodic convolution • step 2): invert h(k1, k2)

1 11 2N N− −

19

Periodic convolution • step 3): shift g(k1, k2) by (n1, n2)

1 11 2N N− −

k1

k2k2

k

(3)(4)

n1

k1

th t t ld b t i t i lti l th t

],[ 21 kkx ],[

=−−

the next step would be to point-wise multiply the two signals and sum

][][ 1 11 2

kkhkkh N N

o

Periodic convolution • this is where we depart from linear convolution • remember that the sequences are periodic, and we really

only care about what happens in the fundamental periodonly care about what happens in the fundamental period • we use the periodicity to fill the values missing in the

flipped sequence k2

22

Periodic convolution • step 4): we can finally point-wise multiply the two signals

and sum

3x1+1x1=4

],[ 21 kkx ],[ 21 nny],[ 2211

Periodic convolution • note: the sequence that results from the convolution is

also periodic • it is important to keep in mind what we have done• it is important to keep in mind what we have done

– we work with a single period (the fundamental period) to make things manageable b t b th t h i di– but remember that we have periodic sequences

– it is like if we were peeking through a window – if we shift, or flip the sequence we need to remember that – the sequence does not simply move out of the window, but the

next period walks in!!! – note, that this

k2 k2

24

Discrete Fourier Transform • all of this is interesting,

– but why do I care about periodic sequences? – all images are finite, I could never have such a sequence

• while this is true – the DFS is the easiest route to learn about the discrete Fourierthe DFS is the easiest route to learn about the discrete Fourier

transform (DFT)

• recall that the DFT is obtained by sampling the DSFT

2 2

21 1

1 2,22121 ),(],[

k N

k N

== =

– we know that when we sample in space we have aliasing in frequency

– well, the same happens when we sample in frequency: we get

25

Discrete Fourier Transform • this means that

– even if we have a finite sequence – when we compute the DFT we are effectively working with a

periodic sequence

• you may recall from 1D signal processing thaty y g p g – when you multiply two DFTs, you do not get convolution in time – but instead something called circular convolution

this is strange: when I flip a signal (e g convolution) it wraps– this is strange: when I flip a signal (e.g. convolution) it wraps around the sequence borders

– well, in 2D it gets much stranger

th l I k h t d t d thi i t• the only way I know how to understand this is to – think about the underlying periodic sequence – establish a connection between the DFT and the DFS of that

26

sequence – use what we have seen for the DFS to help me out with the DFT

Discrete Fourier Transform • let’s start by the relation between DFT and DFS • the DFT is defined as

2 2

21 1

1 2,22121 ),(],[

k N

k N

[ ] <≤ ∑∑

22111 2 ππ

[ ] <≤ ∑∑

22111 2 ππ

jnk N

jN N

kkX ππ

110 Nk <≤ 110 Nn <≤

11

<≤ Nn0 1 11

29

[ ] [ ] [ ]212121 ,,, 21

kkRkkXkkX NN ×=

that working in the DFT domain is equivalent to – working in the DFS domain

[ ] [ ] [ ]212121 21 NN [ ] [ ] [ ]212121 21 NN

– extracting the fundamental period at the end

• we can summarize this as

[ ] [ ] [ ] [ ]2121

2121 ,

↔← →

• in this way, I can work with the DFT without having to worry about aliasing

eperiodiciztruncate

30

↔ →

• this trick can be used to derive all the DFT properties

[ ] [ ] [ ] [ ]21212121 ,,,, kkXkkXnnxnnx eperiodiciztruncate

←↔←

• e.g. what is the inverse transform of a phase shift? – let’s follow the steps

22 kk ππ

– 1) periodicize: this causes the same phase shift in the DFS

[ ] [ ] 22 2

11 1

← →

↔← →

– 2) compute the inverse DFS: it follows from the properties of the DFS (page 142 on Lim) that we get a shift in space

eperiodiciztruncate ←←

DFS (page 142 on Lim) that we get a shift in space

[ ] [ ]221121 ,, mnmnxnny −−=

[ ] [ ] [ ]

– in summary, the new sequence is obtained by making the

[ ] [ ] [ ]21221121 ,,, 21

nnRmnmnxnny NN ×−−=

32

y q y g original periodic, shifting, and taking the fundamental period

Example k2 k2

33

• note that what leaves on one end, enters on the other

Example • for this reason it is called a circular shift

k2

k1

• note that this is way more complicated than in 1D • to get it right we really have to think in terms of the

i di t i f thperiodic extension of the sequence • we will see that this shows up in the properties of the

DFT,

34

35

The Discrete-Space Fourier Transform • as in 1D, an important concept in linear system analysis

is that of the Fourier transform • the Discrete-Space Fourier Transform is the 2D

extension of the Discrete-Time Fourier Transform 2211][)( ωω ωω eennxX njnj∑∑ −−

2121

2211

2211

2121221 ),( )2(

],[ ωωωω π

ddeeXnnx ∫∫=

q y – inconvenient to evaluate numerically in DSP hardware – we need a discrete version

this is the 2D Discrete Fourier Transform (2D DFT)

2

• before that we consider the sampling problem

Sampling in 2D

• consider an analog signal xc(t1,t2) and let its analog Fourier transform be X (1 2)Fourier transform be Xc(1,2) – we use capital to emphasize that this is analog frequency

• sample with period (T1,T2) to obtain a discrete-space signal

222111 ;2121 ),(],[ TntTntc ttxnnx

Sampling in 2D

∑ ∑ ∞ ∞

−∞= −∞= 1 2 2121 r r TTTT

“discrete spectrum” “analog spectrum”

• Discrete Space spectrum is sum of replicas of analog• Discrete Space spectrum is sum of replicas of analog spectrum – in the “base replica” the analog frequency 1 (2) is mapped

i t th di it l f T ( T ) 4

into the digital frequency 1T1 (2T2) – discrete spectrum has periodicity (2π,2π)

For example 2

ω1

2π⇔

is the critical sampling frequency

• below it we have aliasing

ω2

aliasing

ω1

• this is just like the 1D case, but now there are morenow there are more possibilities for overlap

6

Reconstruction • if there is no aliasing we can recover the signal in a way

similar to the 1D case

( ) ( ) ∑ ∑ ∞ ∞

−− =

( ) ( ) ∑ ∑ −∞= −∞= −−1 2

222 2

111 1

ππ

• note: in 2D there are many more possibilities than in 1D – e.g. the sampling grid does not have to be rectangular, e.g.

hexagonal sampling when T2 = T1/sqrt(3) and

= ==

21 ,),(

7– in practice, however, one usually adopts the rectangular grid

• a sequence of images obtained by down- sampling without any filteringg

• aliasing: the low- frequency parts are

li t d th h t th 8

replicated throughout the low-res image

The role of smoothing

l ta lot

9 • too little leads to aliasing • too much leads to loss of information

Aliasing in video • video frames are the result of temporal sampling

– fast moving objects are above the critical frequency – above a certain speed they are aliased and appear to move

backwards – this was common in old western movies and become known as

the “wagon wheel” effect – here is an example: super-resolution increases the frame rate

and eliminates aliasing

from “Space-Time Resolution in Video” by y E. Shechtman, Y. Caspi and M. Irani

(PAMI 2005).

10

2D-DFT • the 2D-DFT is obtained by sampling the DSFT at regular

frequency intervals

2 2

21 1

1 2,22121 ),(],[

k N

k N

== =

• this turns out to make the 2D-DFT somewhat harder to work with than the DSFT

it i th i 1D– it is the same as in 1D – you might remember that the inverse transform of the product of

two DFTs is not the convolution of the associated signals – but, instead, the “circular convolution” – where does this come from?

• it is better understood by first considering the 2D

11

it is better understood by first considering the 2D Discrete Fourier Series (2D-DFS)

[ ] [ ] [ ]

−−= 1 2

21 212121 ],[),(

n n

jnjn rrnnxrrX

• makes no sense for a periodic signal – the sum will be infinite for any pair r1,r2

ith th 2D DSFT th Z t f ill k h

12

– neither the 2D DSFT or the Z-transform will work here

2D-DFS • the 2D-DFS solves this problem • it is based on the observation that

– any periodic sequence can be represented as a weighted sum of complex exponentials of the form

22 2211 nkjnkj ππ

10 22 ≤≤ Nk

22 kk ππ

is an orthonormal basis of the space of periodic sequences

10 ,10 , 2211

– is an orthonormal basis of the space of periodic sequences

2D-DFS • the 2D-DFS relates x[n1,n2] and X[k1,k2]

( ) [ ] 22111 2 221 1 nkjnkjN N ππ

−−− −

1010 ≤≤≤≤ NkNk • like the DSFT,

properties of the 2D DFS are identical to those of the 1D DFS

10 ,10 2211 −≤≤−≤≤ NkNk

14

– properties of the 2D-DFS are identical to those of the 1D-DFS – with the straightforward extension of separability

Periodic convolution • like the Fourier transform,

– the inverse transform of multiplication is convolution

[ ] [ ] ( ) ( )2121

×↔∗

– however, we have to be careful about how we define convolution – since the sequences have no end, the standard definition

],[],[],[ 22112121 1 2

knknhkkxnny k k

−−= ∑ ∑ ∞

−∞=

∞

−∞=

makes no sense – e.g. if x and h are both positive sequences, this will allways be

infinite

15

infinite

Periodic convolution • to deal with this, we introduce the idea of periodic

convolution • instead of the regular definition

],[],[* 221121 knknhkkxyx −−= ∑ ∑ ∞ ∞

• which, from now on, we refer to as linear convolution

],[],[ 221121 1 2

y k k ∑ ∑

1 11 2N N− −

],[ ],[ 2211

1

0

1

• the only difference is in the summation limits

Periodic convolution • this is simple, but produces a convolution which is

substantially different • let’s go back to our example, now assuming that the

sequences have period (N1=3,N2=2) n2 n2

(1) (2)* (3) (4)

• as before we need four steps ],[ 21 nnx ],[ 21 nnh

17

• as before, we need four steps

Periodic convolution • step 1): express sequences in terms of (k1, k2), and

consider one period only

],[ 21 kkx ],[ 21 kkh

Periodic convolution • step 2): invert h(k1, k2)

1 11 2N N− −

19

Periodic convolution • step 3): shift g(k1, k2) by (n1, n2)

1 11 2N N− −

k1

k2k2

k

(3)(4)

n1

k1

th t t ld b t i t i lti l th t

],[ 21 kkx ],[

=−−

the next step would be to point-wise multiply the two signals and sum

][][ 1 11 2

kkhkkh N N

o

Periodic convolution • this is where we depart from linear convolution • remember that the sequences are periodic, and we really

only care about what happens in the fundamental periodonly care about what happens in the fundamental period • we use the periodicity to fill the values missing in the

flipped sequence k2

22

Periodic convolution • step 4): we can finally point-wise multiply the two signals

and sum

3x1+1x1=4

],[ 21 kkx ],[ 21 nny],[ 2211

Periodic convolution • note: the sequence that results from the convolution is

also periodic • it is important to keep in mind what we have done• it is important to keep in mind what we have done

– we work with a single period (the fundamental period) to make things manageable b t b th t h i di– but remember that we have periodic sequences

– it is like if we were peeking through a window – if we shift, or flip the sequence we need to remember that – the sequence does not simply move out of the window, but the

next period walks in!!! – note, that this

k2 k2

24

Discrete Fourier Transform • all of this is interesting,

– but why do I care about periodic sequences? – all images are finite, I could never have such a sequence

• while this is true – the DFS is the easiest route to learn about the discrete Fourierthe DFS is the easiest route to learn about the discrete Fourier

transform (DFT)

• recall that the DFT is obtained by sampling the DSFT

2 2

21 1

1 2,22121 ),(],[

k N

k N

== =

– we know that when we sample in space we have aliasing in frequency

– well, the same happens when we sample in frequency: we get

25

Discrete Fourier Transform • this means that

– even if we have a finite sequence – when we compute the DFT we are effectively working with a

periodic sequence

• you may recall from 1D signal processing thaty y g p g – when you multiply two DFTs, you do not get convolution in time – but instead something called circular convolution

this is strange: when I flip a signal (e g convolution) it wraps– this is strange: when I flip a signal (e.g. convolution) it wraps around the sequence borders

– well, in 2D it gets much stranger

th l I k h t d t d thi i t• the only way I know how to understand this is to – think about the underlying periodic sequence – establish a connection between the DFT and the DFS of that

26

sequence – use what we have seen for the DFS to help me out with the DFT

Discrete Fourier Transform • let’s start by the relation between DFT and DFS • the DFT is defined as

2 2

21 1

1 2,22121 ),(],[

k N

k N

[ ] <≤ ∑∑

22111 2 ππ

[ ] <≤ ∑∑

22111 2 ππ

jnk N

jN N

kkX ππ

110 Nk <≤ 110 Nn <≤

11

<≤ Nn0 1 11

29

[ ] [ ] [ ]212121 ,,, 21

kkRkkXkkX NN ×=

that working in the DFT domain is equivalent to – working in the DFS domain

[ ] [ ] [ ]212121 21 NN [ ] [ ] [ ]212121 21 NN

– extracting the fundamental period at the end

• we can summarize this as

[ ] [ ] [ ] [ ]2121

2121 ,

↔← →

• in this way, I can work with the DFT without having to worry about aliasing

eperiodiciztruncate

30

↔ →

• this trick can be used to derive all the DFT properties

[ ] [ ] [ ] [ ]21212121 ,,,, kkXkkXnnxnnx eperiodiciztruncate

←↔←

• e.g. what is the inverse transform of a phase shift? – let’s follow the steps

22 kk ππ

– 1) periodicize: this causes the same phase shift in the DFS

[ ] [ ] 22 2

11 1

← →

↔← →

– 2) compute the inverse DFS: it follows from the properties of the DFS (page 142 on Lim) that we get a shift in space

eperiodiciztruncate ←←

DFS (page 142 on Lim) that we get a shift in space

[ ] [ ]221121 ,, mnmnxnny −−=

[ ] [ ] [ ]

– in summary, the new sequence is obtained by making the

[ ] [ ] [ ]21221121 ,,, 21

nnRmnmnxnny NN ×−−=

32

y q y g original periodic, shifting, and taking the fundamental period

Example k2 k2

33

• note that what leaves on one end, enters on the other

Example • for this reason it is called a circular shift

k2

k1

• note that this is way more complicated than in 1D • to get it right we really have to think in terms of the

i di t i f thperiodic extension of the sequence • we will see that this shows up in the properties of the

DFT,

34

35