Signal Processing with Wavelets.metalab.uniten.edu.my/~zainul/images/adsp/ADSP10b slide.pdfSignal...

Preview:

Citation preview

Signal Processing with Wavelets.

Newer mathematical tool since 1990.

Limitation of classical methods of Descrete-time Fourier Analysis when dealing withnonstationary signals .

A mathematical treatment of Wavelets isquite daunting. Simplify the approachusing subband coding of signals.

Use synthetic signals i.e. combination ofsine and cosine functions to gain someinsight to knowledge on wavelets.

Signal Processing with Wavelets.

Signal Processing with Wavelets.

fs=2500;

>> len=100;

>> [x1,t1]=analog(50,.5,len,fs); % The time vector t1 is in milliseconds

>> [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 vectors 1 to len, len to

2*len, etc.

>> [y2,ty2]=analog([50,100,200],[.5,.25,1],300,fs);

>> subplot(2,1,1), plot(y1), title('Concatenation of 50,100,200 Hz Sines')

>> subplot(2,1,2), plot(y2),title('Summation of 50,100,200 Hz Sines')

Non-stationary & Stationary Signal.

0 100 200 300 400 500 600 700 800-1

-0.5

0

0.5

1Concatenation of 50,100,200 Hz Sines

0 100 200 300 400 500 600 700 800-2

-1

0

1

2Summation of 50,100,200 Hz Sines

Spectrum of signals y1 and y2.

>> subplot(2,1,1),fft_plot(y1,2500);title('Spectrum of Concantenated Signal')

>> subplot(2,1,2),fft_plot(y2,2500);title('Spectrum of Summation Signal')

0 200 400 600 800 1000 1200 14000

0.1

0.2

0.3

0.4

Hz

Spectrum of Concantenated Signal

0 200 400 600 800 1000 1200 14000

0.5

1

Hz

Spectrum of Summation Signal

Spectrum of signals y1 and y2.

If the signals are represented by the tworespective spectrums using DFT it lookslike they represent a similar identicalsignal.

Problem overcome by reverting towavelet transforms.

One-level Decomposition of Signal

With Wavelet filters.

Low-Pass

Filter

High-Pass

Filter

Down-Sample

2x

Signal

Down-Sample

2x

Approximation

(A)

Detail(D)

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

-100

-80

-60

-40

-20

0

Normalized Frequency ( rad/sample)

Magnitude (

dB

)

Magnitude Response (dB)

Frequency Response of Decomposition

Filters for Daubechies-8 Wavelets.

Signal

D1A1

D2A2

D3A3

Multilevel Decomposition of a Signal

With Wavelets.

0 100 200 300 400 500 600 700 800-1

0

1Original Signal

0 50 100 150 200 250 300 350 400-2

0

2One Level Approximation

0 50 100 150 200 250 300 350 400-0.2

0

0.2One Level Detail

Decomposition of a Concatenation of

Signals.

fs=2500;

>> len=100;

>> [x1,t1]=analog(50,.5,len,fs); % The time vector t1 is in

milliseconds

>> [x2,t2]=analog(100,.25,len,fs);

>> [x3,t3]=analog(200,1,len,fs);

[y2,ty2]=analog([50,100,200],[.5,.25,1],300,fs);

>> [A1,D1]=dwt(y2,'db8');

>> subplot(3,1,1),plot(y2),title('Original Signal')

>> subplot(3,1,2),plot(A1),title('One Level Approximation')

>> subplot(3,1,3),plot(D1),title('One Level Detail')

0 100 200 300 400 500 600 700 800-2

0

2Original Signal

0 50 100 150 200 250 300 350 400-5

0

5One Level Approximation

0 50 100 150 200 250 300 350 400-0.2

0

0.2One Level Detail

Decomposition of a Summation of

Three sine waves.

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')

Decomposition of a Noisy

Sinusoid

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

0

5Original Signal

0 50 100 150 200 250-10

0

10One Level Approximation

0 50 100 150 200 250-2

0

2One Level Detail

Results of the Decomposition of a

Noisy Sinusoid.

• A crude way to compress a signal is to use the third

Level approximation coefficient A3.

• Neglect all the details coeffients ie D1, D2 & D3

Simple Signal Compression Using

A Wavelet Approximation.

Simple Signal Compression Using

A Wavelet Approximation Level 3

>> load leleccum

x=leleccum;

w = 'db3';

[C,L] = wavedec(x,4,w);

A4 = wrcoef('a',C,L,'db3',4);

A3 = wrcoef('a',C,L,'db3',3);

A2 = wrcoef('a',C,L,'db3',2);

A1 = wrcoef('a',C,L,'db3',1);

a3 = appcoef(C,L,w,3);

subplot(2,1,1),plot(x),axis([0,4000,100,600])

title('Original Signal')

subplot(2,1,2),plot(A3),axis([0,4000,100,600])

title('Approximation Reconstruction at Level 3 Using the Daubechies-3 Wavelet')

(length(a3)/length(x))*100

ans =

12.5926

% Contain about 13% of the number of original sample i.e.

compressed to 13% or by factor of 823

Result of Simple Signal Compression

Using A Wavelet Approximation.

0 500 1000 1500 2000 2500 3000 3500 4000100

200

300

400

500

600Original Signal

0 500 1000 1500 2000 2500 3000 3500 4000100

200

300

400

500

600Approximation Reconstruction at Level 3 Using the Daubechies-3 Wavelet

a3_interp=interp(a3,8);

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

subplot(2,1,2),plot(a3_interp),title('Level 3

Approximation Interpolated by 8X')

Reconstruction from a3 coefficients.

0 500 1000 1500 2000 2500 3000 3500 4000 45000

200

400

600Original Signal

0 500 1000 1500 2000 2500 3000 3500 4000 45000

500

1000

1500

2000Level 3 Approximation Interpolated by 8X

Comparison of a Signal with its

Interpolated Reconstruction From A3

Compression by Thresholding

>> load leleccum

>> 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')

0 100 200 300 400 500 6000

500

1000

1500

2000Approximation Coefficients at Level 3

0 100 200 300 400 500 600-50

0

50Detail Coefficients at Level 3

Compression by Thresholding.

Very few D3 coefficients >10.

Therefore Zeros all D3<10.

>> load leleccum

>> x=leleccum; % Uncompressed signal

>> w = 'db3'; % Set wavelet family

>> n=3; % Set decomposition level

>> [C,L] = wavedec(x,n,w); % Find the decomposition structure of x to level n

using w.

>> thr = 10; % Set the threshold value

>> keepapp = 1; %Logical parameter = do not threshold approximation

coefficients

>> sorh='h'; % Use hard thresholding

>> [xd,cxd,lxd, perf0,perfl2] =wdencmp('gbl',C,L,w,n,thr,sorh,keepapp);

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

>> subplot(2,1,2),plot(xd),title('Compressed Signal (Detail Thresholding)')

>> perf0 % Percent of coefficients set to zero

>> perfl2 % Percent retained energy in the compressed signal

perf0 = 83.4064. Giving compression ratio 100/(100-83.4054)= 6 to 1.

perfl2 = 99.9943

0 500 1000 1500 2000 2500 3000 3500 4000 45000

200

400

600Original Signal

0 500 1000 1500 2000 2500 3000 3500 4000 45000

200

400

600Compressed Signal (Detail Thresholding)

>> D1 = wrcoef('d',C,L,w,1);

>> D2 = wrcoef('d',C,L,w,2);

>> D3 = wrcoef('d',C,L,w,3);

>> d1 = wrcoef('d',cxd,lxd,w,1);

>> d2 = wrcoef('d',cxd,lxd,w,2);

>> d3 = wrcoef('d',cxd,lxd,w,3);

>> subplot(3,2,1),plot(D3),title('Original Detail - Levels 3 to 1')

>> subplot(3,2,2),plot(d3),title('Thresholded Detail - Levels 3 to 1')

>> subplot(3,2,3),plot(D2)

>> subplot(3,2,4),plot(d2)

>> subplot(3,2,5),plot(D1)

>> subplot(3,2,6),plot(d1)

Thresholding of Detail Coefficients at

Each of Three Levels.

Thresholding of Detail Coefficients at

Each of Three Levels.

0 2000 4000 6000-20

0

20

40Original Detail - Levels 3 to 1

0 2000 4000 6000-20

0

20

40Thresholded Detail - Levels 3 to 1

0 2000 4000 6000-20

0

20

40

0 2000 4000 6000-20

0

20

40

0 2000 4000 6000-50

0

50

0 2000 4000 6000-50

0

50

Aggresive Compression.

Threshold=50 for both details

& approximation coefficients.>> load leleccum

>> x=leleccum;

>> w = 'db3';

>> n=3;

>> [C,L] = wavedec(x,4,w);

>> thr = 50;

>> keepapp = 0;

>> [xd,cxd,lxd, perf0,perfl2]

=wdencmp('gbl',C,L,w,n,thr,'h',keepapp);

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

>> subplot(2,1,2),plot(xd),title('Aggressively Compressed')

>> perf0

perf0 =93.6362. Giving compression ratio about 100/(100-perf0)

=16 to 1.

0 500 1000 1500 2000 2500 3000 3500 4000 45000

200

400

600Original Signal

0 500 1000 1500 2000 2500 3000 3500 4000 45000

200

400

600Aggressively Compressed

Aggresive Compression.

Threshold=50 for both details

& approximation coefficients.

Image DWT compression.

JPEG2000 image compression algorithm.

Two dimensional DWT is computed for theimage signal.

Many of the DWT coefficients have valuesclosed to zeros and are discarded.

By discarding many of these small DWTcoefficients, effectively we are compressingthe image.

>> load detfingr.mat

>> whos

>>FPbw=X/(max(max(X)));

>>imshow(FPbw),title('Uncompressed B/W Intensity

Fingerprint Image')

%

Uncompressed B/W Intensity Fingerprint Image

Name Size Bytes Class

X 296x296 700928 double

map 180x3 4320 double

Uncompressed Fingerprint Intensity

Image

>> mask_2=mask8(2); %Set a DCT mask to 21-to-1 compression

>> mask_3=mask8(3); %Set a DCT mask to 11-to-1 compression

>> FPr_11=jpeg_demo(FPbw,mask_3); %Generate a reconstructed

image 11-tto-1

>> close %Close the figure created by jpeg_demo

>> FPr_21=jpeg_demo(FPbw,mask_2); % Generate a reconstructed

image 21-to-1

>> close %Close the figure created by jpeg_demo

>> imshow(FPr_11),title('Reconstructed JPEG 11-to-1 Compression')

>> figure,imshow(FPr_21),title('Reconstructed JPEG 21-to-1

Compression')

Reconstructed JPEG 21-to-1 CompressionReconstructed JPEG 11-to-1 Compression

Result of JPEG Compression. DCT based.

Blocky and severely degraded image.

Wavelet Compression of Fingerprint

Images. JPEG2000

Uncompressed Fingerprint Image

>> wav='bior4.4'; %Set the wavelet family to be used

>> level=3; % Set the decomposition level

>> sorh='h'; % Set the thresholding method to “hard”

>> keepapp=1; % Do not threshold the approximation coefficients

>> thr=40; % Set the thresholding level and use globally

(‘gbl’)

>> [XC,CXC,LXC,PERF0,PERFL2]=

wdencmp('gbl',X,wav,level,thr,sorh,keepapp);

>> imshow(XC/max(max(XC))),colormap(bone(128));

>> title('20-to-1 Compression, bior4.4 Wavelet, Threshold = 40')

>> PERF0

PERF0 =94.8699

Wavelet Compression of Fingerprint

Images

20-to-1 Compression, bior4.4 Wavelet, Threshold = 40

Wavelet Compression of Fingerprint

Images

College of EngineeringAdvanced Digital Signal Processing

Recommended