Products & Services Solutions Academia Support User Community Company

Importing and Exporting from Graphical Tools

The Wavelet Packet 1-D and Wavelet Packet 2-D tools let you import information from and export information to your disk.

If you adhere to the proper file formats, you can

Saving Information to Disk

Using specific file formats, the graphical tools let you save synthesized signals or images, as well as one- or two-dimensional wavelet packet decomposition structures. This feature provides flexibility and allows you to combine command line and graphical interface operations.

Saving Synthesized Signals

You can process a signal in the Wavelet Packet 1-D tool, and then save the processed signal to a MAT-file.

For example, load the example analysis:

FileExample Analysisdb1 - depth: 2 - ent: shannon --> sumsin

and perform a compression or de-noising operation on the original signal. When you close the Wavelet Packet 1-D De-noising or Wavelet Packet 1-D Compression window, update the synthesized signal by clicking Yes in the dialog box.

Then, from the Wavelet Packet 1-D tool, select the FileSaveSynthesized Signal menu option.

A dialog box appears allowing you to select a directory and filename for the MAT-file. For this example, choose the name synthsig.

To load the signal into your workspace, simply type

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

Saving Synthesized Images

You can process an image in the Wavelet Packet 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 Analysisdb1 - depth: 1 - ent: shannon --> woman

and perform a compression on the original image. When you close the Wavelet Packet 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. For this example, choose the name wpsymage.

To load the image into your workspace, simply type

The synthesized image is given by X. The variable map contains the associated 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 One-Dimensional Decomposition Structures

The Wavelet Packet 1-D tool lets you save an entire wavelet packet decomposition tree and related data to your disk. The toolbox creates a MAT-file in the current directory with a name you choose, followed by the extension wp1 (wavelet packet 1-D).

Open the Wavelet Packet 1-D tool and load the example analysis:

FileExample Analysisdb1 - depth: 2 - ent: shannon --> sumsin

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

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

After saving the decomposition data to the file wpdecex1d.wp1, load the variables into your workspace.

The variable tree_struct contains the wavelet packet tree structure. The variable data_name contains the data name and valTHR contains the global threshold, which is currently empty since the synthesized signal does not exist.

Saving Two-Dimensional Decomposition Structures

The file format, variables, and conventions are exactly the same as in the one-dimensional case except for the extension, which is wp2 (wavelet packet 2-D). The variables saved are the same as with the one-dimensional case, with the addition of the colormap matrix map:

Name
Size
Bytes
Class
data_name
1x5
10
char array
map
255x3
6120
double array
tree_struct
1x1
527400
wptree object
valTHR
1x1
8
double array

Save options are also available when performing de-noising or compression inside the Wavelet Packet 1-D and Wavelet Packet 2-D tools.

In the Wavelet Packet De-Noising windows, you can save the de-noised signal or image and the decomposition. The same holds true for the Wavelet Packet Compression windows.

This way, you can save directly many different trials from inside the De-Noising and Compression windows without going back to the main Wavelet Packet windows during a fine-tuning process.

Loading Information into the Graphical Tools

You can load signals, images, or one- and two-dimensional wavelet packet decompositions into the graphical interface tools. 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 graphical tools, or else errors will result when you try to load information.

Loading Signals

To load a signal you've constructed in your MATLAB® workspace into the Wavelet Packet 1-D tool, save the signal in a MAT-file (with extension mat or other).

For instance, suppose you've designed a signal called warma and want to analyze it in the Wavelet Packet 1-D tool.

The workspace variable warma must be a vector.

To load this signal into the Wavelet Packet 1-D tool, use the menu option FileLoad Signal.

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

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 a 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 Packet 2-D graphical 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 Packet 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 Packet 2-D tool. Type

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

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

Caution The graphical tools allow you to load an image that does not contain integers from 1 to n. The computations will be correct since they act directly on the matrix, but the display of the image will be strange. The values less than 1 will be evaluated as 1, the values greater than n will be evaluated as n, and a real value within the interval [1,n] will be evaluated as the closest integer.

Note that the coefficients, approximations, and details produced by wavelet packets decomposition are not indexed image matrices. To display these images in a suitable way, the Wavelet Packet 2-D tool follows these rules:

Loading Wavelet Packet Decomposition Structures

You can load one- and two-dimensional wavelet packet decompositions into the graphical tools providing you have previously saved the decomposition data in a MAT-file of the appropriate format.

While it is possible to edit data originally created using the graphical tools and then exported, you must be careful about doing so. Wavelet packet data structures are complex, and the graphical tools do not do any consistency checking. This can lead to errors if you try to load improperly formatted data.

One-dimensional data file contains the following variables:

Variable
Status
Description
tree_struct
Required
Object specifying the tree structure
data_name
Optional
String specifying the name of the decomposition
valTHR
Optional
Global threshold (can be empty if neither compression nor de-noising has been done)

These variables must be saved in a MAT-file (with extension wp1 or other).

Two-dimensional data file contains the following variables:

Variable
Status
Description
tree_struct
Required
Object specifying the tree structure
data_name
Optional
String specifying the name of the decomposition
map
Optional
Image map
valTHR
Optional
Global threshold (can be empty if neither compression nor de-noising has been done)

These variables must be saved in a MAT-file (with extension wp2 or other).

To load the properly formatted data, use the menu option FileLoad Decomposition Structure from the appropriate tool, and then select the desired MAT-file from the dialog box that appears.

The Wavelet Packet 1-D or 2-D graphical tool then automatically updates its display to show the new analysis.


 Provide feedback about this page 

Previous page Two-Dimensional Wavelet Packet Analysis Advanced Concepts Next page

Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS