| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Wavelet Toolbox |
| Contents | Index |
Two-Dimensional Discrete Stationary Wavelet Analysis
This section takes you through the features of two-dimensional discrete stationary wavelet analysis using the Wavelet Toolbox™ software. For more information, see Available Methods for De-Noising, Estimation, and Compression Using GUI Tools.
The toolbox provides these functions for image analysis. For more information, see the reference pages.
Analysis-Decomposition Function
| Function Name |
Purpose |
| swt2 |
Decomposition |
Synthesis-Reconstruction Function
| Function Name |
Purpose |
| iswt2 |
Reconstruction |
The stationary wavelet decomposition structure is more tractable than the wavelet one. So, the utilities useful for the wavelet case are not necessary for the Stationary Wavelet Transform (SWT).
In this section, you'll learn to
Two-Dimensional Analysis Using the Command Line
In this example, we'll show how you can use two-dimensional stationary wavelet analysis to denoise an image.
This example involves a image containing noise.
For the SWT, if a decomposition at level k is needed, 2^k must divide evenly into size(X,1) and size(X,2). If your original image is not of correct size, you can use the Image Extension GUI tool or the function wextend to extend it.
This generates the coefficients matrices of the level-one approximation (swa) and horizontal, vertical and diagonal details (swh, swv, and swd, respectively). Both are of size-the-image size. Type
map = pink(size(map,1)); colormap(map) subplot(2,2,1), image(wcodemat(swa,192)); title('Approximation swa') subplot(2,2,2), image(wcodemat(swh,192)); title('Horiz. Detail swh') subplot(2,2,3), image(wcodemat(swv,192)); title('Vertical Detail swv') subplot(2,2,4), image(wcodemat(swd,192)); title('Diag. Detail swd').
This generates the coefficients of the approximations at levels 1, 2, and 3 (swa) and the coefficients of the details (swh, swv and swd). Observe that the matrices swa(:,:,i), swh(:,:,i), swv(:,:,i), and swd(:,:,i) for a given level i are of size-the-image size. Type
colormap(map) kp = 0; for i = 1:3 subplot(3,4,kp+1), image(wcodemat(swa(:,:,i),192)); title(['Approx. cfs level ',num2str(i)]) subplot(3,4,kp+2), image(wcodemat(swh(:,:,i),192)); title(['Horiz. Det. cfs level ',num2str(i)]) subplot(3,4,kp+3), image(wcodemat(swv(:,:,i),192)); title(['Vert. Det. cfs level ',num2str(i)]) subplot(3,4,kp+4), image(wcodemat(swd(:,:,i),192)); title(['Diag. Det. cfs level ',num2str(i)]) kp = kp + 4; end
To reconstruct the details at levels 1, 2 and 3, type
H = mzero; V = mzero; D = mzero; for i = 1:3 swcfs = mzero; swcfs(:,:,i) = swh(:,:,i); H(:,:,i) = iswt2(mzero,swcfs,mzero,mzero,'db1'); swcfs = mzero; swcfs(:,:,i) = swv(:,:,i); V(:,:,i) = iswt2(mzero,mzero,swcfs,mzero,'db1'); swcfs = mzero; swcfs(:,:,i) = swd(:,:,i); D(:,:,i) = iswt2(mzero,mzero,mzero,swcfs,'db1'); end
A(:,:,2) = A(:,:,3) + H(:,:,3) + V(:,:,3) + D(:,:,3); A(:,:,1) = A(:,:,2) + H(:,:,2) + V(:,:,2) + D(:,:,2);
To display the approximations and details at levels 1, 2, and 3, type
colormap(map) kp = 0; for i = 1:3 subplot(3,4,kp+1), image(wcodemat(A(:,:,i),192)); title(['Approx. level ',num2str(i)]) subplot(3,4,kp+2), image(wcodemat(H(:,:,i),192)); title(['Horiz. Det. level ',num2str(i)]) subplot(3,4,kp+3), image(wcodemat(V(:,:,i),192)); title(['Vert. Det. level ',num2str(i)]) subplot(3,4,kp+4), image(wcodemat(D(:,:,i),192)); title(['Diag. Det. level ',num2str(i)]) kp = kp + 4; end
thr = 44.5; sorh = 's'; dswh = wthresh(swh,sorh,thr); dswv = wthresh(swv,sorh,thr); dswd = wthresh(swd,sorh,thr); clean = iswt2(swa,dswh,dswv,dswd,'db1');
To display both the original and denoised images, type
colormap(map) subplot(1,2,1), image(wcodemat(X,192)); title('Original image') subplot(1,2,2), image(wcodemat(clean,192)); title('denoised image')
A second syntax can be used for the swt2 and iswt2 functions, giving the same results:
lev = 4; swc = swt2(X,lev,'db1'); swcden = swc; swcden(:,:,1:end-1) = wthresh(swcden(:,:,1:end-1),sorh,thr); clean = iswt2(swcden,'db1');
You obtain the same plot by using the plot commands in step 9 above.
Two-Dimensional Analysis for De-Noising Using the
Graphical Interface
In this section, we explore a strategy for de-noising images based on the two-dimensional stationary wavelet analysis using the graphical interface tools. The basic idea is to average many slightly different discrete wavelet analyses.
The Wavelet Toolbox Main Menu appears:
Click the SWT De-noising 2-D menu item.
The discrete stationary wavelet transform de-noising tool for images appears.
When the Load Image dialog box appears, select the MAT-file noiswom.mat, which should reside in the MATLAB folder toolbox/wavelet/wavedemo. Click the OK button. The noisy woman image is loaded into the SWT De-noising 2-D tool.
The tool displays the histograms of the stationary wavelet detail coefficients of the image on the left of the window. These histograms are organized as follows:
The result seems to be oversmoothed and the selected thresholds too aggressive. Nevertheless, the histogram of the residuals is quite good since it is close to a Gaussian distribution, which is the noise introduced to produce the analyzed image noiswom.mat from a piece of the original image woman.mat.
The result is quite satisfactory, although it is possible to improve it slightly.
Select the sym6 wavelet and click the Decompose Image button. Use the Sparsity slider to adjust the threshold value close to 40.44, and then click the denoise button.
Importing and Exporting Information from the
Graphical Interface
The tool lets you save the denoised image to disk. The toolbox creates a MAT-file in the current folder with a name you choose.
To save the denoised image from the present de-noising process, use the menu File > Save denoised Image. A dialog box appears that lets you specify a folder and filename for storing the image. Type the name dnoiswom. After saving the image data to the file dnoiswom.mat, load the variables into your workspace:
load dnoiswom whos
| Name |
Size |
Bytes |
Class |
| X |
96x96 |
73728 |
double array |
| map |
255x3 |
6120 |
double array |
| valTHR |
3x4 |
96 |
double array |
| wname |
1x4 |
8 |
char array |
The denoised image is X and map is the colormap. In addition, the parameters of the de-noising process are available. The wavelet name is contained in wname, and the level dependent thresholds are encoded in valTHR. The variable valTHR has four columns (the level of the decomposition) and three rows (one for each detail orientation).
| Provide feedback about this page |
![]() | One-Dimensional Discrete Stationary Wavelet Analysis | One-Dimensional Wavelet Regression Estimation | ![]() |

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