Sunteți pe pagina 1din 29

Signal Processing with Wavelets

Objectives
• Define and illustrate the difference between a stationary
and non-stationary signal.
• Describe the relationship between wavelets and sub-
band coding of a signal using quadrature mirror filters
with the property of perfect reconstruction.
• Illustrate the multi-level decomposition of a signal into
approximation and detail components using wavelet
decomposition filters.
• Illustrate the application of wavelet analysis using
MATLAB® to noise suppression, signal compression,
and the identification of transient features in a signal.
Motivation for Wavelet Analysis
• Signals of practical interest are usually non-
stationary, meaning that their time-domain and
frequency-domain characteristics vary over short
time intervals (i.e., music, seismic data, etc)
• Classical Fourier analysis (Fourier transforms)
assumes a signal that is either infinite in extent
or stationary within the analysis window.
• Non-stationary analysis requires a different
approach: Wavelet Analysis
• Wavelet analysis also produces better solutions
to important problems such as the transform
compression of images (jpeg versus jpeg2000)
CHIRP SIGNALS

Frequency: 2 Hz to 20 Hz Different in Time Domain Frequency: 20 Hz to 2 Hz

1 150 1 150

0.8 0.8

0.6 0.6

0.4 0.4
Magnitud

Magnitud
100 100
Magnitud

Magnitud
0.2 0.2

0 0
e

e
e

e
-0.2 -0.2
50 50
-0.4 -0.4

-0.6 -0.6

-0.8 -0.8

-1 0 -1 0
0 0.5 1 0 5 10 15 20 25 0 0.5 1 0 5 10 15 20 25
Time Frequency (Hz) Time Frequency (Hz)

At what time the frequency components occur? FT can not tell!

SHORT TIME FOURIER
TRANSFORM (STFT)
• Dennis Gabor (1946) Used STFT
– To analyze only a small section of the signal at a time
-- a technique called Windowing the Signal.
• The Segment of Signal is Assumed Stationary
• A 3D transform
STFTX t , f    xt   * t  t  e j 2 ft dt
t
t  : the window function

A function of time
and frequency
DRAWBACKS OF STFT

• Unchanged Window
• Dilemma of Resolution
– Narrow window -> poor frequency resolution
– Wide window -> poor time resolution
• Heisenberg Uncertainty Principle
– Cannot know what frequency exists at what time intervals

Via Narrow Window Via Wide Window

Continuous wavelet transform

mother wavelet may be real or complex with the following properties

1.the total area under the curve=0,   (t )dt  0
2. the total area of  (t ) is finite 

3. Admissible condition | (t ) |
2

 | (t ) | dt  
2



oscillate above and below the t-axis

energy of the function is finite function is localize
Infinite number of functions satisfies above conditions– some of
them used for wavelet transform
example
Morlet wavelet
Mexican hat wavelet
 once a wavelet  (t ) has been chosen , the CWT of a square integrable
function f(t) is defined as

1  t b
W ( a, b)  

f (t ) * 
|a|  a 
 dt

For any a, 1 t

 (t )   
a ,0
|a| a
Thus b is a translation parameter
Setting b=0,
Here a is a scaling parameter
a>1 stretch the wavelet and 0<a<1 shrink it
Basic Theory of Wavelets
• Wavelet analysis can be understood as a
form of sub-band coding with quadrature
mirror filters
• The two basic wavelet processes are
decomposition and reconstruction
Wavelet Decomposition
• A single level decomposition puts a signal through 2 complementary low-pass and
high-pass filters
• The output of the low-pass filter gives the approximation (A) coefficients, while the
high pass filter gives the detail (D) coefficients

Low-Pass Down-
Sample Approximation (A)
Filter 2X
Signal

Down-
High-Pass Sample
Detail (D)
Filter 2X

Decomposition Filters for Daubechies-8 Wavelets

