Top Banner

of 39

EEE6209 Part a Topic 01

Jan 10, 2016

Download

Documents

dialauchenna

dd
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • EEE6209

    Advanced Signal Processing (ASP)

    Topic 01 - Digital Filters :

    Part I

    Analogue vs. Digital

    Filter basics

    Time/Frequency domain parameters

    Dr Charith Abhayaratne

    Tel: 25893

    Email: [email protected]

    Office: P/C11

    Time/Frequency domain parameters

    A framework for filter design

    Part II

    Time/Frequency domain parameters

    What makes a good filter?

    Realising other filters from a LPF

    Moving average filter

    Reference

    Proakis: Ch8.1

    MATLAB

    Commands: filter, freqz, pz2tf, tf2pz, fft, plot, help, fir1, fir2, remez, firls

    EEE62091

  • Digital filters are used for two general purposes:

    (1) separation of signals that have been combined,

    E.g., foetus heartbeat monitoring

    (2) restoration of signals that have been distorted in

    some way.

    E.g., Denoising an image

    Analogue vs. Digital filters

    Advantages of Digital filters?

    Disadvantages of digital filters?

    EEE6209 2

  • Both x(n) and y(n) are digital signals.

    Usually a filter's input and output signals are in the time

    Digital filter

    x(n) y(n)

    )]([)( nxTny

    Usually a filter's input and output signals are in the time domain. (Due to A to D conversion process sampling at equal intervals of time)

    The second most common way of sampling is at equal intervals in space. E.g., imaging

    EEE6209 3

  • Difference Equation

    (1.1)

    Convolution

    (1.2)

    ==

    +=M

    k

    k

    N

    k

    k knxbknyany01

    )()()(

    knxkhny

    =

    = )()()(

    (1.3)

    (1.4)

    EEE6209

    N

    N

    M

    M

    k

    zaza

    zbzbbzH

    zXzHzY

    =

    +++

    +++=

    =

    ...1

    ...)(

    )()()(

    1

    1

    1

    10

    4

  • The impulse response

    The step response

    The frequency response.

    Each of these responses contains complete information about the filter, but in a different form. form.

    If one of the three is specified, the other two are fixed and can be directly calculated.

    All three of these representations are important, because they describe how the filter will react under different circumstances.

    EEE6209 5

  • The impulse response

    The output when the input is an impulse

    )0()( when )()(

    )()()(

    ==

    =

    =

    nxnhny

    knxkhnyk

    The step response

    The output when the input is a step (also called an edge, and an edge response)

    It is the integral of the impulse response

    Two ways to compute.

    EEE6209 6

  • Frequency response

    Denoted by H(j)

    Magnitude and Phase responses

    jNN

    j

    jM

    M

    j

    ez eaea

    ebebbzHjH j

    = +++

    +++==

    ...1

    ...)()(

    1

    10

    Magnitude and Phase responses

    EEE6209

    ( )

    ( ) ( )

    =

    =

    ==

    )()(

    )()()()(

    jHjH

    jHjHejHjH j

    7

  • EEE6440 8

  • Exercise: 2.1

    Consider the difference equation

    y(n) = 0.5y(n-1) + x(n) x(n-2)

    Find out Find out

    Impulse response

    Step response

    Frequency response

    EEE6209 9

  • Filter Implementation

    The most straightforward way to implement a digital filter is by convolving the input signal with the digital filter's impulse response.

    All possible linear filters can be made in this manner. manner.

    When the impulse response is used in this way, filter designers give it a special name: the filter kernel.

    There is also another way to make digital filters, called recursion.

    EEE6209 10

  • When a filter is implemented by convolution, each sample in the output is calculated by weighting the samples in the input, and adding them together.

    Recursive filters are an extension of this, using previously calculated values from the output, besides points from the input.

    Instead of using a filter kernel, recursive filters are defined by a set of recursion coefficients.

    Remember, all linear filters have an impulse response, even if you don't use it to implement the filter.

    EEE6209 11

  • To find the impulse response of a recursive filter, simply feed in an impulse, and see what comes out.

    The impulse responses of recursive filters are composed of sinusoids that exponentially decay in amplitude.

    In principle, this makes their impulse responses infinitely long. However, the amplitude eventually drops below the round-off noise of the system, and infinitely long. However, the amplitude eventually drops below the round-off noise of the system, and the remaining samples can be ignored.

    Because of this characteristic, recursive filters are also called Infinite Impulse Response or IIR filters.

    In comparison, filters carried out by convolution are called Finite Impulse Response or FIR filters.

    EEE6209 12

  • IIR Filters

    Duration length of h(n) is infinite. That means

    h(n)0 when n.

    IIR filters are recursive. That means at least one

    coefficient ak0.

    Causal IIR filters can be represented as Causal IIR filters can be represented as

    IIR filters have at least one nonzero finite pole

    EEE6209 13

    ==

    =

    +==M

    k

    k

    N

    k

    k

    k

    knxbknyaknxkhny010

    )()()()()(

    ( ) ( )NN

    M

    M

    N

    N

    M

    M

    zpzp

    zbzbb

    zaza

    zbzbbzH

    +

    +++=

    +++

    +++=

    1...1

    ...

    ...1

    ...)(

    1

    1

    1

    10

    1

    1

    1

    10

  • FIR Filters

    Duration length of h(n) is finite. Length is M+1 <

    . That means h(n)=0 when n.

    FIR filters are non-recursive. That means all

    coefficients ak=0 when k>0 and a0=1.

    Causal FIR filters can be represented as Causal FIR filters can be represented as

    FIR filters are all zero filters. That means all poles

    are either 0 finite pole

    EEE6209 14

    ==

    ==M

    k

    k

    M

    k

    knxbknxkhny00

    )()()()(

    M

    M zbzbbzH +++= ...)( 110

  • Information in signals There are many ways that information can be contained

    in a signal.

    information represented in the time domain,

    information represented in the frequency domain

    Information represented in the time domain describes when something occurs and what the amplitude of the occurrence is.

    Each sample contains information that is interpretable Each sample contains information that is interpretable without reference to any other sample. Even if you have only one sample from this signal, you still know something about what you are measuring.

    This is the simplest way for information to be contained in a signal.

    The step response describes how information represented in the time domain is being modified by the system

    EEE6209 15

  • Information in signals

    In contrast, information represented in the frequency domain is more indirect.

    Many things in our universe show periodic motion. By measuring the frequency, phase, and amplitude of this periodic motion, information can often be obtained about the system producing the motion.

    A single sample, in itself, contains no information A single sample, in itself, contains no information about the periodic motion. The information is contained in the relationship between many points in the signal.

    The frequency response shows how information represented in the frequency domain is being changed.

    EEE6209 16

  • Filter parameters Step response

    Fast step response

    No overshoot

    Linear phase

    Frequency response

    Fast roll-off Fast roll-off

    Flat passband

    Good stopband attenuation

    Why step response and not the impulse response is considered?

    What about phase related parameters of the frequency response?

    EEE6209 17

  • EEE6209 18

  • Filter Classification

    Four main types

    Low pass

    High pass

    Band pass

    Band reject

    How to design a high pass filter if we know the impulse

    response of the low pass FIR filter h(n)?

    EEE6209 19

  • There are two methods

    Spectral inversion

    Spectral reversal

    Spectral Inversion

    If low pass filter is H(z)

    H(z)1

    00 0.5 f

    G(z)1

    00

    fc

    fcIf low pass filter is H(z)

    The high pass filter G(z) = 1 H(z)

    in time domain g(n) = (n) h(n)

    Parallel filters

    EEE6209 20

    00 0.5 f

    h(n)

    (n)

    +

    x(n)y(n)

    -

    fc

  • Spectral reversal

    If low pass filter is H(z)

    The high pass filter G(z) = H(z+0.5)

    in time domain g(n) = (1)n h(n)

    H(z)1

    EEE6209 21

    1

    00 0.5 f

    G(z)1

    00 0.5 f

    fc

    0.5-fc

  • Show how to use cascade and/or parallel LPF and/or HPF to

    realise band-pass and band-reject filters.

    LPF H(Z) with cut-off frequency f1

    HPF G(z) with cut-off frequency f2

    If f1 > f2 If f1 > f2

    Band-pass filter is given by H(z) G(z) or h(n) * g(n) (cascaded filters)

    Band reject by 1 H(z)G(z) (spectral inversion of band pass)

    If f1 < f2

    Band reject is give by parallel h(n) + g(n)

    EEE6209 22

  • Draw the cascaded/parallel filtering system for Band pass and band reject filtering

    EEE6209 23

  • The Moving average filter (MAF)

    The moving average filter operates by averaging a number of

    points from the input signal to produce each point in the

    output signal.

    Example: Consider a 5-point MAF, i.e., M=5

    =

    +=1

    0

    )(1

    )(M

    k

    kixM

    iy

    Example: Consider a 5-point MAF, i.e., M=5

    What is the impulse response?

    What is the step response?

    Write a pseudo-code to implement it

    What is the frequency response?

    The main aim of the MAF is to remove the noise while

    keeping sharp transitions intactEEE6209 24

  • EEE6209 25

  • Noise reduction performance

    Consider the signal below

    MATLAB commands:

    X=[zeros(1,200) ones(1,100) zeros(1,200)];

    Y= X+ 0.2*randn(1,500); % original signal

    What is the output (recovered X) when the following three MAFs are used on Y.

    M=5

    M=11

    M=25

    Explain your observations using the step and frequency responses of the above filters.

    EEE6209 26

  • EEE6209 27

  • Frequency response of MAF

    Mathematically described by the Fourier transform of the

    rectangular pulse.

    How to write the rectangular pulse ?

    Frequency response?

    )sin(

    )sin(][

    fM

    fMfH

    =

    An alternative way

    zero pad the impulse response to make it a length N filter, where

    N is a power of 2

    Take the FFT

    0 to N/2 points represent the Frequency response from 0 to 0.5 of

    the normalised frequency.

    EEE6209 28

  • The roll-off is very slow and the stopband attenuation is

    ghastly. Clearly, the moving average filter cannot separate one ghastly. Clearly, the moving average filter cannot separate one

    band of frequencies from another. (Good performance in the

    time domain results in poor performance in the frequency

    domain, and vice versa)

    the moving average is an exceptionally good smoothing filter

    (the action in the time domain), but an exceptionally bad low-

    pass filter (the action in the frequency domain). EEE6209 29

  • Multiple pass MAF

    Consider M=5 MAF and involve passing the input signal

    through a moving average filter two or more times.

    Find out the

    Filter kernal (the impulse response)

    Step response

    Frequency response Frequency response

    For 1 pass, 2-pass and 3-pass MAF.

    How is the noise removal performance for the (example in

    slide 12)

    For 2-pass MAF

    For 3-pass MAF

    EEE6209 30

  • Multiple pass MAF

    Consider the output after the first stage

    y1 = h*x

    Second stage

    y2 = h*y1y2 = h*h*x

    h = h*h

    y2 = h*h*x

    h2 = h*h

    Third stage

    y3 = h*y2y3 = h*h2*x

    h3 = h*h2

    EEE6209 31

  • EEE6209 32

  • Multiple pass MAF

    EEE6440 33

  • Multiple pass MAF

    Two passes are equivalent to using a triangular filter

    kernel (a rectangular filter kernel convolved with itself).

    After four or more passes, the equivalent filter kernel looks

    like a Gaussian.

    As shown in (b), multiple passes produce an "s" shaped

    step response, as compared to the straight line of the step response, as compared to the straight line of the

    single pass.

    The frequency responses in (c) and (d) are given by the

    equation in slide 14 multiplied by itself for each pass. That

    is, each time domain convolution results in a multiplication

    of the frequency spectra.

    Why are the resulting filters from multiple passes better

    than the MAF itself?EEE6209 34

  • Recursive implementation of MAF

    Consider a MAF with M=5

    y[n] is computed as

    y[n] = (x[n-2]+x[n-1]+x[n]+x[n+1]+x[n+2])/5

    y[n+1] is computed as

    y[n+1] = (x[n-1]+x[n]+x[n+1]+x[n+2]+x[n+3])/5

    In other words,In other words,

    y[n+1] = y[n]+(x[n+3]-x[n-2])/5

    For any M, y[i] is computed as

    y[i] = y[i-1]+(x[i+p]-x[i-q])/M

    where p=(M-1)/2

    q=p+1

    EEE6209 35

  • Filters can be summarized by

    Their use

    1) In time domain

    E.g. ?

    2) In frequency domain

    E.g. ?

    3) Custom

    E.g. ?

    Their implementation Their implementation

    A) Convolution

    B) Recursion

    Examples for 1A, 1B, 2A, 2B, 3A, 3B ?

    EEE6209 36

  • Recursive implementation of MAF

    The equation in the previous slide uses two sources of data to calculate each point in the output: points from the input and

    previously calculated points from the output.

    This is called a recursive equation, meaning that the result of one calculation is used in future calculations.

    Be aware that the moving average recursive filter is Be aware that the moving average recursive filter is very different from typical recursive filters.

    Is this an IIR or a FIR?

    This algorithm is faster than other digital filters for several reasons. there are only two computations per point, regardless of the

    length of the filter kernel.

    addition and subtraction are the only math operations needed (if division by M is omitted at the individual step and performed at the end) --- Integer representation.

    EEE6209 37

  • Custom filters

    Most filters have one of the four standard frequency

    responses: low-pass, high-pass, band-pass or band-reject.

    But most of the time, we have to design digital filters with

    an arbitrary frequency response, tailored to the needs of

    our particular application. our particular application.

    Two important uses of custom filters:

    Deconvolution - a way of restoring signals that have undergone an

    unwanted convolution, and

    Optimal filtering - the problem of separating signals with

    overlapping frequency spectra. (lectures by WL)

    EEE6209 38

  • Deconvolution

    The detected signal is the

    desired signal convolved with an

    unwanted kernel.

    How do we recover the desired

    signal back?

    If the exact frequency response

    of the desired signal not known

    how can we get the desired signal

    back? (blind deconvolution -

    from WL lectures)

    EEE6209 39