Signal Processing with Wavelets. Newer mathematical tool since 199. Limitation of classical methods of Descretetime Fourier Analysis when dealing with nonstationary signals. A mathematical treatment of Wavelets is quite daunting. Simplify the approach using subband coding of signals. Use synthetic signals i.e. combination of sine and cosine functions to gain some insight to knowledge on wavelets.
Signal Processing with Wavelets.
Signal Processing with Wavelets. fs=25; >> len=1; >> [x1,t1]=analog(5,.5,len,fs); % The time vector t1 is in milliseconds >> [x2,t2]=analog(1,.25,len,fs); >> [x3,t3]=analog(2,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([5,1,2],[.5,.25,1],3,fs); >> subplot(2,1,1),plot(y1), title('concatenation of 5,1,2 Hz Sines') >> subplot(2,1,2), plot(y2),title('summation of 5,1,2 Hz Sines')
Non-stationary & Stationary Signal. 1 Concatenation of 5,1,2 Hz Sines.5 -.5-1 1 2 3 4 5 6 7 8 2 Summation of 5,1,2 Hz Sines 1-1 -2 1 2 3 4 5 6 7 8
Spectrum of signals y1 and y2. >> subplot(2,1,1),fft_plot(y1,25);title('spectrum of Concantenated Signal') >> subplot(2,1,2),fft_plot(y2,25);title('spectrum of Summation Signal').4 Spectrum of Concantenated Signal.3.2.1 2 4 6 8 1 12 14 Hz Spectrum of Summation Signal 1.5 2 4 6 8 1 12 14
Spectrum of signals y1 and y2. If the signals are represented by the two respective spectrums using DFT it looks like they represent a similar identical signal. Problem overcome by reverting to wavelet transforms.
One-level Decomposition of Signal With Wavelet filters. Signal Low-Pass Filter Down-Sample 2x Approximation (A) High-Pass Filter Down-Sample 2x Detail(D)
Frequency Response of Decomposition Filters for Daubechies-8 Wavelets. Magnitude Response (db) -2-4 Magnitude (db) -6-8 -1.1.2.3.4.5.6.7.8.9 Normalized Frequency ( rad/sample)
Multilevel Decomposition of a Signal With Wavelets. Signal A1 D1 A2 D2 A3 D3
Decomposition of a Concatenation of Signals. 1 Original Signal -1 1 2 3 4 5 6 7 8 2 One Level Approximation -2 5 1 15 2 25 3 35 4.2 One Level Detail -.2 5 1 15 2 25 3 35 4
fs=25; >> len=1; >> [x1,t1]=analog(5,.5,len,fs); % The time vector t1 is in milliseconds >> [x2,t2]=analog(1,.25,len,fs); >> [x3,t3]=analog(2,1,len,fs); [y2,ty2]=analog([5,1,2],[.5,.25,1],3,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')
Decomposition of a Summation of Three sine waves. 2 Original Signal -2 1 2 3 4 5 6 7 8 5 One Level Approximation -5 5 1 15 2 25 3 35 4.2 One Level Detail -.2 5 1 15 2 25 3 35 4
Decomposition of a Noisy Sinusoid x=analog(1,4,4,1);% Construct a 1 Hz sinusoid of amplitude 4 xn=x+.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')
Results of the Decomposition of a Noisy Sinusoid. 5 Original Signal -5 5 1 15 2 25 3 35 4 45 1 One Level Approximation -1 5 1 15 2 25 2 One Level Detail -2 5 1 15 2 25
Simple Signal Compression Using A Wavelet Approximation. 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 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([,4,1,6]) title('original Signal') subplot(2,1,2),plot(a3),axis([,4,1,6]) title('approximation Reconstruction at Level 3 Using the Daubechies-3 Wavelet') (length(a3)/length(x))*1 ans = 12.5926 % Contain about 13% of the number of original sample i.e. compressed to 13% or by factor of 2 3 8
Result of Simple Signal Compression Using A Wavelet Approximation. 6 Original Signal 5 4 3 2 1 5 1 15 2 25 3 35 4 Approximation Reconstruction at Level 3 Using the Daubechies-3 Wavelet 6 5 4 3 2 1 5 1 15 2 25 3 35 4
Reconstruction from a3 coefficients. 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')
Comparison of a Signal with its Interpolated Reconstruction From A3 6 Original Signal 4 2 5 1 15 2 25 3 35 4 45 2 Level 3 Approximation Interpolated by 8X 15 1 5 5 1 15 2 25 3 35 4 45
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')
Compression by Thresholding. Very few D3 coefficients >1. Therefore Zeros all D3<1. 2 Approximation Coefficients at Level 3 15 1 5 1 2 3 4 5 6 5 Detail Coefficients at Level 3-5 1 2 3 4 5 6
>> 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 = 1; % Set the threshold value >> keepapp = 1; %Logical parameter = do not threshold approximation coefficients >> sorh='h'; % Use hard thresholding >> [xd,cxd,lxd, perf,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)') >> perf % Percent of coefficients set to zero >> perfl2 % Percent retained energy in the compressed signal perf = 83.464. Giving compression ratio 1/(1-83.454)= 6 to 1. perfl2 = 99.9943
6 Original Signal 4 2 5 1 15 2 25 3 35 4 45 6 Compressed Signal (Detail Thresholding) 4 2 5 1 15 2 25 3 35 4 45
Thresholding of Detail Coefficients at Each of Three Levels. >> 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. 4 2 Original Detail - Levels 3 to 1 Thresholded Detail - Levels 3 to 1 4 2-2 2 4 6 4 2-2 2 4 6 5-2 2 4 6 4 2-2 2 4 6 5-5 2 4 6-5 2 4 6
Aggresive Compression. Threshold=5 for both details & approximation coefficients. >> load leleccum >> x=leleccum; >> w = 'db3'; >> n=3; >> [C,L] = wavedec(x,4,w); >> thr = 5; >> keepapp = ; >> [xd,cxd,lxd, perf,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') >> perf perf =93.6362. Giving compression ratio about 1/(1-perf) =16 to 1.
Aggresive Compression. Threshold=5 for both details & approximation coefficients. 6 Original Signal 4 2 5 1 15 2 25 3 35 4 45 6 Aggressively Compressed 4 2 5 1 15 2 25 3 35 4 45
Image DWT compression. JPEG2 image compression algorithm. Two dimensional DWT is computed for the image signal. Many of the DWT coefficients have values closed to zeros and are discarded. By discarding many of these small DWT coefficients, effectively we are compressing the image.
Uncompressed Fingerprint Intensity Image >> load detfingr.mat >> whos >>FPbw=X/(max(max(X))); >>imshow(fpbw),title('uncompressed B/W Intensity Fingerprint Image') % Name Size Bytes Class X 296x296 7928 double map 18x3 432 double Uncompressed B/W Intensity Fingerprint 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')
Result of JPEG Compression. DCT based. Blocky and severely degraded image. Reconstructed JPEG 11-to-1 Compression Reconstructed JPEG 21-to-1 Compression
Wavelet Compression of Fingerprint Images. JPEG2 Uncompressed Fingerprint Image
Wavelet Compression of Fingerprint Images >> 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=4; % Set the thresholding level and use globally ( gbl ) >> [XC,CXC,LXC,PERF,PERFL2]= wdencmp('gbl',x,wav,level,thr,sorh,keepapp); >> imshow(xc/max(max(xc))),colormap(bone(128)); >> title('2-to-1 Compression, bior4.4 Wavelet, Threshold = 4') >> PERF PERF =94.8699
Wavelet Compression of Fingerprint Images 2-to-1 Compression, bior4.4 Wavelet, Threshold = 4
College of Engineering Advanced Digital Signal Processing