Wavelet Reconstruction
• The A and D coefficients can be used to
reconstruct the signal perfectly when run
through the mirror reconstruction filters of
the wavelet family
Wavelet Families
• Wavelet families consist of a particular set
of quadrature mirror filters with the
property of perfect reconstruction.
• These families are completely determined
by the impulse responses of the set of 4
filters.
Example:
Filter Set for the Daubechies-5 Wavelet Family
% Set wavelet name.
>> wname = 'db5';
% Compute the four filters associated with wavelet name given
% by the input string wname.
>> [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters(wname);
>> subplot(221); stem(Lo_D);
>> title('Decomposition low-pass filter');
>> subplot(222); stem(Hi_D);
>> title('Decomposition high-pass filter');
>> subplot(223); stem(Lo_R);
>> title('Reconstruction low-pass filter');
>> subplot(224); stem(Hi_R);
>> title('Reconstruction high-pass filter');
>> xlabel('The four filters for db5')
Example:
Filter Set for the Daubechies-5 Wavelet Family
Decomposition low-pass filter Decomposition high-pass filter
1 1

0.5
0.5
0
0
-0.5

-0.5 -1
0 5 10 0 5 10

Reconstruction low-pass filter Reconstruction high-pass filter

1 1

0.5
0.5
0
0
-0.5

-0.5 -1
0 5 10 0 5 10
The four filters for db5
Example:
Filter Set for the Daubechies-5 Wavelet Family

>> fvtool(Lo_D,1,Hi_D,1)
>> fvtool(Lo_R,1,Hi_R,1)

Magnitude Response Magnitude Response

1.5 1.5

1 1

Magnitude
Magnitude

0.5 0.5

0 0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

Decomposition Filters Reconstruction Filters

Multi-level Decomposition of a Signal with
Wavelets

Signal

A1 D1

A2 D2
The decomposition tree
can be schematically
described as:
A3 D3
Aj = Aj + 1 + D j + 1
Multi-level Decomposition of a Signal with Wavelets
Frequency Domain (Sub-band Coding)

A2 D2 D1

fs/8 fs/4 fs/2

Example: One-level Decomposition of a Noisy Signal

>> x=analog(100,4,40,10000); % Construct a 100 Hz sinusoid of amplitude 4

>> xn=x+0.5*randn(size(x)); % Add Gaussian noise
>> [cA,cD]=dwt(xn,'db8'); % Compute the first level decomposition with dwt
% and the Daubechies-8 wavelet
>> subplot(3,1,1),plot(xn),title('Original Signal')
>> subplot(3,1,2),plot(cA),title('One Level Approximation')
>> subplot(3,1,3),plot(cD),title('One Level Detail')

Original Signal
5

-5
0 50 100 150 200 250 300 350 400 450

10
One Level Approximation Single level discrete
wavelet decomposition
0
with the Daubechies-8
-10
0 50 100 150 200 250 wavelet family
One Level Detail
2

-2
0 50 100 150 200 250
One-Level Decomposition of a Non-Stationary Signal

>> fs=2500; >> subplot(3,1,1),plot(y1),title('Original Signal')

>> len=100; >> subplot(3,1,2),plot(A1),title('One Level
>> [x1,t1]=analog(50,.5,len,fs); % The time vector t1 is Approximation')
in milliseconds >> subplot(3,1,3),plot(D1),title('One Level Detail')
>> [x2,t2]=analog(100,.25,len,fs);
>> [x3,t3]=analog(200,1,len,fs);
>> y1=cat(2,x1,x2,x3); % Concatenate the signals
>> ty1=[t1,t2+len,t3+2*len]; %Concatenate the time Original Signal
vectors 1 to len, len to 2*len, etc. 1
>> [A1,D1]=dwt(y1,'db8');
0

-1
0 100 200 300 400 500 600 700 800
One Level Approximation
2

The detail 0

coefficients reveal -2
0 50 100 150 200 250 300 350 400
the transitions in the One Level Detail
0.2
non-stationary signal
0

-0.2
0 50 100 150 200 250 300 350 400
De-Noising a Signal with Multilevel Wavelet Decomposition

>> x=analog(100,4,40,10000); >> subplot(5,1,1),plot(xn),title('Original Signal')

>> xn=x+0.5*randn(size(x)); >> subplot(5,1,2),plot(A1),title('Reconstructed
>> [C,L] = wavedec(xn,4,'db8'); % Do a multi-level Approximation - Level 1')
analysis to four levels with the >> subplot(5,1,3),plot(A2),title(' Reconstructed
% Daubechies-8 Approximation - Level 2')
wavelet >> subplot(5,1,4),plot(A3),title(' Reconstructed
>> A1 = wrcoef('a',C,L,'db8',1); % Reconstruct the Approximation - Level 3')
approximations at various levels >> subplot(5,1,5),plot(A4),title(' Reconstructed
>> A2 = wrcoef('a',C,L,'db8',2); Approximation - Level 4')
>> A3 = wrcoef('a',C,L,'db8',3); Original Signal
10
>> A4 = wrcoef('a',C,L,'db8',4);
0
-10
0 50 100 150 200 250 300 350 400 450
Reconstructed Approximation - Level 1
5
0
-5
0 50 100 150 200 250 300 350 400 450
Significant de-noising occurs 5
Reconstructed Approximation - Level 2

0
with the level-4 approximation -5
0 50 100 150 200 250 300 350 400 450
coefficients (Daubechies-8 5
Reconstructed Approximation - Level 3

0
wavelets) -5
0 50 100 150 200 250 300 350 400 450
Reconstructed Approximation - Level 4
5
0
-5
0 50 100 150 200 250 300 350 400 450
Finding Signal Discontinuities

>> x=analog(100,4,40,10000);
>> x(302:305)=.25; 3 sample discontinuity
>> [A,D]=dwt(x,'db8'); at sample 302
>> subplot(3,1,1),plot(x),title('Original Signal')
>> subplot(3,1,2),plot(A),title('First Level Approximation')
>> subplot(3,1,3),plot(D),title('First Level Detail')

Original Signal
5
Daubechies-8 wavelets
0

-5
0 50 100 150 200 250 300 350 400 450
First Level Approximation
10

-10
Discontinuity response
0 50 100 150 200 250
First Level Detail in the 1st level detail
0.5
coefficients (sample
0
151 because of the 2X
-0.5
0 50 100 150 200 250
down-sampling)
Simple Signal Compression Using a Wavelet
Approximation
>> load leleccum >> a3 = appcoef(C,L,w,3);
>> x=leleccum; >> subplot(2,1,1),plot(x),axis([0,4000,100,600])
>> w = 'db3'; >> title('Original Signal')
>> [C,L] = wavedec(x,4,w); >> subplot(2,1,2),plot(A3),axis([0,4000,100,600])
>> A4 = wrcoef('a',C,L,'db3',4); >> title('Approximation Reconstruction at Level 3 Using
>> A3 = wrcoef('a',C,L,'db3',3); the Daubechies-3 Wavelet')
>> A2 = wrcoef('a',C,L,'db3',2); >> (length(a3)/length(x))*100
>> A1 = wrcoef('a',C,L,'db3',1); ans =
12.5926
Original Signal
600

500

400

300
The wavelet approximation at
200 level-3 contains only 13 % of the
100
0 500 1000 1500 2000 2500 3000 3500 4000
original signal values because of
Approximation Reconstruction at Level 3 Using the Daubechies-3 Wavelet
the wavelet down-sampling, but
600
still retains the important signal
500

400
characteristics.
300

200

100
0 500 1000 1500 2000 2500 3000 3500 4000
Compression by Thresholding
>> x=leleccum;
>> w = 'db3'; % Specify the Daubechies-4 wavelet
>> [C,L] = wavedec(x,4,w); % Multi-level decomposition to 4 levels.
>> a3 = appcoef(C,L,w,3); % Extract the level 3 approximation coefficients
>> d3 = detcoef(C,L,3); % Extract the level 3 detail coefficients.
>> subplot(2,1,1), plot(a3),title('Approximation Coefficients at Level 3')
>> subplot(2,1,2), plot(d3),title('Detail Coefficients at Level 3')

Approximation Coefficients at Level 3

2000

1500
These are the A3 and D3
1000 coefficients for the signal.
500 Many of the D3
0 coefficients could be
0 100 200 300 400 500 600
“zeroed” without losing
Detail Coefficients at Level 3
50 much signal information or
power
0

-50
0 100 200 300 400 500 600
Compression by Thresholding

>> load leleccum >> subplot(2,1,1), plot(x),title('Original Signal')

>> x=leleccum; % Uncompressed signal >> subplot(2,1,2),plot(xd),title('Compressed Signal
>> w = 'db3'; % Set wavelet family (Detail Thresholding)')
>> n=3; % Set decomposition level >> perf0 % Percent of coefficients set to zero
>> [C,L] = wavedec(x,n,w); % Find the decomposition >> perfl2 % Percent retained energy in the compressed
structure of x to level n using w. signal
>> thr = 10; % Set the threshold value perf0 =
>> keepapp = 1; %Logical parameter = do not threshold 83.4064
approximation coefficients perfl2 =
>> sorh='h'; % Use hard thresholding 99.9943
>> [xd,cxd,lxd, perf0,perfl2] Original Signal
600
=wdencmp('gbl',C,L,w,n,thr,sorh,keepapp);

400

200
In this compression
83% of the coefficients 0
0 500 1000 1500 2000 2500 3000 3500 4000 4500
were set to zero, but Compressed Signal (Detail Thresholding)
99% of the energy in 600

the signal was 400

retained.
200

0
0 500 1000 1500 2000 2500 3000 3500 4000 4500
Compression by Thresholding

>> D1 = wrcoef('d',C,L,w,1); >> subplot(3,2,1),plot(D3),title('Original Detail - Levels 3

>> D2 = wrcoef('d',C,L,w,2); to 1')
>> D3 = wrcoef('d',C,L,w,3); >> subplot(3,2,2),plot(d3),title('Thresholded Detail -
>> d1 = wrcoef('d',cxd,lxd,w,1); Levels 3 to 1')
>> d2 = wrcoef('d',cxd,lxd,w,2); >> subplot(3,2,3),plot(D2)
>> d3 = wrcoef('d',cxd,lxd,w,3); >> subplot(3,2,4),plot(d2)
>> subplot(3,2,5),plot(D1)
>> subplot(3,2,6),plot(d1)
Original Detail - Levels 3 to 1 Thresholded Detail - Levels 3 to 1
40 40

20 20

0 0

-20
0 2000 4000 6000
-20
0 2000 4000 6000
Zeroing of coefficients
40 40 by thresholding
20 20
results in effective
0 0
signal compression
-20 -20
0 2000 4000 6000 0 2000 4000 6000
50 50

0 0

-50 -50
0 2000 4000 6000 0 2000 4000 6000
MULTIRESOLUTION ANALYSIS
(MRA)
• Wavelet Transform
– An alternative approach to the short time Fourier transform
to overcome the resolution problem
– Similar to STFT: signal is multiplied with a function
• Multiresolution Analysis
– Analyze the signal at different frequencies with different
resolutions
– Good time resolution and poor frequency resolution at high
frequencies
– Good frequency resolution and poor time resolution at low
frequencies
– More suitable for short duration of higher frequency; and
longer duration of lower frequency components
COMPARSION OF
TRANSFORMATIONS

From http://www.cerm.unifi.it/EUcourse2001/Gunther_lecturenotes.pdf, p.10

RESOLUTION OF TIME &
FREQUENCY
Better time
resolution;
Poor
frequency
resolution
Frequenc
y

Better
frequency
resolution;
Poor time Time
resolution
• Each box represents a equal portion
• Resolution in STFT is selected once for entire
analysis
Summary
• Wavelet processing is based on the idea of sub-
band decomposition and coding.
• Wavelet “families” are characterized by the low-
pass and high-pass filters used for
decomposition and perfect reconstruction of
signals.
• Typical applications of wavelet processing
include elimination of noise, signal compression,
and the identification of transient signal features.