Wavelet Toolbox    

Two-Dimensional Analysis Using the Command Line

In this example, we'll show how you can use two-dimensional stationary wavelet analysis to de-noise an image.

This example involves a image containing noise.

  1. Load an image.
  1. From the MATLAB prompt, type

    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.

  1. Perform a single-level Stationary Wavelet Decomposition.
  1. Perform a single-level decomposition of the image using the db1 wavelet. Type

    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

  1. Display the coefficients of approximation and details.
  1. To display the coefficients of approximation and details at level 1, type

  1. Regenerate the image by Inverse Stationary Wavelet Transform.
  1. To find the inverse transform, type

    To check the perfect reconstruction, type

  1. Construct and display approximation and details from the coefficients.
  1. To construct the level 1 approximation and details (A1, H1, V1 and D1) from the coefficients swa, swh, swv and swd, type

    To display the approximation and details at level 1, type

  1. Perform a multilevel Stationary Wavelet Decomposition.
  1. To perform a decomposition at level 3 of the image (again using the db1 wavelet), type

    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

  1. Display the coefficients of approximations and details.
  1. To display the coefficients of approximations and details, type

  1. Reconstruct approximation at Level 3 and details from coefficients.
  1. To reconstruct the approximation at level 3, type

    To reconstruct the details at levels 1, 2 and 3, type

  1. Reconstruct and display approximations at Levels 1, 2 from approximation at Level 3 and details at Levels 1, 2, and 3.
  1. To reconstruct the approximations at levels 2 and 3, type

    To display the approximations and details at levels 1, 2, and 3, type

  1. Remove noise by thresholding.
  1. To de-noise an image, use the threshold value we find using the GUI tool (see the next section), use the wthresh command to perform the actual thresholding of the detail coefficients, and then use the iswt2 command to obtain the de-noised image.

    To display both the original and de-noised images, type

    A second syntax can be used for the swt2 and iswt2 functions, giving the same results:

    You obtain the same plot by using the plot commands than in Step 14 above,


  Two-Dimensional Discrete Stationary Wavelet Analysis Two-Dimensional Analysis for De-Noising Using the Graphical Interface