9 filter design - cuhk electronic engineering...

36
ELEG3503 Introduction to Digital Signal Processing 1 Introduction 2 Basics of Signals and Systems 3 Fourier analysis 4 Sampling 5 Linear time-invariant (LTI) systems 6 z-transform 7 System Analysis 8 System Realization 9 Filter Design

Upload: lamliem

Post on 23-May-2018

278 views

Category:

Documents


17 download

TRANSCRIPT

Page 1: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

ELEG3503 Introduction to Digital Signal Processing

1 Introduction2 Basics of Signals and Systems3 Fourier analysis4 Sampling5 Linear time-invariant (LTI) systems6 z-transform7 System Analysis8 System Realization9 Filter Design

Page 2: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

2

9 Filter Design (2)

9.1 Introduction

9.2 Phase response & Magnitude response

9.3 FIR Filter Design by window method

Page 3: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

9.1 Introduction (3)

Filters can enhance or suppress a certain frequency band of a signal. It can be used in many applications.

)( jeY

interference removed

Noise Reduction

Hz50100 or

)( jeS

100

)( jeHinterference )( jeN

][][ nns Notch Filter

][nyInterference Removal

][][][ nnsnx Noise Reduction

Filter

][][][ nxnhny

0 B

)( jeS )( jeN

0 B

)( jeH

0 B

)( jeSN() with >B removed

)()()( jjj eHeSeY

Page 4: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

input n -½ -½ -½image -½ 5 -½ = outputx[m,n] -½ -½ -½ image

m y[m,n]

],[ nmxHigh Pass

Filter

],[],[],[ nmxnmhnmy Image Enhancement

Page 5: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

9.2 Phase response & Magnitude response (5)

The frequency response of a filter is

H(ej|H(ej ej

which consists of the magnitude frequency response |H(ejand the phase response .

][][][ nnsnx Noise Reduction

Filter

][][][ nxnhny

0 B

)( jeS )( jeN

0 B

)( jeH

0 B

)( jeSN() with >B removed

)()()( jjj eHeSeY

e.g. Filters for Noise Reduction

Page 6: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Phase Response (6)

Consider a stable system of system function H(z) = |H(ejej whose coefficients are real. Now we apply to it a sinusoidal sequence

x[n] = sin[n0] u[n].At steady state, the output will be

nuneHny jss 00sin0

Example: Consider the case where

|H(ejand or The output is

yss[n] = sin[n0 ] u[n].

Hence the waveforms of yss[n] is ahead that of x [n].

180

][nx ][nyss

n

delayed 270

ahead

90

Page 7: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Phase Distortion

The ideal phase response is zero. If not, the filter is said to introduce phase distortion.

dnjjid eeH

or|Hid(ej)| = 1 and Hid(ej) = - nd, || < ,

nuneHany jss 00sin0

continued: Phase distortion

DelayConsider the ideal delay system whose impulse response ishid[n] = [n-nd] and the frequency response is

with periodicity 2 in assumed. The phase - nd of the ideal delay system is linear.

Page 8: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

8

)]4(cos[1.1)]3(cos[1.0)]2(cos[3.0)]1(cos[1.0]cos[1.1][ nnnnnny

2cos2sin24sin]2cos[cos]2cos[3cos2cos24cos1 2

using

3sin1.0sin1.02sin3.04sin1.1sin

3cos1.0cos1.02cos3.04cos1.11.1cos

nn ny ][

With u=n and v= -4, we have cosn-4)] = cosn]cos] + sinn] sin].Similarly, we express cosn-3)], cosn-2)], cosn-1)] into needed forms.

= A cosn - ] where -2 is the phase shift

We have yn] = A cosn] cos] + A sinn] sin] where A= 0.3 + 2(0.1cos + 1.1cos2

= A cosn-]

Sln:

= A cos (n- 2) ]. Hence the delay is 2.

