50
Linear filtering methods based on the DFT DFT provides a discrete frequency representation of a finite duration sequence in the frequency domain. Computational tool for linear system analysis, especially for linear filtering. DFT can be used to perform linear filtering in the frequency domain.

Linear Filtering Methods Based on the DFT

Embed Size (px)

DESCRIPTION

signal processing

Citation preview

Linear filtering methods based on the DFT

DFT provides a discrete frequency representation of a finite duration sequence in the frequency domain. Computational tool for linear system analysis, especially for linear filtering.DFT can be used to perform linear filtering in the frequency domain.

Linear filtering methods based on the DFT

1.Use of the DFT in Linear Filtering2.Filtering of long data sequence• Overlap-save method• Overlap-add method

Use of the DFT in Linear Filtering

• Our objective is to determine the output of a linear filter to a given input sequence.

• Linear Convolution• By using DFT and IDFT• Circular Convolution

Linear Filter( )h n( )x n

( )y nInput

Output or Response

• A sequence x(n) of length L filtered by an FIR filter h(n) of length M

Example x(n) =[1, 2, 2, 1] , h(n) =[1, 2, 3]L=4,M=3x(n)=[1 ,2,2,1] ,h(n)=[1, 2,3]

The length of sequence y(n) is N=L+M-1=6

y(n)={1,4,9,11,8,3}

Linear Convolution

y n h n x n kk

M( ) ( ) ( )

0

1

DFT and TDFT• Therefore ,a DFT of size N L+M-1 is required

to represent y(n) in the frequency domain.• Using the DFT notation

X(k) and H(k) are the DFT (with zero padding) of x(n) and h(n), respectively.

