Generating Matlab Code

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. Enter wavemenu at the MATLAB command prompt. 2. Select Wavelet 1-D in the Wavelet Toolbox Main Menu. 3. Load the noisy Doppler example analysis. Select File > Example Analysis > Noisy Signals - Constant Noise Variance > with sym4 at level 5 - - -> Noisy Doppler.

description

generating MATLAB code for Denoising

Transcript of Generating Matlab Code

Page 1: Generating Matlab Code

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

On this page…

Wavelet 1-D Denoising

Wavelet 1-D DenoisingYou 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. Enter wavemenu at the MATLAB command prompt.2. Select Wavelet 1-D in the Wavelet Toolbox Main Menu.3. Load the noisy Doppler example analysis. Select File > Example Analysis > Noisy Signals - Constant Noise Variance > with sym4 at

level 5 - - -> Noisy Doppler.

Page 2: Generating Matlab Code

4. Click De-noise.

Page 3: Generating Matlab Code

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

Page 4: Generating Matlab Code

Click De-noise.6. 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.

%----------------------

Page 5: Generating Matlab Code

% meth = 'sqtwolog';

% scal_or_alfa = one;

sorh = 's'; % Specified soft or hard thresholding

thrParams = [...

3.00000000 ; ...

2.00000000 ; ...

3.00000000 ; ...

3.72000000 ; ...

3.50000000 ...

];

% Denoise using CMDDENOISE.

%--------------------------

sigDEN = cmddenoise(SIG,wname,level,sorh,NaN,thrParams);

7. 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);11. Export the denoised signal from the GUI by selecting File > Save > De-noised Signal.

Page 6: Generating Matlab Code

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');

Page 7: Generating Matlab Code

Interval Dependent 1-D Wavelet Denoising

1. Enter wavemenu at the MATLAB command prompt.2. Select Wavelet 1-D.3. Select File > Load > Signal, and load leleccum.mat from the matlab/toolbox/wavelet/wavedemo folder.4. Select the sym4 wavelet, and set Level equal to 3. Click Analyze.

Page 8: Generating Matlab Code

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. Click De-noise.2. Under Select thresholding method, select Rigorous SURE.3. Select Int. dependent threshold settings.4. 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.5. Click Close, and answer Yes to Update Thresholds?.6. Select De-noise.7. 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.

Page 9: Generating Matlab Code

%---------------------

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.9. 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.

load leleccum;

Page 10: Generating Matlab Code

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