Example: Find the output y[n] and the delay introduced to the input x[n] = cosn] by the system of difference equation

]4[1.1]3[1.0]2[3.0]1[1.0][1.1][ nxnxnxnxnxny

Page 9: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Delay is considered as a rather mild form of phase distortion. Thus in design approximations to ideal filters and other LTI systems, we often are willing to accept linear phase response rather than zero phase response as our ideal.

Delay (9)

Example: Find the delay introduced by the system satisfying difference equation ]4[1.1]3[1.0]2[3.0]1[1.0][1.1][ nxnxnxnxnxny

2

222

2cos1.1cos1.023.0)1.11.03.01.01.1(

j

jjjjj

eeeeee

Sln: H(z) = 1.1 + 0.1 z-1 + 0.3 z-2 + 0.1 z-3 + 1.1 z-4.

)(2)()(

2cos1.1cos1.023.0)(

phaselinear

j

j

eH

eH

2)(

Delay or 2Ts where Ts is the sampling period.

432 1.11.03.01.01.1)( jjjjj eeeeeH

Page 10: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

The delay is 2 or 2 Ts where Ts is the sampling period.

Consider a system whose input & output satisfy difference equation

y[n] = 1.1 x[n] + 0.1 x[n-1] + 0.3 x[n-2] + 0.1 x[n-3] + 1.1 x[n-4].

When input x[n] = cos n], its output y[n] = A cos (n-2) ].

Example: Suppose Ts = 1 sec and = 2 (0.2).

Find the phase shift of y[n].

Sln: 2)()( jeH = -2 x 2 x 0.2 = -0.8 or -144o

Alternatively

2 ()/(-2)

Hence,

() = -0.8 or -144on

x[n]

2;5 sT

)(2

sT

yss[n]

10

Page 11: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

3. The coefficients h[k] are also the impulse response of the filter.

11

Notes:1. If the input is cosn] u[n] instead of cosn], this phase shift of

144o occurs only in the steady-state.

otherwise

nnx ,00,1][ If i.e. a unit pulse

][nyss

n

x[n]

o144

continued: For a system of difference equation y[n] = 1.1 x[n] + 0.1 x[n-1] + 0.3 x[n-2] + 0.1 x[n-3] + 1.1 x[n-4], the output y[n] = A cos (n-2) ] when input x[n] = cosn].

2. Phase delay depends on N, the filter order. The larger is N, the longer the delay is.

then y[0]= h[0]=1.1,

y[1]=h[1]=0.1,...,

y[4]=h[4]=1.1, y[n]=0 for n 5.

Page 12: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