• Performing the inverse DFT of Y(K)

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

)(()( kYIDFTny

• L=4,M=3,N=L+M-1=6• Eight point DFT of x(n) is• X(K)= {6,1.707 - 4.121j, -1 – j,0.2929 - j0.121, 0,0.292 + j0.121, -1+j,1.707 + j4.121}

• Eight point DFT of h(n) is• H(K)={6,2.414 - j4.414, -2-j2,-0.4142+ j1.585,2,-0.414 -j 1.585,-2+j2,2.414 +

j4.4142}• Y(k)=X(k).H(K)={36,-14.0-j17.48,j4,0.07+j0.515,0,0.07-j0.515,-j4,-14.07+j17.48}

• Eight point IDFT of Y(K) is

Circular Convolution

• Example x(n) =[1, 2, 2, 1] , h(n) =[1, 2, 3]• L=4,M=3• The length of sequence y(n) is N=L+M-1=6• Example x(n)=[1 ,2,2,1,0 ,0] ,h(n)=[1, 2,3,0,0 0]

• y(n)={1,4,9,11,8,3}

Filtering of Long Data Sequences

• In practical applications involving linear filtering of signals, the input sequence x(n) is often a very long sequence.

• Real-time signal processing applications concerned with signal monitoring and analysis.

• Overlap-save method• Overlap-add method

Filtering of Long Data Sequences

• When the DFT is used to implement linear filtering, a signal is processed in blocks. Due to the real-time requirement (low delay) and the limitation of physical memory, the size of the block can not be arbitrarily large.

• The length of the FIR filter is M and the length of on block of data is L (L>M)

• Each time a block of data of length L+M-1 is filtered by using the DFT method.

Overlap-Add Method

x(n)={3,-1,0,1,3,2,0,1,2,1},h(n)={1,1,1}• Overlap-Save Method:• Let L=5,M=3,N=L+M-1=7 x1(n)={0,0,3,-1,0,1}, x3(n)={0,1,2,1,0,0} x2(n)={0,1,3,2,0,1}Perform y1(n)=x1(n) h(n)

y2(n)=x2(n) h(n)

y3(n)=x3(n) h(n)

N

N

N 1

3 1 2 1 2 Nn 0

x (m) x (n) x (n) x (n)x ((n m))

N 1

1 1 1 Nn 0

y (m) x (n) h(n) x (n)h((n m))

N 1

2 2 2 Nn 0

y (m) x (n) h(n) x (n)h((n m))

NN 1

3 3 3 Nn 0

y (m) x (n) h(n) x (n)h((n m))

• y(n)={3,2,2,0,4,6,5,3,3,4,3,1}

x(n)={3,-1,0,1,3,2,0,1,2,1},h(n)={1,1,1}• Overlap-Add Method:• Let L=5,M=3,N=L+M-1=7 x1(n)={3,-1,0,1,0,0}, x3(n)={2,1,0,0,0,0} x2(n)={3,2,0,1,0,0}Perform y1(n)=x1(n) h(n)

y2(n)=x2(n) h(n)

y3(n)=x3(n) h(n)

N

N

N 1

3 1 2 1 2 Nn 0

x (m) x (n) x (n) x (n)x ((n m))

N 1

1 1 1 Nn 0

y (m) x (n) h(n) x (n)h((n m))

N 1

2 2 2 Nn 0

y (m) x (n) h(n) x (n)h((n m))

NN 1

3 3 3 Nn 0

y (m) x (n) h(n) x (n)h((n m))

• y(n)={3,2,2,0,4,6,5,3,3,4,3,1}

• • Properties of DFT Circular Convolution

• Linear Filtering Methods Based on the DFT1.Use of the DFT in Linear Filtering• By using DFT and IDFT• Linear Convolution• Circular Convolution2.Filtering of Long Data Sequence• Overlap-save method• Overlap-add method

DFT IDFTx(n) X(k) x(n)

N 1DFT

3 1 2 1 2 N 3 1 2n 0

x (m) x (n) x (n) x (n)x ((n m)) X (K) X (K)X (K)

DFT IDFTx(n) X(k) H(K) Y(K) X(K).H(K) y(n) H(K)

Fast Fourier Transform• A large amount of work has been devoted to

reducing the computation time of a DFT.• This has led to efficient algorithms which are

known as the Fast Fourier Transform (FFT) algorithms.

• Decimation In Time(DIT) Radix-2 Algorithm• Decimation In Frequency(DIF) Radix-2 Algorithm

Fast Fourier Transform(FFT)

N-Point DFT DFT FFT

N(N-1) complex ‘+’

N2 complex ‘×’ N/2 log2(N) complex ‘×’.

N log2(N) complex ‘+’.

8 56 64 12 24

16 240 256 32 64

32 992 1024 80 160

64 4032 4096 192 384

128 16256 16384 448 896

1

0

2N

n

nkN

jenxkX

))((2

rPhaseFactoortorTwiddleFacWe NN

j

1

0

1

0

1 N

n

nkN

N

n

nkN

WkXN

nx

WnxkX

opertySymmetryWeeeeeW kN

kN

jj

kN

jN

Njk

Nj

Nk

N Pr,22

2

22

2

opertyyPeriodicitWeeeW kN

kN

jN

Njk

NjN

k

N Pr,2

2

2

22

2

2

2

2

2

DIT Radix-2 FFT Algorithm• Let us consider the computation of the N-Point DFT

,r-Radix, m- No.of StagesFirst Step: x[n] = x[0], x[1], …, x[N-1]Split the N-point data sequences into two N/2-pointdata sequences f1(n) and f2(n)Lets divide the sequence x[n] into even and oddLets divide the sequence x[n] into even and oddSequencesSequences

f1(n) =x[2n] = x[0], x[2], …, x[N-2]x[2n] = x[0], x[2], …, x[N-2]

f2(n) =x[2n+1] = x[1], x[3], …, x[N-1]x[2n+1] = x[1], x[3], …, x[N-1]

mN r

1

2,1,0;

Nn

1

2,1,0;

Nn

)1(

1

2

0

12

12

0

2 122

N

n

kn

N

N

n

nk

N WnxWnxkX

10 ;1

0

NkWnxkXN

n

nkN

nkN

kN

knN

nkN

nkN

jnkN

jnk

N

WWW

WeeW

2

12

2

2

22

22

)2(1,0 ;

)()(

122

21

12

0 2

2

12

0 2

1

12

0 2

12

0 2

NkkFWkFkX

WnfWWnf

WnxWWnxkX

k

N

N

n

nk

N

k

N

N

n

nk

N

N

n

nk

N

k

N

N

n

nk

N

N-point DFTN-point DFT

• Where FWhere F11(k) and F(k) and F22(k)(k)

• Since FF11(k+N/2)= F(k+N/2)= F11(k) and F(k) and F22(k+N/2)= F(k+N/2)= F22(k), (k),

N/2-point DFTsN/2-point DFTs

kN

NkN WW 2/

)2.3(12

,0 ;2

)1.3(12

,0 ;

21

21

NkkFWkF

NkX

NkkFWkFkX

k

N

k

N

12

0 2

22

12

0 2

11

)(

)(

N

n

nk

N

N

n

nk

N

WnfkF

WnfkF

Second Step: Split the N/2-point data sequences into two N/4-point sequences

v11(n) =f1(2n) v12(n) =f1(2n+1)--------------- (4.1) v21(n) =f2(2n) v21(n) =f2(2n+1)----------------(4.2)

)5()()(

)12()2(

)(

12

2

11

14

0 4

12

2

14

0 4

11

14

0

)12(

2

1

14

0

2

2

1

12

0 2

11

kVWkVWnvWWnv

WnfWnf

WnfkF

k

N

N

n

nk

N

k

N

N

n

nk

N

N

n

kn

N

N

n

nk

N

N

n

nk

N

1

4,1,0;

Nn

1

4,1,0;

Nn

• Where V11(k),V12(k),V21(k) and V22(k)• N/4 point DFT of the sequences v11(n),v12(n),v21(n) and v22(n)

)1.6(4 12

2

11

1

12

2

111

kVWkVN

kF

kVWkVkF

k

N

k

N

)2.6(4 22

2

21

2

22

2

212

kVWkVN

kF

kVWkVkF

k

N

k

N

14

0 4

2222

14

0 4

2121)(;)(

N

n

nk

N

N

n

nk

NWnvkVWnvkV

14

0 4

1212

14

0 4

1111)(;)(

N

n

nk

N

N

n

nk

NWnvkVWnvkV

)14

(..,,.........1,0; N

k

)14

(..,,.........1,0; N

k

• N=8, - Three Stages• Four 2-point(N/4) DFT’s --->Two 4-point(N/2) DFT’s --->One 8-point (N)DFT

v11(0) = f1(0) = x(0) v11() = f1(2) = x(2) v12(0) = f1(1) = x(4) v12(1) = f1(3) = x(6) v21(0) = f2(0) = x(1) v21() = f2(2) = x(3) v22(0) = f2(1) = x(5) v22(1) = f2(3) = x(7)

3N 2

v11(n) =f1(2n)

v12(n) =f1(2n+1)

v21(n) =f2(2n)

v21(n) =f2(2n+1) ; n=0,1,…(N/4-1)

f1(n) =x[2n] x[2n]

f2(n) =x[2n+1] x[2n+1] ; n=0,1,…(N/2-1)

71111117

50111106

31011015

10011004

61100113

20100102

41000011

00000000

Re

xxxx

xxxx

xxxx

xxxx

xxxx

xxxx

xxxx

xxxx

ofDataShufflingversalBit

• First Stage-Four 2-point(N/4) DFT’s

)7()3(1

)7()3(0

)5()1(1

)5()1(0

)6()2(1

)6()2(0

)4()0()1()0(

)1()0(1;1

)4()0()1()0(

)1()0(0;0

)1()0(

)()()(

0822

0822

0821

0821

0812

0812

08

121111

1)1(211

1)0(21111

0811

0211

0)1(211

0)0(21111

)1(211

)0(211

1

0211

14

8

0 4

811

14

0 4

1111

xWxV

xWxV

xWxV

xWxV

xWxV

xWxV

xWxWvv

WvWvVk

xWxvWv

WvWvVk

WvWv

WnvWnvWnvkV

kk

n

nk

n

nk

N

n

nkN

18

)0(20

8

j

eW

011

V

111

V

012

V

112

V

021

V

121

V

022

V

112

V

Second Stage-Two 4-point(N/2) DFT’s

11113;1

00002;0

11111;1

00000;0

0113;1

002;0

4

8

4

11111;1

00000;0

22

2

82122

1

4212

22

0

82122

0

4212

22

2

82122

1

4212

22

0

82122

0

4212

12

2

81112

1

4111

12

0

81112

0

4111

12

2

811

1

12

2

11

1

12

2

81112

1

4111

12

0

81112

0

4111

12

2

81112

2

111

VWVVWVFk

VWVVWVFk

VWVVWVFk

VWVVWVFk

kVWVVWVFk

kVWVkVWVFk

kVWkVkFkVWkVN

kF

VWVVWVFk

VWVVWVFk

kVWkVkVWkVkF

kk

N

kk

N

01

F

11

F

21

F

31

F

02

F

12

F

22

F

32

F

jeeW

eWjj

j

28

)2(22

8

8

)0(20

81

Third Stage-One 8-point(N) DFT

337;3

226;2

115;1

004;0

2

333;3

222;2

111;1

000;0

2

3

81

2

2

81

2

1

81

2

0

81

21

2

3

81

2

2

81

2

1

81

2

0

81

21

FWFXk

FWFXk

FWFXk

FWFXk

kFWkFN

kX

FWFXk

FWFXk

FWFXk

FWFXk

kFWkFkX

k

N

k

N

707.00707;

707.00707

1

4

3

8

)3(23

8

2

8

48

)1(21

8

8

)0(20

8

jeeWjW

jeeW

eW

jj

jj

j

x(0)x(0)

x(4)x(4)

x(2)x(2)

x(6)x(6)

x(1)x(1)

x(5)x(5)

x(3)x(3)

x(7)x(7)

X(0)X(0)

X(1)X(1)

X(2)X(2)

X(3)X(3)

X(4)X(4)

X(5)X(5)

X(6)X(6)

X(7)X(7)

WW8800

WW8811

WW8822

WW8833

-1-1

WW8800

WW8800

WW8811

WW8811

WW8800

WW8800

WW8800

WW8800

WW8800=1=1

33rdrd stage stage22ndnd stage stage11stst stage stage

-1-1

-1-1

-1-1

-1-1

-1-1

-1-1

-1-1

-1-1

-1-1

-1-1

-1-1

Decimation In Frequency(DIF) Radix-2 Algorithm

• Frequency Domain sequence is decimated• Butterfly Diagram

Decimation In Frequency(DIF) Radix-2 Algorithm

DIT ! DIF

• Time Domain Sequence Frequency Domain decimated Sequence decimated

• Input Sequence is bit Normal order Reversal order• Output sequence is Bit-reversal order Normal order• Phase factor is Multiplied After subtraction Before addition & subtraction

Problems• x(n)={1,-1,-1,-1,1,1,1,-1}

• First Stage

0)1.(11)7()3(1

2)1.(11)7()3(0

21.11)5()1(1

01.11)5()1(0

21.11)6()2(1

01.11)6()2(0

01.11)4()0(1

21.11)4()0()0(

0

822

0

822

0

821

0

821

0

812

0

812

0

811

0

811

xWxV

xWxV

xWxV

xWxV

xWxV

xWxV

xWxV

xWxV

18

)0(20

8

j

eW

011

V

111

V

012

V

112

V

021

V

121

V

022

V

112

V

Second Stage

20).(2113

2)2(10002

20).(2111

2)2.(10000

2)2)((003

20.1202

2)2)((0111

20.12000

22

2

8212

22

0

8212

22

2

8212

22

0

8212

12

2

8111

12

0

8111

12

2

8111

12

0

8111

jVWVF

VWVF

jVWVF

VWVF

jjkVWVF

kVWVF

jjVWVF

VWVF

01

F

11

F

21

F

31

F

02

F

12

F

22

F

32

F

jeeW

eWjj

j

28

)2(22

8

8

)0(20

81

Third Stage

414.34142.1337

22226

585.0414.1115

4004

585.0414.1333

22222

414.3414.1

)2)(707.0707.0(2111

0)2.(12000

2

3

81

2

2

81

2

1

81

2

0

81

2

3

81

2

2

81

2

1

81

2

0

81

jFWFX

jFWFX

jFWFX

FWFX

jFWFX

jFWFX

j

jjFWFX

FWFX

707.00707;

707.00707

1

4

3

8

)3(23

8

2

8

48

)1(21

8

8

)0(20

8

jeeWjW

jeeW

eW

jj

jj

j

Application of FFT Algorithm

• Linear Filtering• Correlation• Spectrum Analysis

Use Of FFT in Linear Filtering• Let h(n).0nM-1,be the sample response of the

FIR filter• x(n)-Input data Sequence

• The block size of the FFT Algorithm is N• N=L+M-1 and L is the number of new data samples

being processed by the filter.• N is a power of 2 .

Linear Filter( )h n( )x n

( )y nInput

Output or Response

3N 2

1. The N-point DFT of h(n),which is padded by L-1 zeros, is denoted as H(K) using either DIT or DIF algorithm

2. The N-point DFT of x(n), is denoted as X(K) using either DIT or DIF algorithm.

3. Multiply X(k) and H(K), Y(k)=X(k).H(K)4. The inverse DFT can be computed by use of an FFT

algorithm• Step 1: Conjugate of Y(K)• Step 2: DFT of Y*(k) using either DIT or DIF radix-2

Algorithm• Step 3:conjugate of result of step 2• Step 4: The result of Step 3 Divided by N, we get y(n).

Nnk

Nn

y n Y k WN

*1*

0

1( ) ( )

Determine the response of LTI system when the input sequence x(n)={-1,1,2,1,-1} by radix-2 DIT FFT. The impulse response of the systems is h(n)={-1,1,1,-1}

• L=5,M=4,N=L+M-1=8• x(n)= {-1,1,2,1,-1,0,0,0} • h(n)={-1,1,1,-1,0,0,0,0}• Determine X(K) using DIT or DIF algorithm• X(K)={ 2,- 3.414j,-4,0.585j,-2,-0.5858j,-4,3.414j• Determine H(K) using DIT or DIF algorithm• H(K)={ 0,-1- 0.414j,0,-1-2.414j,-4,-1+2.414j,0,-1+0.414j}• Y(k)={0,-1.413+3.414j,0,1.412-j0.585,8,1.12+0.585j,0,-1.413-3.414j}• Y*(k)={0,-1.413-3.414j,0,1.412+j0.585,8,1.12-0.585j,0,-1.413+3.414j}• DFT of Y*(k) using Either DIT or DIF• The result of previous step divide by N=8• y(n)={1,-2,0,-1,1,0,2,-1}

Discrete Cosine Transform(DCT)

• Used for Speech and Image compression• Forward DCT

• Inverse DCT

1

0

12 0 1

2

N

n

V(k) x(n)cos n k , k NN

10

0

1 10 1

2 2

N

k

Vx(n) V(k)cos n k , n N

N N