Generating MATLAB Code for 1-D Wavelet Packet Denoising and Compression

1-D Wavelet Packet Denoising

You can generate MATLAB® code to reproduce GUI–based 1-D wavelet packet denoising at the command line. You must perform this operation in the Wavelet Packet 1-D - - De-noising tool. You must first denoise your signal before you can enable the File > Generate Matlab Code (Denoising Process) operation.

  1. Enter wavemenu at the MATLAB command prompt.

  2. Select Wavelet Packet 1-D.

  3. Select File > Load Signal and load noisbump.mat from the matlab/toolbox/wavelet/wavedemo folder.

  4. Select the db4 wavelet, and set the Level to 4. Accept the default value Shannon for Entropy.

  5. Click Analyze.

  6. Click De-noise.

  7. Under Select thresholding method, accept the default Fixed form thr. (unscaled wn) with the soft radio button enabled.

    Set Select Global Threshold to 2.75.

  8. Click De-noise.

  9. Select File > Generate Matlab Code (Denoising Process)

The operation generates the following MATLAB code.

function [sigDEN,wptDEN] = func_denoise_wp1d(SIG)
% FUNC_DENOISE_WP1D Saved Denoising Process.
%   SIG: vector of data
%   -------------------
%   sigDEN: vector of denoised data
%   wptDEN: wavelet packet decomposition (wptree object)

% Analysis parameters.
Wav_Nam = 'db4';
Lev_Anal = 4;
Ent_Nam = 'shannon';
Ent_Par = 0;

% Denoising parameters.
% meth = 'sqtwologuwn';
sorh = 's';    % Specified soft or hard thresholding
thrSettings = {sorh,'nobest',2.750000000000000,1};

% Decompose using WPDEC.
wpt = wpdec(SIG,Lev_Anal,Wav_Nam,Ent_Nam,Ent_Par);

% Nodes to merge.
n2m = [];
for j = 1:length(n2m)
    wpt = wpjoin(wpt,n2m(j));

% Denoise using WPDENCMP.
[sigDEN,wptDEN] = wpdencmp(wpt,thrSettings{:});

Save func_denoise_wp1d.m in a folder on the MATLAB search path.

Save the denoised signal from the Wavelet Packet 1-D - - De-noising tool as wp_denoisedbump.mat in a folder on the MATLAB search path.

Execute the following code.

load noisbump;
[sigDEN,wptDEN] = func_denoise_wp1d(noisbump);
load wp_denoisedbump;
plot(sigDEN); title('Denoised Signal');
axis([1 1024 min(sigDEN)-1 max(sigDEN+1)]);

Was this topic helpful?