lec dft fft

39
Dr. Shoab Khan Digital Signal Processing Lecture

Upload: syed-abdullah-hasan-chishti

Post on 02-Dec-2015

262 views

Category:

Documents


5 download

DESCRIPTION

discrete time Fourier transform

TRANSCRIPT

Page 1: lec DFT FFT

Dr. Shoab Khan

Digital Signal Processing

Lecture

Page 2: lec DFT FFT

Discrete-Time Fourier Series

Page 3: lec DFT FFT

The conventional (continuous-time) FS represent a periodic signal using an infinite number of complex exponentials, whereas the DFS represent such a signal using a finite number of complex exponentials

Page 4: lec DFT FFT

Example 2 DFS of an periodic rectangular pulse train

The DFS coefficients

10/ksin

2/ksine

e1

e1ekX

~ 10/k4j

k10/2j

5k10/2j4

0n

kn10/2j

Page 5: lec DFT FFT

Properties of DFS Linearity

Shift of a Sequence

Duality

kX~

bkX~

anx~bnx~a

kX~

nx~kX

~nx~

21DFS

21

2DFS

2

1DFS

1

mkX~

nx~e

kX~

emnx~kX

~nx~

DFSN/nm2j

N/km2jDFS

DFS

kx~NnX

~kX

~nx~

DFS

DFS

Page 6: lec DFT FFT

Periodic Convolution Take two periodic sequences

Let’s form the product

The periodic sequence with given DFS can be written as

Periodic convolution is commutative

kX

~nx~

kX~

nx~

2DFS

2

1DFS

1

kX~

kX~

kX~

213

1N

0m213 mnx~mx~nx~

1N

0m123 mnx~mx~nx~

Page 7: lec DFT FFT

Graphical Periodic Convolution

Page 8: lec DFT FFT

DTFT to DFT

Page 9: lec DFT FFT

Sampling the Fourier Transform Consider an aperiodic sequence with a Fourier transform

Assume that a sequence is obtained by sampling the DTFT

Since the DTFT is periodic resulting sequence is also periodic

We can also write it in terms of the z-transform

The sampling points are shown in figure

could be the DFS of a sequence

Write the corresponding sequence

kN/2j

kN/2

j eXeXkX~

jDTFT eX]n[x

kN/2j

ezeXzXkX

~kN/2

kX~

1N

0k

knN/2jekX~

N

1]n[x~

Page 10: lec DFT FFT

DFT Analysis and Synthesis

Page 11: lec DFT FFT

DFT is Periodic with period N

Page 12: lec DFT FFT

Properties of DFT Linearity

Duality

Circular Shift of a Sequence

kbXkaXnbxnax

kXnx

kXnx

21DFT

21

2DFT

2

1DFT

1

mN/k2jDFT

N

DFT

ekX1-Nn0 mnx

kXnx

N

DFT

DFT

kNxnX

kXnx

Page 13: lec DFT FFT

DFT Properties

Page 14: lec DFT FFT

Example: Circular Shift

Page 15: lec DFT FFT

Example: Circular Shift

Page 16: lec DFT FFT

Example: Circular Shift

Page 17: lec DFT FFT

Duality

Page 18: lec DFT FFT

Circular Flip

Page 19: lec DFT FFT

Properties: Circular Convolution

Page 20: lec DFT FFT

Example: Circular Convolution

Page 21: lec DFT FFT

Example: Circular Convolution

Page 22: lec DFT FFT

illustration of the circular convolution process

Example (continued)

Page 23: lec DFT FFT

Illustration of circular convolution for N = 8:

Page 24: lec DFT FFT

03/17/2011 CS267 Lecture 18

Using the 2D FFT for image compression

° Image = 200x320 matrix of values

° Compress by keeping largest 2.5% of FFT components

° Similar idea used by jpeg

Page 25: lec DFT FFT

void dft(complex_float* in, complex_float* out, int N, int inv)

{

int i, j;

float a, f;

complex_float s, w;

f = inv ? 1.0/N : 1.0;

for (i = 0; i < N; i++) {

s.re = 0;

s.im = 0;

for (j = 0; j < N; j++) {

a = -2*PI*i*j/N;

if (inv) a = -a;

w.re = cos(a);

w.im = sin(a);

s.re += in[j].re * w.re - in[j].im * w.im;

s.im += in[j].im * w.re + in[j].re * w.im;

}

out[i].re = s.re*f;

out[i].im = s.im*f;

}

Page 26: lec DFT FFT

DFT & IDFT

Page 27: lec DFT FFT

DFT Properties

Page 28: lec DFT FFT

Circular Convolution

Page 29: lec DFT FFT

Filtering of Long Data Sequences

The input signal x(n) is often very long especially in real-time signal processing applications.

For linear filtering via the DFT, for example, the signal must be limited size due to memory requirements

Page 30: lec DFT FFT

Filtering of Long Data Sequences

Segment the input signal into fixed-size blocks prior to processing.

Compute DFT-based linear filtering of each block separately via the FFT.

Fit the output blocks together in such a way that the overall output is equivalent to the linear filtering of x(n) directly.

Main advantage: samples of the output y(n) = h(n) ⊗ x(n) will be available real-time on a block-by-block basis.

Page 31: lec DFT FFT

Filtering of Long Data Sequences

Goal: FIR filtering: y(n) = x(n) * h(n)

Two approaches to real-time linear filtering of long inputs:

Overlap-Add Method

Overlap-Save Method

Assumptions:

FIR filter h(n) length = P

Block length = L ≫ P

Page 32: lec DFT FFT

For example, consider two sequences h[n] and x[n] as follows.

Page 33: lec DFT FFT

Segmenting x[n]

into L-length

sequences. Each

segment is padded

by P1 zero values.

Fir filtering by

using the

overlapping-add

method.

Page 34: lec DFT FFT
Page 35: lec DFT FFT

Overlap-Add Method

1. Break the input signal x(n) into non-overlapping blocks xm(n) of length L.

2. Zero pad h(n) to be of length N = L + M -1

3. Take N-DFT of h(n) to give H(k), k = 0; 1, …,N-1

4. For each block m:

1. Zero pad xm(n) to be of length N = L + M-1

2. Take N-DFT of xm(n) to give Xm(k), k = 0,1,…,N-1

3. Multiply: Ym(k) = Xm(k)H(k), k = 0,1,…,N -1

4. Take N-IDFT of Ym(k) to give ym(n), n = 0,1,…,N-1

5. Form y(n) by overlapping the last M-1 samples of ym(n) with the first M -1 samples of ym+1(n) and adding the result

Page 36: lec DFT FFT

Example of overlapping-save method

Decompose x[n] into overlapping sections

of length L

Page 37: lec DFT FFT

Example of overlapping-save method (continue)

Result of circularly convolving each section with h[n]. The portions

of each filter section to be discarded in forming the linear convolution

are indicated

Page 38: lec DFT FFT

Overlap-Save Method

Page 39: lec DFT FFT

Overlap-Save Method

Using DFT for Circular Convolution

N = L + M -1

Let xm(n) have support n = 01,2,…,N -1

Let h(n) have support n = 01,2,…,M-1

We zero pad h(n) to have support n = 01,2,…,N-1

1. Take N-DFT of xm(n) to give Xm(k), k = 0,1,2,….,N-1

2. Take N-DFT of h(n) to give H(k), k = 0,1,2,….,N-1

3. Multiply: Ym(k) = Xm(k) H(k), k = 0,1,2,….,N-1

4. Take N-IDFT of Ym(k) to give yC,m(n), n = 01,2,…,N-1