12

][nx h(k) ][nyFIR Filter

The present output y[n] is a sum of the weighted present and past inputs. The weights are the filter coefficients.

The present output depends on weighted present and past inputs AND on weighted past outputs (i.e. feedback).

][nx a[k],b[k] ][nyIIR Filter

][][][1

0

knxkhnyM

k

M= filter orderh[k]= filter coefficientsgeneral form

][][][][][1

1

0

knykaknxkbnyM

k

N

k

general form

]2[]1[2][][ nxnxnxny1]2[2]1[1]0[ hhh

example

]2[6.0]1[5.0]1[3.0][2.0][ nynynxnxnyexample

Page 13: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

13

FIR-IIR comparisons:1. Frequency response of a FIR filter can have linear phase, i.e.

H(ej)= () = kwhere k is a constant. This implies a FIR filter introduces the same delay nd for sinusoidal input of different . Such property is important for some image and audio processing applications. IIR always has nonlinear phase responses, especially at the band edges (image of phase distortion).

2. FIR is always stable. IIR can be unstable.3. FIR requires more coefficients (and so more delays and

multiplications) than IIR to achieve same frequency response specifications.

4. Easier to design IIR from analog filters.

Rule of thumb:a. Use FIR if linear phase is needed, and the number of filter

coefficients is acceptable.b. Use IIR if filter requires sharp frequency cut-off.

Page 14: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

14

f

Specifications of themagnitude frequency response

of a Lowpass Filter

p1

p1

magnitude

cf

s

sf21 sampling frequency

frequency off-cut

for 1, fromdeviation maximumripple passband

c

cp

f

ff

frequency edge stopband for , from deviation maximumnattenuatio stopband

s

ss

fff0

In most cases, magnitude frequency response is the prime concern of filter design.

Page 15: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

15

f

Normalized tosampling frequency=1 Hz

ripple passband p

p1

p11

sf18.0 sf33.0

s

sf14.0 sf37.0 sf5.0

Passband 0.18-0.33 ( normalized to 1 Hz sampling)1.8 – 3.3 KHz ( if sampling frequency is 10 KHz)

Specifications of the magnitude frequency responseof a Bandpass Filter

Stopbands 0 to 0.14 and 0.37 to 0.5

nattenuatio stopband s

Transition width = 0.18-0.14 = 0.37-0.33 = 0.04

Page 16: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

9.2 FIR Filter Design by Window Method (16)

16

The specifications of a filter usually given in the frequency domain.Let that be Hd(ej). The impulse response is .)(

21][

deeHnh njj

dd

)( jeW

n

][nw

0

n

][nh

0][ nh

Remedy:

multiply hd[n] by a

window w[n] that

becomes zero when |n| is larger than a certain number.

However, hd[n] is usually too long, often infinite. If Hd(ej) is ideal LPF, hd[n] is a sinc function.

)( jd eH

c n

][nhd

0

)( jeH

0

Page 17: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Let the ideal desired frequency response be

.nj

nd

jd enheH

)()(

.21

deeH

πnh njj

dd )()(

The corresponding impulse response is

Multiply hd[n] by rectangular window w[n], i.e. h[n] = hd[n] w[n] where

.,0

21

21,1

otherwise

MnMnw ][

with M =7

We can find W(ej) from the z-transform of w[n], which is

W(z) = z(M-1)/2 + ..+ z2 + z1 + 1 + z-1 + z-2 +...+ z-(M-1)/2

Page 18: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Its frequency response is

W(ej) = ej(M-1)/2 +...+ ej+ ej+ 1 + e-j+ e-j + ...+ e-j(M-1)/2

1

0

2/)1(M

n

njMj ee

The z-transform of w[n] is W(z) = z(M-1)/2+..+z2+z1+1+z-1+z-2+..+ z-(M-1)/2

= ej(M-1)/2 { 1 + e-j+ e-j +...+ ej(M-1)/2 +...+ e-j(M-1) }

j

Mj

j

Mj

ee

ee

11

2/

2/

)(2

2

sin

Msin

2/2/

2/2/

jj

MjMj

eeee

. r

rrMM

n

n

111

0

Note: |W(ej)| for M=7

main lobe

side lobes

Page 19: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Hd(ej) is the ideal frequency response and

hd(n) is the corresponding impulse response.

The frequency response of h(n) is the convolution of Hd(ej)and W(ej).

h(n) = hd(n) w(n).

.

2

2)(

)()(

sin

MsineW j

is the frequency response of the rectangular window w(n).

Hd(ej)

hd(n)

xThe rectangular window w(n)

|W(ej)|

Page 20: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

With W(ej( - )) increasing from 0, the integral H(ej)

• will oscillate as each side lobe of W(ej( - )) moves past the discontinuity of Hd(ej) and

• will go from the passband to stopband as the main lobe of W(ej( - ))moves past the discontinuity of Hd(ej).

deWeHπ

eH jjd

j )()()( )(

21

The integral is the net area of the shifted (by )periodic Sinc function W(ej( - ))under the rectangular function Hd(ej).

Page 21: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

It can be proved that

1) The width of the main lobe is 4/M.

2) The side lobes are significantly large, and its width decreases as Mincreases and is 2/M.

3) The area under each lobe (main and side lobes) is a constant independent of M.

)()(

2

22)1(

2)1(

sin

MsineeW

M

Mn

njj

Page 22: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Why does the area under each lobe (main and side lobes) is a constant independent of M ?

sin(M/2) =0 at = 2n/M with n= 1, 2,..., M-1.

The width of a sidelobe is 2/M. The width of the main lobe is 4/M.

sin(M/2)/sin(/2) has a local maximumat = 2n/M + /M with n= 1, 2, 3, ..., M-1

with amplitude = sin(M/2)/sin(/2) (M/2)/(/2)

= M

The area under a lobe is proportional to the width and amplitude of a side lobe. Hence, the area does not increase with the increase of M.

)()(

2

22)1(

2)1(

sin

MsineeW

M

Mn

njj

M=8

M=16

M=64

Page 23: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

As M increases, 1) the mainlobe width decreases and so H(ej) has sharper

