Wavelet Toolbox Previous page   Next Page

Importing and Exporting Information from the Graphical Interface

The Wavelet 2-D graphical tool lets you import information from and export information to disk, if you adhere to the proper file formats.

Saving Information to Disk

You can save synthesized images, coefficients, and decompositions from the Wavelet 2-D tool to disk, where the information can be manipulated and later reimported into the graphical tool.

Saving Synthesized Images.   You can process an image in the Wavelet 2-D tool, and then save the processed image to a MAT-file (with extension mat or other).

For example, load the example analysis:

FileExample Analysisat level 3, with sym4 --> detail Durer

and perform a compression on the original image. When you close the Wavelet 2-D Compression window, update the synthesized image by clicking Yes in the dialog box that appears.

Then, from the Wavelet 2-D tool, select the FileSaveSynthesized Image menu option.

A dialog box appears allowing you to select a directory and filename for the MAT-file (with extension mat or other). For this example, choose the name symage.

To load the image into your workspace, simply type

Name
Size
Bytes
Class
X
359x371
1065512
double array
map
64x3
1536
double array
valTHR
1x1
8
double array
wname
1x4
8
char array

The synthesized image is given by X and map contains the colormap. In addition, the parameters of the de-noising or compression process are given by the wavelet name (wname) and the global threshold (valTHR).

Saving Discrete Wavelet Transform Coefficients.   The Wavelet 2-D tool lets you save the coefficients of a discrete wavelet transform (DWT) to disk. The toolbox creates a MAT-file in the current directory with a name you choose.

To save the DWT coefficients from the present analysis, use the menu option FileSaveCoefficients.

A dialog box appears that lets you specify a directory and filename for storing the coefficients.

Consider the example analysis:

FileExample Analysisat level 3, with sym4 --> Detail Durer

After saving the discrete wavelet coefficients to the file cfsdurer.mat, load the variables into your workspace:

Name
Size
Bytes
Class
coefs
1x142299
1138392
double array
map
64x3
1536
double array
sizes
5x2
80
double array
valTHR
0x0
0
double array
wname
1x4
8
char array

Variable map contains the colormap. Variable wname contains the wavelet name and valTHR is empty since the synthesized image is the same as the original one.

Variables coefs and sizes contain the discrete wavelet coefficients and the associated matrix sizes. More precisely, in the above example, coefs is a 1-by-142299 vector of concatenated coefficients, and sizes gives the length of each component.

Saving Decompositions.   The Wavelet 2-D tool lets you save the entire set of data from a discrete wavelet analysis to disk. The toolbox creates a MAT-file in the current directory with a name you choose, followed by the extension wa2 (wavelet analysis 2-D).

Open the Wavelet 2-D tool and load the example analysis:

FileExample Analysisat level 3, with sym4 --> Detail Durer.

To save the data from this analysis, use the menu option FileSaveDecomposition.

A dialog box appears that lets you specify a directory and filename for storing the decomposition data. Type the name decdurer.

After saving the decomposition data to the file decdurer.wa2, load the variables into your workspace:

Name
Size
Bytes
Class
coefs
1x142299
1138392
double array
data_name
1x6
12
char array
map
64x3
1536
double array
sizes
5x2
80
double array
valTHR
0x0
0
double array
wave_name
1x4
8
char array

Variables coefs and sizes contain the wavelet decomposition structure. Other variables contain the wavelet name, the colormap, and the filename containing the data. Variable valTHR is empty since the synthesized image is the same as the original one.

Loading Information into the Wavelet 2-D Tool

You can load images, coefficients, or decompositions into the graphical interface. The information you load may have been previously exported from the graphical interface, and then manipulated in the workspace; or it may have been information you generated initially from the command line.

In either case, you must observe the strict file formats and data structures used by the Wavelet 2-D tool, or else errors will result when you try to load information.

Loading Images.   This toolbox supports only indexed images. An indexed image is a matrix containing only integers from 1 to n, where n is the number of colors in the image.

This image may optionally be accompanied by an n-by-3 matrix called map. This is the colormap associated with the image. When MATLAB displays such an image, it uses the values of the matrix to look up the desired color in this colormap. If the colormap is not given, the Wavelet 2-D tool uses a monotonic colormap with max(max(X))-min(min(X))+1 colors.

To load an image you've constructed in your MATLAB workspace into the Wavelet 2-D tool, save the image (and optionally, the variable map) in a MAT-file (with extension mat or other).

For instance, suppose you've created an image called brain and want to analyze it in the Wavelet 2-D tool. Type

To load this image into the Wavelet 2-D tool, use the menu option FileLoadImage.

A dialog box appears that lets you select the appropriate MAT-file to be loaded.

Note that the coefficients, approximations, and details produced by wavelet decomposition are not indexed image matrices.

To display these images in a suitable way, the Wavelet 2-D tool follows these rules:

Loading Discrete Wavelet Transform Coefficients.   To load discrete wavelet transform (DWT) coefficients into the Wavelet 2-D tool, you must first save the appropriate data in a MAT-file, which must contain at least the two variables: coefficients vector coefs and bookkeeping matrix sizes.

Variable coefs must be a vector of concatenated DWT coefficients. The coefs vector for an n-level decomposition contains 3n+1 sections, consisting of the level-n approximation coefficients, followed by the horizontal, vertical, and diagonal detail coefficients, in that order, for each level. Variable sizes is a matrix, the rows of which specify the size of cAn, the size of cHn (or cVn, or cDn),..., the size of cH1 (or cV1, or cD1), and the size of the original image X. The sizes of vertical and diagonal details are the same as the horizontal detail.

After constructing or editing the appropriate data in your workspace, type

Use the FileLoad Coefficients menu option from the Wavelet 2-D tool to load the data into the graphical tool.

A dialog box appears, allowing you to choose the directory and file in which your data reside.

Loading Decompositions.   To load discrete wavelet transform decomposition data into the Wavelet 2-D tool, you must first save the appropriate data in a MAT-file (with extension wa2 or other).

The MAT-file contains the variables

Variable
Status
Description
coefs
Required
Vector of concatenated DWT coefficients
sizes
Required
Matrix specifying sizes of components of coefs and of the original image
wave_name
Required
String specifying name of wavelet used for decomposition (e.g., db3)
map
Optional
n-by-3 colormap matrix.
data_name
Optional
String specifying name of decomposition

After constructing or editing the appropriate data in your workspace, type

Use the FileLoadDecomposition menu option from the Wavelet 2-D tool to load the image decomposition data.

A dialog box appears, allowing you to choose the directory and file in which your data reside.


Previous page  Two-Dimensional Analysis Using the Graphical Interface Wavelets: Working with Images Next page

© 1994-2005 The MathWorks, Inc.