Let us consider a finite discrete signal, represented by a vector
In many practical situations
The octave code below applies this denoising method with the DWT corresponding to different Daubechies wavelets and produces the examples shown here. Note that it calls to a function in "The matrix of the DWT". The output is treated with this sagemath plotter to get the images.
The chosen signal (taken from my course on signal processing) is
![]() |
![]() |
Signal |
Noisy signal |
The jump in the discontinuity is
For D2, the Haar wavelet, the graphs of the denoised signal and of the error are
![]() |
![]() |
Of course the technique for D2 has only an academic interest.
For D4 the result is a little ’shaky’ due to the lack of smoothness of the wavelet. On the other hand the discontinuity has been detected.
![]() |
![]() |
With D8 we get a better result and in general smaller errors except for points very close to the discontinuity which now visually is less obvious.
![]() |
![]() |
Finally, with D12 the error near the discontinuity boosts and there is also a replica, coming from
![]() |
![]() |
This is octave code that produces the figures:
pkg load signal
clear all
%close all
filename = "data_plot.txt";
fid = fopen (filename, "w");
% Haar
fd2 = [1,-1]/sqrt(2);
% D4
fd4 = [ 1-sqrt(3), sqrt(3)-3, 3+sqrt(3), -1-sqrt(3)]/4/sqrt(2);
%(the bizarre ordering compensated by fliplr is to copy the data from wikipedia)
% D6
fd6 = [0.47046721, 1.14111692 , 0.650365, -0.19093442, -0.12083221, 0.0498175 ];
fd6 = -fliplr(fd6)/sqrt(2).*(-1).^[1:size(fd6,2)];
% D8
fd8 = [0.32580343 , 1.01094572 , 0.89220014, -0.03957503 , -0.26450717 , 0.0436163 , 0.0465036, -0.01498699];
fd8 = -fliplr(fd8)/sqrt(2).*(-1).^[1:size(fd8,2)];
% D12
fd12 = [0.15774243 , 0.69950381 ,1.06226376 , 0.44583132, -0.31998660, -0.18351806 , 0.13788809 , 0.03892321 , -0.04466375 , 7.83251152e-4, 6.75606236e-3, -1.52353381e-3 ];
fd12 = -fliplr(fd12)/sqrt(2).*(-1).^[1:size(fd12,2)];
N = 1024
% FIX RANDOM NUMBERS
randn ("seed", 0.5)
% SIGNAL
t = ( [0:N-1]/N )';
x = (15-sign(t-1/2))/16.*(sin(pi*t)).^2 + cos(8*pi*t)/6;
metadat = '>!_!_!_\nPJ0 SI6 FI./file_%s.png\n!_!_!_<\n';
% POINT SIGNAL x
fprintf (fid, '(%f, %f)\n', [t'; x']);
fprintf (fid, sprintf(metadat, '1') );
% NOISY SIGNAL xn1
sig1 = 0.02;
xn1 = x +randn(N,1)*sig1;
fprintf (fid, '(%f, %f)\n', [t'; xn1']);
fprintf (fid, sprintf(metadat, '2') );
% DENOISED SIGNAL AND ERROR D2
xden = noi_denoi(xn1, fd2, N);
fprintf (fid, '(%f, %f)\n', [t'; xden']);
fprintf (fid, sprintf(metadat, 'd2') );
fprintf (fid, '(%f, %f)\n', [t'; (x-xden)']);
fprintf (fid, sprintf(metadat, 'd2e') );
% DENOISED SIGNAL AND ERROR D4
xden = noi_denoi(xn1, fd4, N);
fprintf (fid, '(%f, %f)\n', [t'; xden']);
fprintf (fid, sprintf(metadat, 'd4') );
fprintf (fid, '(%f, %f)\n', [t'; (x-xden)']);
fprintf (fid, sprintf(metadat, 'd4e') );
% DENOISED SIGNAL AND ERROR D8
xden = noi_denoi(xn1, fd8, N);
fprintf (fid, '(%f, %f)\n', [t'; xden']);
fprintf (fid, sprintf(metadat, 'd8') );
fprintf (fid, '(%f, %f)\n', [t'; (x-xden)']);
fprintf (fid, sprintf(metadat, 'd8e') );
% DENOISED SIGNAL AND ERROR D12
xden = noi_denoi(xn1, fd12, N);
fprintf (fid, '(%f, %f)\n', [t'; xden']);
fprintf (fid, sprintf(metadat, 'd12') );
fprintf (fid, '(%f, %f)\n', [t'; (x-xden)']);
fprintf (fid, sprintf(metadat, 'd12e') );
fclose (fid);
It requires the functions:
|
noi_sigma
|
|
|