2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT....

50
2D Discrete Fourier Transform (DFT)

Transcript of 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT....

Page 1: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D Discrete Fourier Transform (DFT)

Page 2: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Outline

•  Circular and linear convolutions

•  2D DFT

•  2D DCT

•  Properties

•  Other formulations

•  Examples

2

Page 3: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Circular convolution

•  Finite length signals (N0 samples) → circular or periodic convolution –  the summation is over 1 period –  the result is a N0 period sequence

•  The circular convolution is equivalent to the linear convolution of the zero-padded equal length sequences

3

[ ]f m

m *

[ ]g m

m

[ ]* [ ]f m g m

m=

Length=P Length=Q Length=P+Q-1

For the convolution property to hold, M must be greater than or equal to P+Q-1.

[ ]* [ ] [ ] [ ]f m g m F k G k⇔

0 1

0[ ] [ ] [ ] [ ] [ ]

N

nc k f k g k f n g k n

=

= ⊗ = −∑

Page 4: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Convolution

4

•  Zero padding [ ]* [ ] [ ] [ ]f m g m F k G k⇔

[ ]f m

m *

[ ]g m

m

[ ]* [ ]f m g m

m=

[ ]F k

4-point DFT (M=4)

[ ]G k [ ] [ ]F k G k

Page 5: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

In words

•  Given 2 sequences of length N and M, let y[k] be their linear convolution

•  y[k] is also equal to the circular convolution of the two suitably zero padded sequences making them consist of the same number of samples

•  In this way, the linear convolution between two sequences having a different length (filtering) can be computed by the DFT (which rests on the circular convolution)

–  The procedure is the following •  Pad f[n] with Nh-1 zeros and h[n] with Nf-1 zeros •  Find Y[r] as the product of F[r] and H[r] (which are the DFTs of the corresponding zero-padded

signals) •  Find the inverse DFT of Y[r]

•  Allows to perform linear filtering using DFT 5

[ ] [ ] [ ] [ ] [ ]n

y k f k h k f n h k n+∞

=−∞

= ∗ = −∑

0 1

0

0

[ ] [ ] [ ] [ ] [ ]

+ 1: length of the zero-padded seq

N

n

f h

c k f k h k f n h k n

N N N

=

= ⊗ = −

= −

Page 6: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D Discrete Fourier Transform

•  Fourier transform of a 2D signal defined over a discrete finite 2D grid of size MxN

or equivalently

•  Fourier transform of a 2D set of samples forming a bidimensional sequence

•  As in the 1D case, 2D-DFT, though a self-consistent transform, can be considered as a mean of calculating the transform of a 2D sampled signal defined over a discrete grid

•  The signal is periodized along both dimensions and the 2D-DFT can be regarded as a sampled version of the 2D DTFT

6

Page 7: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D Discrete Fourier Transform (2D DFT)

7

•  2D Fourier (discrete time) Transform (DTFT) [Gonzalez]

2 ( )( , ) [ , ] j um vn

m nF u v f m n e π

∞ ∞− +

=−∞ =−∞

= ∑ ∑

1 1 2

0 0

1[ , ] [ , ]k lM N j m nM N

m nF k l f m n e

MNπ ⎛ ⎞− − − +⎜ ⎟⎝ ⎠

= =

= ∑∑

•  2D Discrete Fourier Transform (DFT)

2D DFT can be regarded as a sampled version of 2D DTFT.

a-periodic signal periodic transform

periodized signal periodic and sampled transform

Page 8: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DFT: Periodicity

8

1 1 2

0 0

1[ , ] [ , ]k lM N j m nM N

m nF k l f m n e

MNπ ⎛ ⎞− − − +⎜ ⎟⎝ ⎠

= =

= ∑∑

1 1 2

0 0

1[ , ] [ , ]k M l NM N j m nM N

m nF k M l N f m n e

MNπ

+ +⎛ ⎞− − − +⎜ ⎟⎝ ⎠

= =

+ + = ∑∑1 1 2 2

0 0

1 [ , ]k l M NM N j m n j m nM N M N

m nf m n e e

MNπ π⎛ ⎞ ⎛ ⎞− − − + − +⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

= =

= ∑∑

1

•  A [M,N] point DFT is periodic with period [M,N] –  Proof

[ , ]F k l=

(In what follows: spatial coordinates=k,l, frequency coordinates: u,v)

Page 9: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DFT: Periodicity

•  Periodicity

•  This has important consequences on the implementation and energy compaction property

–  1D

9

[ , ] [ , ] [ , ] [ , ]F u v F u mM v F u v nN F u mM v nN= + = + = + +

[ , ] [ , ] [ , ] [ , ]f k l f k mM l f k l nN f k mM l nN= + = + = + +

F[u]

