| Contents | Index |
You can generate MATLAB code to reproduce GUI-based 2-D stationary wavelet denoising at the command line. You can generate code to denoise both indexed and truecolor images. You must perform this operation in the SWT Denoising 2-D tool. You must first denoise your image before you can enable the File > Generate Matlab Code (Denoising Process) operation.

Enter wavemenu at the MATLAB command prompt.
Select SWT Denoising 2-D.
Select File > Load Image, and load noiswom.mat from the matlab/toolbox/wavelet/wavedemo folder.
Choose No when prompted to use the grayscale image.
Select the db4 wavelet, and set the Level to 5.
Click Decompose Image.
Use the default soft thresholding method with Fixed form threshold and Unscaled white noise for Select noise structure.
Set the following thresholds for the horizontal, diagonal, and vertical details. Ensure that you set the thresholds for the three detail coefficient types.
Level 1 — 5
Level 2 — 4
Level 3 — 3
Level 4 — 2
Level 5 — 1
Click De-noise.
Select File > Generate Matlab Code (Denoising Process).
The operation generates the following MATLAB code.
function [XDEN,wDEC] = func_denoise_sw2d(X)
% FUNC_DENOISE_SW2D Saved Denoising Process.
% X: matrix of data
% -----------------
% XDEN: matrix of denoised data
% wDEC: stationary wavelet decomposition
% Analysis parameters.
%---------------------
wname = 'db2';
level = 5;
% Denoising parameters.
%-----------------------
% meth = 'sqtwolog';
% scal_OR_alfa = one;
sorh = 's'; % Specified soft or hard thresholding
thrSettings = [...
1.0000 2.0000 3.0000 4.0000 5.0000 ; ...
1.0000 2.0000 3.0000 4.0000 5.0000 ; ...
1.0000 2.0000 3.0000 4.0000 5.0000 ...
];
roundFLAG = false;
% Decompose using SWT2.
%---------------------
wDEC = swt2(X,level,wname);
% Denoise.
%---------
permDir = [1 3 2];
for j = 1:level
for kk=1:3
ind = (permDir(kk)-1)*level+j;
thr = thrSettings(kk,j);
wDEC(:,:,ind) = wthresh(wDEC(:,:,ind),sorh,thr);
end
end
% Reconstruct the denoise signal using ISWT2.
%-------------------------------------------
XDEN = iswt2(wDEC,wname);
if roundFLAG , XDEN = round(XDEN); endSave this MATLAB program as func_denoise_sw2d.m in a folder on the MATLAB search path.
Execute the following code.
load noiswom
[XDEN,wDEC] = func_denoise_sw2d(X);Save the denoised image as denoisedwom.mat in a folder on the MATLAB search path.

Execute the following code.
load denoisedwom % Compare the GUI and command line results imagesc(X); title('GUI Operation'); colormap(gray); figure; imagesc(XDEN); title('Command Line Operation'); colormap(gray); norm(XDEN-X,2)
![]() | Generating MATLAB Code for 1-D Stationary Wavelet Denoising | Generating MATLAB Code for 1-D Wavelet Packet Denoising and Compression | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |