Vous êtes sur la page 1sur 10

Generating MATLAB Code for 1-D Decimated Wavelet Denoising and

Compression
On this page

Wavelet 1-D Denoising

Wavelet 1-D Denoising


You can generate MATLAB code to reproduce GUI-based 1-D wavelet denoising at the command line. You must perform this operation in
the Wavelet 1-D - - De-noising tool. You must first denoise your signal before you can enable the File > Generate Matlab Code (Denoising
Process) operation.
The generated MATLAB code does not include the calculation of the thresholds using thselect or wbmpen.

Denoise Doppler Signal


1.
2.
3.

Enter wavemenu at the MATLAB command prompt.


Select Wavelet 1-D in the Wavelet Toolbox Main Menu.
Load the noisy Doppler example analysis. Select File > Example Analysis > Noisy Signals - Constant Noise Variance > with sym4
at level 5 - - -> Noisy Doppler.

4.

Click De-noise.

5.

In the Select thresholding method drop-down menu, select the default Fixed form threshold. Use the
default soft option. Set the thresholds by level as follows:
level 5 3.5

level 4 3.72

level 3 3.0

level 2 2.0

level 1 3.0

6.

Click De-noise.
Generate the MATLAB code by selecting File > Generate Matlab Code (Denoising Process).
The operation generates the following MATLAB code.

function sigDEN = func_denoise_dw1d(SIG)


% FUNC_DENOISE_DW1-D Saved Denoising Process.
%

SIG: vector of data

-------------------

sigDEN: vector of denoised data

% Analysis parameters.
%--------------------wname = 'sym4';
level = 5;

% Denoising parameters.
%----------------------

% meth = 'sqtwolog';
% scal_or_alfa = one;
sorh = 's';
thrParams =

% Specified soft or hard thresholding


[...

3.00000000 ; ...
2.00000000 ; ...
3.00000000 ; ...
3.72000000 ; ...
3.50000000

...

];

% Denoise using CMDDENOISE.


%-------------------------sigDEN = cmddenoise(SIG,wname,level,sorh,NaN,thrParams);
7.

11.

Save func_denoise_dw1d.m in a folder on the MATLAB search path. Execute the following code.
8. load noisdopp;
9. SIG = noisdopp;
10. % func_denoise_dw1d.m is generated code
sigDEN = func_denoise_dw1d(SIG);
Export the denoised signal from the GUI by selecting File > Save > De-noised Signal.

Save the denoised signal as denoiseddoppler.mat in a folder on the MATLAB search path.
Loaddenoiseddoppler.mat in the MATLAB workspace. Compare denoiseddoppler with your command line result.
load denoiseddoppler;
plot(sigDEN,'k'); axis tight;
hold on;
plot(denoiseddoppler,'r');
legend('Command Line','GUI','Location','SouthEast');

Interval Dependent 1-D Wavelet Denoising


1.
2.
3.
4.

Enter wavemenu at the MATLAB command prompt.


Select Wavelet 1-D.
Select File > Load > Signal, and load leleccum.mat from the matlab/toolbox/wavelet/wavedemo folder.
Select the sym4 wavelet, and set Level equal to 3. Click Analyze.

When you inspect the original signal and the finest-scale wavelet coefficients, you see that the noise variance is not constant. In this situation,
interval-dependent thresholding is useful. To implement interval-dependent denoising:
1.
2.
3.
4.
5.
6.
7.

Click De-noise.
Under Select thresholding method, select Rigorous SURE.
Select Int. dependent threshold settings.
In the Interval Dependent Threshold Settings for Wavelet 1-D tool, choose Generate Default Intervals. Three intervals are
created. Click Propagate to propagate the intervals to all levels.
Click Close, and answer Yes to Update Thresholds?.
Select De-noise.
Generate the MATLAB code by selecting File > Generate Matlab Code (Denoising Process).
The operation generates the following MATLAB code.

function sigDEN = func_denoise_dw1d(SIG)


% FUNC_DENOISE_DW1D Saved Denoising Process.
%

SIG: vector of data

-------------------

sigDEN: vector of denoised data

% Analysis parameters.

%--------------------wname = 'sym4';
level = 3;

% Denoising parameters.
%---------------------% meth = 'rigrsure';
% scal_or_alfa = one;
sorh = 's';

% Specified soft or hard thresholding

thrSettings =

{...

[...
1.000000000000000

2410.000000000000000

5.659608351110114; ...

2410.000000000000000

3425.000000000000000

19.721391195242880; ...

3425.000000000000000

4320.000000000000000

4.907947952868359; ...

]; ...
[...
1.000000000000000

2410.000000000000000

5.659608351110114; ...

2410.000000000000000

3425.000000000000000

5.659608351110114; ...

3425.000000000000000

4320.000000000000000

5.659608351110114; ...

]; ...
[...
1.000000000000000

2410.000000000000000

5.659608351110114; ...

2410.000000000000000

3425.000000000000000

5.659608351110114; ...

3425.000000000000000

4320.000000000000000

5.659608351110114; ...

]; ...
};

% Denoise using CMDDENOISE.


%-------------------------sigDEN = cmddenoise(SIG,wname,level,sorh,NaN,thrSettings);
8.

To avoid confusion with the MATLAB code generated in Denoise Doppler Signal , change the function definition line. Change the
function definition to:

function sigDEN = func_IDdenoise_dw1d(SIG)


Save the MATLAB program as func_IDdenoise_dw1d.m in a folder on the MATLAB search path.
Save the denoised signal as denoisedleleccum.mat with File > Save > De-noised Signal in a folder on the MATLAB
search path.
Execute the following code.

9.

load leleccum;

load denoisedleleccum;
sigDEN = func_IDdenoise_dw1d(leleccum);
plot(sigDEN,'k');
hold on;
plot(denoisedleleccum,'r');
legend('Command Line','GUI');
norm(sigDEN-denoisedleleccum,2)

Vous aimerez peut-être aussi