u M/2 M 0

[ ] [ ]F N u F u∗− =

The two inverted periods meet here f[k] real→F[u] is Hermitian symmetric M/2 samples are enough

Page 10: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Periodicity: 1D

10

F[u]

u M/2 M 0 It is more practical to have one complete period positioned in [0, M-1]

[ ] [ ]f k F u↔

0

0

2

0

2 22

0

[ ]e [ ]

e e e ( 1)2

( 1) [ ] [ ]2

u kj

M

u k Mkj j j k kM M

k

f k F u u

Mu

Mf k F u

π

π π π

↔ −

= → = = = −

− ↔ −

changing the sign of every other sample of the DFT puts F[0] at the center of the interval [0,M]

The two inverted periods meet here

Page 11: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Periodicity in 2D

11

1/M↔128 1/N↔128

I 4 semiperiodi si incontrano ai vertici I 4 semiperiodi si incontrano al centro

Page 12: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Periodicity

12

0,127=1/M,1/N

0,0

0,0

fft2 fftshift(fft2)

Page 13: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Periodicity: 2D

13

DFT periods

MxN values

4 inverted periods meet here

M/2

-M/2

N/2

-N/2

F[u,v]

(0,0)

Page 14: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Periodicity: 2D

14

DFT periods

MxN values

4 inverted periods meet here

M/2

N/2

F[u,v]

(0,0) M-1

N-1 0 02 ( )

0 0

0 0

[ , ]e [ , ]

,2 2

( 1) [ ] ,2 2

u k v lj

M N

k l

f k l F u u v vM Nu v

M Nf k F u v

π +

+

↔ − −

= = →

⎡ ⎤− ↔ − −⎢ ⎥⎣ ⎦

data contain one centered complete period

Page 15: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Angle and phase spectra

15

[ ] [ ] [ ]

[ ] [ ]{ } [ ]{ }

[ ][ ]{ }[ ]{ }

[ ]

,

1/ 22 2

2

, ,

, Re , Im ,

Im ,, arctan

Re ,

[ , ] ,

j u vF u v F u v e

F u v F u v F u v

F u vu v

F u v

P u v F u v

Φ=

⎡ ⎤= +⎣ ⎦

⎡ ⎤Φ = ⎢ ⎥

⎣ ⎦

=

modulus (amplitude spectrum)

phase

power spectrum

For a real function

[ , ] [ , ][ , ] [ , ][ , ] [ , ]

F u v F u vF u v F u vu v u v

∗− − =

− − =

Φ − − = −Φ

conjugate symmetric with respect to the origin

Page 16: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Translation and rotation

16

[ ]

[ ] [ ]

2

2

[ , ] ,

, ,

m nj k lM N

m nj k lM N

f k l e F u m v l

f k m l n F u v

π

π

⎛ ⎞+⎜ ⎟⎝ ⎠

⎛ ⎞− +⎜ ⎟⎝ ⎠

↔ − −

− − ↔

[ ] [ ]0 0

cos cossin sin

, ,

k r ul r lf r F

ϑ ω ϕ

ϑ ω ϕ

ϑ ϑ ω ϕ ϑ

= =⎧ ⎧⎨ ⎨= =⎩ ⎩

+ ↔ +

Rotations in spatial domain correspond equal rotations in Fourier domain

Page 17: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

DFT Properties: (5) Rotation

•  Rotating f(x,y) by θ rotates F(u,v) by θ

Page 18: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

mean value

18

[ ] [ ]1 1

0 0

10,0 ,N M

n mF f n m

NM

− −

= =

= ∑∑ DC coefficient

Page 19: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Separability

•  The discrete two-dimensional Fourier transform of an image array is defined in series form as

•  Inverse transform

•  Because the transform kernels are separable and symmetric, the two dimensional transforms can be computed as sequential row and column one-dimensional transforms.

•  The basis functions of the transform are complex exponentials that may be decomposed into sine and cosine components.

19

1 1 2

0 0

1[ , ] [ , ]k lM N j m nM N

m nF k l f m n e

MNπ ⎛ ⎞− − − +⎜ ⎟⎝ ⎠

= =

= ∑∑

1 1 2

0 0[ , ] [ , ]

k lM N j m nM N

k lf m n F k l e

π ⎛ ⎞− − +⎜ ⎟⎝ ⎠

= =

=∑∑

Page 20: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DFT: summary

20

Page 21: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DFT: summary

21

Page 22: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DFT: summary

22

Page 23: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DFT: summary

23

Page 24: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Magnitude and Phase of DFT

•  What is more important?

Hint: use inverse DFT to reconstruct the image using magnitude or phase only information

magnitude phase

Page 25: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Magnitude and Phase of DFT (cont’d)

Reconstructed image using magnitude only (i.e., magnitude determines the contribution of each component!)

Reconstructed image using phase only (i.e., phase determines which components are present!)

Page 26: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Magnitude and Phase of DFT (cont’d)

Page 27: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Ex. 1

27

Page 28: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Ex. 2

28

Page 29: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Ex. 3

29

Magnitudes

Page 30: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Margherita Hack

30

log amplitude of the spectrum

Page 31: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Einstein

31

log amplitude of the spectrum

Page 32: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Examples

32

Page 33: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

other formulations

Page 34: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D Discrete Fourier Transform

•  Inverse DFT

34

1 1 2

0 0

1[ , ] [ , ]k lM N j m nM N

m nF k l f m n e

MNπ ⎛ ⎞− − − +⎜ ⎟⎝ ⎠

= =

= ∑∑

•  2D Discrete Fourier Transform (DFT)

1 1 2

0 0[ , ] [ , ]

k lM N j m nM N

k lf m n F k l e

π ⎛ ⎞− − +⎜ ⎟⎝ ⎠

= =

=∑∑

where 0,1,..., 1k M= −0,1,..., 1l N= −

Page 35: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D Discrete Fourier Transform

•  Inverse DFT

35

1 1 2

0 0

1[ , ] [ , ]k lM N j m nM N

m nF k l f m n e

MN

π ⎛ ⎞− − − +⎜ ⎟⎝ ⎠

= =

= ∑∑

•  It is also possible to define DFT as follows

1 1 2

0 0

1[ , ] [ , ]k lM N j m nM N

k lf m n F k l e

MN

π ⎛ ⎞− − +⎜ ⎟⎝ ⎠

= =

= ∑∑

where 0,1,..., 1k M= −0,1,..., 1l N= −

Page 36: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D Discrete Fourier Transform

•  Inverse DFT

36

1 1 2

0 0[ , ] [ , ]

k lM N j m nM N

m nF k l f m n e

π ⎛ ⎞− − − +⎜ ⎟⎝ ⎠

= =

=∑∑

•  Or, as follows

1 1 2

0 0

1[ , ] [ , ]k lM N j m nM N

k lf m n F k l e

MNπ ⎛ ⎞− − +⎜ ⎟⎝ ⎠

= =

= ∑∑

where and 0,1,..., 1k M= − 0,1,..., 1l N= −

Page 37: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DFT

•  The discrete two-dimensional Fourier transform of an image array is defined in series form as

•  inverse transform

37

Page 38: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DCT

Discrete Cosine Transform

Page 39: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DCT

•  based on most common form for 1D DCT

39

u,x=0,1,…, N-1

“mean” value

Page 40: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

1D basis functions

40

Cosine basis functions are orthogonal

Figure 1

Page 41: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DCT

•  Corresponding 2D formulation

41

u,v=0,1,…., N-1

direct

inverse

Page 42: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D basis functions

•  The 2-D basis functions can be generated by multiplying the horizontally oriented 1-D basis functions (shown in Figure 1) with vertically oriented set of the same functions.

•  The basis functions for N = 8 are shown in Figure 2. –  The basis functions exhibit a progressive increase in frequency both in the

vertical and horizontal direction. –  The top left basis function assumes a constant value and is referred to as the DC

coefficient.

42

Page 43: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

2D DCT basis functions

43

Figure 2

Page 44: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Separability

44

The inverse of a multi-dimensional DCT is just a separable product of the inverse(s) of the corresponding one-dimensional DCT , e.g. the one-dimensional inverses applied along one dimension at a time

Page 45: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Separability

•  Symmetry –  Another look at the row and column operations reveals that these operations are

functionally identical. Such a transformation is called a symmetric transformation. –  A separable and symmetric transform can be expressed in the form

–  where A is a NxN symmetric transformation matrix which entries a(i,j) are given by

•  This is an extremely useful property since it implies that the transformation matrix can be pre computed offline and then applied to the image thereby providing orders of magnitude improvement in computation efficiency.

45

T AfA=

Page 46: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Computational efficiency

•  Computational efficiency –  Inverse transform

–  DCT basis functions are orthogonal. Thus, the inverse transformation matrix of A is equal to its transpose i.e. A-1= AT.

•  This property renders some reduction in the pre-computation complexity.

46

Page 47: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Block-based implementation

47

The source data (8x8) is transformed to a linear combination of these 64 frequency squares.

Block size N=M=8

Block-based transform

Basis function

Page 48: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Energy compaction

48

Page 49: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Energy compaction

49

Page 50: 2D Discrete Fourier Transform (DFT) · 2D DFT can be regarded as a sampled version of 2D DTFT. a-periodic signal periodic transform periodized signal periodic and sampled transform

Appendix

•  Eulero’s formula

50