transition;2) the number of sidelobes increases and so the oscillations of

H(ej) occur more rapidly and

3) the area under each lobes is independent of M and so the magnitude of the oscillations of H(ej) unchanges.

deWeHπ

eH jjd

j )()()( )(

21

Note: The integral H(ej) is the net area of the function W(ej( - )), periodic Sinc function shifted by ,under the rectangular function Hd(ej).

Page 24: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

By tapering w(n) smoothly to zero at each end,

• the height and the width of the side lobes decrease and so the ripples become smaller and narrower;

• the width of the main lobe increases and so the transition at the discontinuity becomes wider.

n

Hd(ej)

hd(n)

x

|W(ej)|

Page 25: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Hamming Windoww(n) = 0.54 - 0.46 cos(2n/(M-1)) 0 n M-1

= 0 otherwise

Rectangular Window

The window function

is non-causal and so not realizable.

.,0

21

21,1

otherwise

MnMnw ][

.,010,1

otherwiseMn

nw ][

Example: w(n) = 0.08 0.31 0.77 1.00 0.77 0.31 0.08 for M=7

Of course, the corresponding impulse response hd(n) is delayed by (M-1)/2 as well.

In practice, it is delayed by (M-1)/2 to become the following:

Page 26: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Example: The desired frequency & impulse responses are

||,0||,2/)1(

c

cMj

jωlp

eeH )(

deeH

πnh njj

ddc

c

)()( 21

Find h(n) = hd(n) w(n)

if c = 1 and w(n) is the Hamming window with M = 7.

|H(ej)|

hd(n)

)(

)(

212

1

Mn

Mnsin c

Filter length M=7w(n)

Sln: The Hamming window is

w(n) = 0.08 0.31 0.77 1.00 0.77 0.31 0.08

Page 27: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Continued: the desired frequency & impulse responses are

.||,0||,2

1

c

c

Mjjω

lpeeH )(

)(

)()(

212

1

Mn

Mnsinnh

c

d

Find: h(n) = hd(n) w(n) if c = 1 & w(n) is the Hamming window with M = 7.

Solutiuon: h(n) = hd(n) w(n)

h(3) = 0.3183 x 1.00h(2) = h(4) = 0.2678 x 0.77h(1) = h(5) = 0.1447 x 0.31h(0) = h(6) = 0.0150 x 0.08

H(ej)

hd(n)

Filter length M=7w(n)

h(n)

x

||

= 0.3183= 0.2062= 0.0449= 0.0012

Page 28: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

Given: the desired frequency & impulse responses are

.||,0||,2

1

c

c

Mjjω

lpeeH )(

)(

)()()(

212

1

21

Mn

MnsindeeH

πnh

cnjj

ddc

c

Find: h(n) = hd(n) w(n) if c = 1 & w(n) is the Hamming window with M = 21.

Solutiuon: h(n) = hd(n) w(n)

h(10) = 0.3183 x 1h(9) = h(11) = 0.2678 x 0.9774

h(8) = h(12) = 0.1447 x 0.9121h(7) = h(13) = 0.0150 x 0.8103h(6) = h(14) = -0.0602 x 0.6821h(5) = h(15) = -0.0610 x 0.5400h(4) = h(16) = -0.0148 x 0.3978h(3) = h(17) = 0.0299 x 0.2696h(2) = h(18) = 0.0394 x 0.1678h(1) = h(19) = 0.0146 x 0.1025h(0) = h(20) = -0.0173 x 0.0799

Page 29: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

29

Some common window functions

Name

Rectangular

Hanning

Hamming

Blackman

TransitionWidth Hz

(Normalized)

Passband ripple20 log (1+p) (db)

Stopband Attenuation

20 log s (db)oddMnnw M

2

)1(...,,1,0,][

1

12cos5.05.0

Mn

12cos46.054.0

Mn

14cos08.0

12cos5.042.0

Mn

Mn

7416.0

0546.0

0194.0

0017.0

21

44

53

74

Notes:1. Rectangular window is ideal. Not used because of Gibbs phenomenon.2. Increase M to reduce transition width.3. Select a window to satisfy the requirements on passband ripple and stopband

attenuation.

19.0M

15.2M

12.3M

16.4M

Page 30: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

30

Example: Design an FIR filter to meet the LPF specs.

p1

f

p1

s

KHz5.1

Transition width 0.5 KHzSampling frequency 8 KHzPassband ripple = 20 log(1+p) < 0.1 dbStopband attenuation = 20 log s < -50 db

Normalization: transition width = .1

2.30625.085.0

M

Because of smearing by window,

½ of transition width for Hamming window

actual cf

ideal cff

Both Hamming or Blackman can meet specs. Let's use Hamming.

2626,sin2][ nn

nfnhc

ccd

Filter coefficients h[n] = hd[n] w[n] where

,)5.1( 25.0 KHzfc Choose ideal

normalized to 1.75/8 or 0.21875.

Use M=53.

fc ideal > fc actual = 1.5 KHz

Page 31: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

31

)1(31119.0)1()1(1

98713.0532cos46.054.0)1(

31219.021875.02sin21875.02

21875.02)1(,1

4375.0)0()0()0(10cos46.054.0)0(

4375.02sin2)0(,0

hwhh

w

hdn

whhw

fn

nfhn

d

d

cc

ccd

Mnnw 2cos46.054.0][

windowHamming Note:

The coefficients run from h(-26) to h(26). To make the filter causal, add26 to each index so that the coefficients now run from h(0) to h(52).

)26(1014.9)26()26(26

08081.053

262cos46.054.0)26(

10131.1)21875.0226sin(21875.0226

21875.02)26(,26

4

2

hwhh

w

hn

d

d

fc=0.21875

Page 32: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

By Matlab Signal Processing Toolbox: [b,a] = butter(N,Wn)

It designs an order N lowpass digital Butterworth filter H(z) with normalized cutoff frequency Wn which is a number between 0 and 1, where 1 corresponds to the Nyquist frequency .

[b,a] = butter(6, 0.2329148)b = 0.0007 0.0044 0.0111 0.0148 0.0111 0.0044 0.0007a = 1.0000 -3.1836 4.6223 -3.7796 1.8137 -0.4800 0.0544

.)1(...)2(1

)1(...)2()1()()()( 1

1

N

N

zNazazNbzbb

zAzBzH

____________________________-2 -1 0 1 2 Wn

)216.0904.01)(358.0011.11)(705.0269.11()1(000738.0)( 212121

61

zzzzzz

zzH

Wn = c/

73172.02

76622.0tan22

tan 11

Tc

c 2

Page 33: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

• [r,g,b]=tiffread('C:\lena.tif');• imshow(r,g,b)• M=512; N=512;• %• % Design a Butterworth lowpass filter• % N=6 & Cufoff freq=0.3• [bf,af] = butter(6, 0.3)• %• % lowpass filtering• %• for j=1:N; • rH(1:M,j)=filter(bf,af,r(1:M,j));• end;• for j=1:N; • gH(1:M,j)=filter(bf,af,g(1:M,j));• end;• for j=1:N; • bH(1:M,j)=filter(bf,af,b(1:M,j));• end;

• %• % Restrict filter o/p within range• %• for i=1:M; for j=1:N; • if rH(i,j)>1 rH(i,j)=1; end;• if rH(i,j)<0 rH(i,j)=0; end;• end; end;• for i=1:M; for j=1:N; • if gH(i,j)>1 gH(i,j)=1; end;• if gH(i,j)<0 gH(i,j)=0; end;• end; end;• for i=1:M; for j=1:N; • if bH(i,j)>1 bH(i,j)=1; end;• if bH(i,j)<0 bH(i,j)=0; end;• end; end;• imshow(rH,gH,bH)

Page 34: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

N=6 & Cufoff frequency =0.3

Page 35: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

N=12 & Cufoff frequency =0.3

Page 36: 9 Filter Design - CUHK Electronic Engineering Programmejwguan/ELEG3503/lecture_notes/Dsp1617Lect09... · ELEG3503 Introduction to Digital Signal Processing ... 2 Basics of Signals

N=24 & Cufoff frequency =0.3