13
EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

Embed Size (px)

Citation preview

Page 1: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

EE513Audio Signals and Systems

Wiener Inverse Filter

Kevin D. DonohueElectrical and Computer Engineering

University of Kentucky

Page 2: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

Weiner Filters

A class of filters, referred to as Wiener filters, exploit correlation information between signal and noise to enhance SNR or reduce distortion. The Wiener filter is the optimal filter for enhancing SNR of a random signal in random noise. Signals and noise are characterized by their PSDs or ACs, and objective metrics are either SNR enhancement or minimization of least-square error.

These filters are named after Norbert Weiner: http://en.wikipedia.org/wiki/Norbert_Wiener

Page 3: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

Wiener Filters and Noise

Let s[n] be the original signal and y[n] be the corrupted version. The error signal or noise is given by:

Minimizing the error in the L2 or mean square error (MSE) sense means minimizing the expected value of:

This is equivalent to maximizing the SNR:

][][][ nsnyn

22 ][][E][E nsnyn

][E

][E

][][E

][E][E

2

2

2

2

2

n

ns

nsny

nsn

Signal Power

Noise Power

Page 4: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

Wiener Filter Objective

Let w[n] be the filter to maximize SNR or equivalently to minimize the MSE:

Express MSE in terms of the above equation:

where is a delay parameter to relax a causality constraint and typically improve performance. The first equation can be expressed more directly in the frequency domain:

mm

mnwmmsmnwmyny ][][][][][][~

22

][][][][E][][~E nsmnwmmsnsnym

][ˆ][ˆ][ˆ][~̂

kWkkSkY

Page 5: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

Wiener Filter and SNR

Assuming the signal and noise are uncorrelated, zero-mean stationary processes, it can be shown that the optimal filter for minimizing MSE is:

Can also be rewritten as:

22

2

][ˆE][ˆE

][ˆE][ˆ

kSk

kSkW

PSD of Signal PSD of Noise

1]SNR[

11

1][ˆE

][ˆE

1][ˆ

2

2

k

kS

kkW

Page 6: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

Homework 1

Download mat file (wienerhw1.mat) from:

http://www.engr.uky.edu/~donohue/ee513/data/wienerhw1.mat

It will contain the signal vectors described below with associated sampling frequency fs. Examples of the signal and noise processes are stored in vectors sig and nos with normalized power.

A) Plot the spectral magnitude of the Wiener filter for a signal plus noise process assuming a signal-to-noise ratio of -15 dB, 0 dB, and 15 dB. Describe how the SNR changes the spectral shape of the filter. Describe how this change makes sense for an optimal filter for this type. Hand in commented code and a clearly labeled plot, and the requested descriptions.

B) Apply a Wiener filter to the data in vector sigpnos, which is a combination of the signal and noise from the same source as the examples. Note that you do not know the SNR for this case. Since you know the PSD shapes you can try to assess the SNR by examining the PSDs or ACs of combined signal. Also assume that the SNR is between -25 and 0 dB and create a loop to increment through various levels of SNR and listen to or test the result to determine at what level the best performance. Hand in the commented code used to filter and test the signal and determine the best SNR for the filter design. Clearly indicate the SNR you thought was the best.

Page 7: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

FIR Inverse (Wiener) Filters

An inverse filter undoes distortions due to frequency selective channels/systems and restore the original transmitted/driving signal. This type of filtering is sometimes referred to as deconvolution. Let h(n) denote the impulse response of the channel/system. The inverse filter, hI(n), is described by:

1)(ˆ)(ˆ

)()(*)(

zHzH

nnhnh

I

I

Page 8: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

FIR Inverse Filters - Polynomial Division

Assume that for practical purposes the channel/system can be modeled as an all-pole system, therefore the inverse filter is an all-zero system. A direct way of obtaining the impulse response of the inverse filter, hI(n), is to expand rational polynomial through long division and truncate the sequence after M+1 coefficients:

)(ˆ zH

H zH z

h k z b z b zI Ik

kk

k

k

M

kk

k M( )

( )( )

1

0 0 1

The resulting error becomes:

1

22 )(Mn

I nbE

Page 9: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

FIR Inverse Filters – Least Squares

Another design can be obtained via a least-squares approach:

h(n)

FIR Filter{bk}

Minimize Sum ofSquared Errors

{ bk}

e(n)

)()( nnd

where d(n) is the desired response and the error of the filter output is e(n). The error and overall squared error E2 are given by:

0

2

1

2 )()(n

M

kk knhbndE

e n d n b h n kkk

M( ) ( ) ( )

0

-

Page 10: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

FIR Inverse Weiner Filter

After minimizing E2 (take the derivatives with respect to each bk and set the result to zero), it can be shown that the optimal set of {bk}’s are the solution to the M equations given by:

b r k l r l l Mk hhk

M

dh( ) ( ) , , , 1

0 1 2

where rhh(.) is the autocorrelation for h(n), and rdh(.) is the cross-correlation between h(n) and d(n):

r l h n h n l r l d n h n lhhn

dhn

( ) ( ) ( ) ( ) ( ) ( )

0 0

Page 11: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

FIR Inverse Filters – Least Squares

For the special case where d(n) = (n):

otherwise 0

0=for )0()(

lhlrdh

r r r M

r r

r M r M r

b

b

b

hhh hh hh

hh hh

hh hh hh M

( ) ( ) ( )

( ) ( )

( ) ( ) ( )

( )0 1

1 0

1 0

0

0

0

0

1

Therefore, the following system of equations can be used to solve for the filter coefficients:

Matrix is Symmetric and Toeplitz, can use Levenson-Durbin algorithm to solve

Page 12: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

Example

Given desired response (original input to the system) d(n) and the actual response of system h(n) up to length N, design an Mth order FIR (Wiener) inverse filter. Create the following vector and matrix:

d T d d d N( ) ( ) ( )0 1

H

h

h h

h M h M h

h M h M h

h N h N h N M

( )

( ) ( )

( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( )

0 0 0

1 0 0

0

1 0

1 2 1

1

Then compute desired filter coefficients by solving the following matrix equation for b:

H Hb H dT T bT b b bM0 1 where

Page 13: EE513 Audio Signals and Systems Wiener Inverse Filter Kevin D. Donohue Electrical and Computer Engineering University of Kentucky

Example

Then test for stability (was original system minimum phase?), apply h(n) (plus a little noise, less than -3 dB) to the inverse filter. If the result is anomalous (not close to the signal of interest), add a delay to the desired response and repeat (i.e. use):

Insert 0’s to delay desired response. This provides the filter with more degrees of freedom to undo the system response at the expense of delaying the output.

Increasing filter order can also improve performance.

Td )1()1()0( 0.... 0 Nddd