# Bài giảng Xử lý tín hiệu số: Chapter 4 - Hà Hoàng Kha

Chapter
p 4
FIR filtering and Convolution
Ha Hoang Kha, Ph.D.Click to edit Master subtitle style
Ho Chi Minh City University of Technology
@
Email: hhkha@hcmut.edu.vn

CuuDuongThanCong.com

https://fb.com/tailieudientucntt

Content
 Block p
processingg methods
 Convolution: direct form, convolution table
 Convolution: LTI form,, LTI table
 Matrix form
 Flip-and-slide form

 Sample processing methods
 FIR filtering in direct form

Ha H. Kha

2
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Introduction
 Block processing methods: data are collected and processed in blocks.
 FIR filtering of finite
finite-duration
duration signals by convolution
 Fast convolution of long signals which are broken up in short segments
 DFT/FFT spectrum computations
 Speech analysis and synthesis
 Image processing

 Sample processing methods: the data are processed one at a timewith each input sample being subject to a DSP algorithm which
transforms it into an output sample.
 Real-time applications
 Digitall audio
d effects
ff
processing
 Digital control systems
Ha H. Kha

3
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

1. Block Processing method
 The collected signal samples x(n), n=0, 1,…, L-1, can be thought as a
block:
x=[x
[ 0, x1, …, xL-1]

The duration of the data record in second: TL=LT
 Consider a casual FIR filter of order M with impulse response:
h=[h0, h1, …, hM]
The length (the number of filter coefficients): Lh=M+1
Ha H. Kha

4
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

11.1.

Direct form

 The convolution in the direct form:
y ( n) = ∑ h( m) x ( n − m)
m

 For DSP implementation,
p
, we must determine
 The range of values of the output index n
 The precise range of summation in m

 Find index n:

index of h(m)
Æ
0≤m≤M
index of x(n-m)
x(n m) Æ 0≤n-m≤L-1
0≤n m≤L 1
Æ 0 ≤ m ≤ n ≤m+L-1 ≤ M+L-1

0 ≤ n ≤ M + L −1
 Lx=L input samples which is processed by the filter with order M
M=L
Lx + M
yield the output signal y(n) of length L y = L + M
Ha H. Kha

5
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

1Direct

form

 Find index m:
index of x(n-m)
(
)

index of h(m)
Æ
0≤m≤M
Æ 0≤n-m≤L-1 Æ n+L-1≤ m ≤ n

max ( 0, n − L + 1) ≤ m ≤ min ( M, n )

 The direct form of convolution is given as follows:
y ( n) =

min( M , n )

h( m) x ( n − m) = h ∗ x

m = max(0,
(0 n − L +1)

with 0 ≤ n ≤ M + L − 1

 Thus,, y is longer
g than the input
p x byy M samples.
p This property
p p y
follows from the fact that a filter of order M has memory M and
keeps each input sample inside it for M time units.
Ha H. Kha

6
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example
 Consider the case of an order-3 filter and a length of 5-input signal.
Find the output
o tp t ?
h=[h0, h1, h2, h3]
x=[x0, x1, x2, x3, x4 ]
yy=h*x=[y
h x [y0, y1, y2, y3, y4 , y5, y6, y7 ]

Ha H. Kha

7
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

1.2. Convolution table
 It can be observed that

y ( n) =

∑ h(i) x( j )
i, j

i+ j =n

 Convolution table
 The convolution
table is convenient
for quick calculation
b h
by
hand
d because
b
iit
displays all required
operations
compactly.

Ha H. Kha

8
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example
 Calculate the convolution of the following filter and input signals?
h=[1, 2, -1, 1],

x=[1, 1, 2, 1, 2, 2, 1, 1]

 Solution:
S l i

sum of the values along anti-diagonal line yields the output y:
y=[1,
=[1 3,
3 3,
3 5,
5 3,
3 7,
7 4,
4 3,
3 3,
3 0,
0 1]
Note that there are Ly=L+M=8+3=11 output samples.
Ha H. Kha

9
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

1.3. LTI Form
 LTI form of convolution:

y ( n ) = ∑ x ( m) h ( n − m)
m

 Consider the filter h=[h0, h1, h2, h3] and the input signal x=[x0, x1, x2,
x3, x4 ]. Then, the output is given by
y (n) = x0 h(n) + x1h(n − 1) + x2 h(n − 2) + x3 h(n − 3) + x4 h(n − 4)

 We can represent the input and output signals as blocks:

Ha H. Kha

10
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

1.3. LTI Form
 LTI form of convolution:

 LTI form of convolution provides a more intuitive way to under
stand the linearity and time-invariance
time invariance properties of the filter.
filter
Ha H. Kha

11
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example
 Using the LTI form to calculate the convolution of the following
filter and inp
inputt signals?
h=[1, 2, -1, 1],

x=[1, 1, 2, 1, 2, 2, 1, 1]

 Solution:
S l i

Ha H. Kha

12
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

1.3. Matrix Form
 Based on the convolution equations
we can write y = Hx
 x is the column vector of the Lx input
p samples.
p
 y is the column vector of the Ly =Lx+M put samples.
 H is a rectangular matrix with dimensions (Lx+M)xLx .

Ha H. Kha

13
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

1.3. Matrix Form

 It can be
b observed
b
d th
thatt H has
h th
the same entry
t along
l
each
h diagonal.
di
l
Such a matrix is known as Toeplitz matrix.
 Matrix representations of convolution are very useful in some
applications:
 Image processing
filtering

Ha H. Kha

14
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example
 Using the matrix form to calculate the convolution of the following
filter and input signals?
h=[1, 2, -1, 1],
x=[1, 1, 2, 1, 2, 2, 1, 1]
 Solution: since Lx=8, M=3 Æ Ly=Lx+M=11, the filter matrix is
11x8 dimensional

Ha H. Kha

15
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

1.4. Flip-and-slide form
 The output at time n is given by
yn = h0 xn + h1 xn −1 + ... + hM xn − M

 Flip-and-slide
li
d lid fform off convolution
l i

 The flip-and-slide form shows clearly the input-on and input-off
steady state behavior of a filter.
Ha H. Kha

16
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

M

 From LTI convolution: y(n) = ∑h(m)x(n − m) = h0 xn + h1xn−1 + ... + hM xn−M
m=0

 The output is divided into 3 subranges:

 Transient
T
d
fil outputs:
filter

Ha H. Kha

17
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

 As the input signal is infinite or extremely large, a practical approach
is to divide the longg input
p into contiguous
g
non-overlapping
pp g blocks of
manageable length, say L samples.
 Overlap

Ha H. Kha

18
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example
 Using the overlap-add method of block convolution with each bock
length L=3, calculate the convolution of the following filter and
input signals? h=[1, 2, -1, 1],
x=[1, 1, 2, 1, 2, 2, 1, 1]
 Solution: The input is divided into block of length L
L=33

The output of each block is found by the convolution table:

Ha H. Kha

19
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example
 The output of each block is given by

 Following
F ll i from
f
time
i invariant,
i
i
aligning
li i the
h output blocks
bl k according
di
to theirs absolute timings and adding them up gives the final results:

Ha H. Kha

20
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

2. Sample processing methods
 The direct form convolution for an FIR filter of order M is given by
 Introduce the internal states
Sample
p p
processingg algorithm
g

Fig: Direct form realization
off Mth
M h order
d fil
filter
Ha H. Kha

 Sample
processing
methods
convenient for real-time
real time applications
21

CuuDuongThanCong.com

are

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example
 Consider the filter and input given by
Using the sample processing algorithm to compute the output and
show the input-off transients.

Ha H. Kha

22
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example

Ha H. Kha

23
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Example

Ha H. Kha

24
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

Hardware realizations
 The FIR filtering algorithm can be realized in hardware using DSP
chips, for example the Texas Instrument TMS320C25
 MAC: Multiplier
Accumulator

Ha H. Kha

25
CuuDuongThanCong.com

FIR Filtering and Convolution
https://fb.com/tailieudientucntt

### Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×