This example denoises a blocky signal using the Haar wavelet with DWT and MODWT denoising. It compares the results with plots and metrics for the original and denoised versions.
First, to ensure reproducibility of results, set a seed that will be used to generate random noise.
rng('default')
Generate a signal and a noisy version with the square root of the signal-to-noise ratio equal to 3. Plot and compare each.
[osig,nsig] = wnoise('blocks',10,3);
plot(nsig,'r')
hold on
plot(osig,'b')
legend('Noisy Signal','Original Signal')
Using the Haar wavelet, perform a level 6 wavelet decomposition of the noisy signal and denoise it using Donoho and Johnstone's universal threshold with level-dependent estimation of the noise. Obtain denoised versions using DWT and MODWT, both with soft thresholding.
wname = 'haar';
lev = 6 ;
[xdDWT,c1,l1] = wden(nsig,'sqtwolog','s','mln',lev,wname);
[xdMODWT,c2] = wden(nsig,'modwtsqtwolog','s','mln',lev,wname);
Plot and compare the original, noise-free version of the signal with the two denoised versions.
figure
plot(osig,'b')
hold on
plot(xdDWT,'r--')
plot(xdMODWT,'k-.')
legend('Original','DWT','MODWT')
hold off
Calculate the L2 and L-infinity norms of the difference between the original signal and the two denoised versions.
L2norm_original_DWT = norm(abs(osig-xdDWT),2)
L2norm_original_DWT = 36.1194
L2norm_original_MODWT = norm(abs(osig-xdMODWT),2)
L2norm_original_MODWT = 14.5987
LInfinity_original_DWT = norm(abs(osig-xdDWT),Inf)
LInfinity_original_DWT = 4.7181
LInfinity_original_MODWT = norm(abs(osig-xdMODWT),Inf)
LInfinity_original_MODWT = 2.9655