3. Performing Wavelet Transforms


3.1 Performing 1d Wavelet Transforms


3.1.1 Reading Data Files

To read a file of data into a Wavelet window, select the Read Data File... item from the File menu. You will then see the following dialog:

The file type buttons can be set to read either normal data (i.e. 1-d data values) or sorted/truncated wavelet coefficients (see section 4.1.7 on reading compressed data files). The data type buttons can be set to read either text data (normal ASCII text delimited by tabs, commas, spaces, or returns) or binary data.

Text files must be of type 'TEXT', while binary files must be of type 'WBIN'. Binary files can be created with Fortran, C, or other programs. The format for binary files is as follows:

      Number of points in data:   4-byte integer value
      Each data point:            4-byte real value
Binary files are much smaller than text, and read and write much faster.

After you have selected the file type and data type, click on OK. You will then be presented with a standard file dialog from which you can select the file to read. The data from this file will be displayed in the current window.


3.1.2 Performing a Discrete Wavelet Transform

The v2.00 MacWavelets program can perform periodic orthogonal discrete wavelet transforms and their inverses, from a variety of built-in or user-defined filter coefficients. The procedure for performing this transform is based on a multi-pass sparse-matrix multiplication by quadrature mirror filters, and includes input data wraparound at the far end of the forward transform, and at the near end of the inverse transform.

To perform a wavelet transform, first read (or create) data into a Wavelet window. Then, select the Perform DWT item from the Wavelets menu. This item will display a submenu of wavelet filter choices:

Select one of the submenu choices (e.g. Daubechies 4) to perform a wavelet transform using that set of filter coefficients.

In order to perform a transform, the length of your input data must be a power of 2. If your data is not a power of 2 in length, it will either be truncated to the next lowest power of 2 length, or padded to the next highest power of 2 length, depending on the Settings... item dialog in the Edit menu.

Once you have selected a filter type, the transform will be performed, and the result displayed in the current window, or in a new window, depending on the Settings... item dialog in the Edit menu. The discrete wavelet transform is a multi-step process. The total number of levels of analysis performed during this transform is also determined by the Settings... dialog.

Here is an example of the result of a wavelet transform:

Each resulting wavelet coefficient is displayed as one element of a 1-d array.


3.1.3 Using Custom Filters

You can also perform a transform using a custom set of filter coefficients. To use a custom filter, select the Custom... submenu item from the Perform DWT item of the Wavelets menu. You will then be prompted with a standard file dialog from which you can select a file of filter coefficients to use. This file must be in TEXT format, and contain the coefficients for the H and then the G quadrature mirror filters for the orthogonal transform you wish to perform. Each filter must have an even number of coefficients.


3.1.4 Creating a Scale Density Plot

Once you have performed a wavelet transform, you can display the resulting coefficients as a 2-d image. One such image is called a Scale Density Plot (SDP), because it arranges the coefficients from each level of the transform (each dyad) into different rows of the image, with the horizontal location of the coefficient corresponding to the relative position in the input dataset from which the coefficient is computed.

To create an SDP, first select a window containg a set of wavelet coefficients. Then, choose Create SDP from the Windows menu. Each row of the SDP corresponds to a different scale (spacial resolution) of features in the input dataset. The lowest 2 rows show the coarsest features, while the highest row shows the finest features. The numbers along the left side of the plot show the index of the first coefficient in each row. The value of each rectangle in the image is the absolute value of each coefficient, according to the color scale at right.

The name of the window, and the scale of the plot, can be set from the window's configuration dialog (available by double-clicking in the window or by choosing Configure Window... from the Edit menu) in the same way as for the 1-d Wavelet window.

Here is an example of an SDP and its input dataset. Note that to create an SDP you must first perform a wavelet transform, select the window containing the transform result, and then choose Create SDP from the Windows menu:


3.1.5 Creating a Scalegram

Once you have performed a wavelet transform, you can also create a Scalegram of the results. A Scalegram is a 1-d array which represents the average squared value of all coefficients in each dyad of the transform. Thus, if the input data array has 1024 points (2^10), a scalegram of a full transform of this array will have 11 points. Each point of the Scalegram represents one pass of the wavelet transform (except for the last pass, which contains two points), and thus one feature scale size of the input data, and shows the relative distribution of feature scales in the input.

To create a Scalegram, first perform a wavelet transform and select the window contaning the resulting wavelet coefficients. Then, choose Create Scalegram from the Windows menu. The Scalegram will be created in a new Wavelet window.

Here is an example of an input array and its Scalegram:


3.1.6 Performing an Inverse Discrete Wavelet Transform

To perform an inverse discrete wavelet transform, first select a Wavelet window containing wavelet coefficients (i.e. the results of a forward wavelet transform). Then choose the Perform Inverse DWT item of the Wavelets menu, and select one of the filter sets from the submenu of this item. You can also use a custom set of filters to perform the inverse transform by choosing the Custom... item of the submenu. You will then be prompted for a TEXT file contaning your filter coefficients.


3.1.7 Generating Wavelets

You can see the shape of various wavelet functions by choosing the Generate Wavelet... item of the Wavelets menu, and then choosing a specific filter from the attached submenu. You can also generate a wavelet shape based on a custom filter by choosing the Custom... item of the submenu.

Once you have chosen a filter to use, you will see the following dialog:

Type in the number of points you would like in the resulting curve, and the order of the wavelet you wish to generate (from 1 to the number of points). The default for this order is the number of coefficients in the corresponding filter (e.g. 4 for the Daubechies 4 filter). The wavelet shape will be generated by creating a vector which is equal to 1 at the element number of the order you entered, and which is zero everywhere else, and then performing an inverse wavelet transform on this vector. Click on OK to generate the wavelet shape.

Here is an example of the wavelet shape for the Daubechies 4 filter, with an order of 4:


3.1.8 Writing Data Files

To write a file of data from a Wavelet window, choose the Write Data File... item from the File menu. You will then see the following dialog:

Select the Text button to write an ASCII file (comma and return delimited), or select the Binary button to write a binary file. The format of a binary file is as follows:

      Number of points in data:   4-byte integer value
      Each data point:            4-byte real value
Click on OK. You will then see a standard Macintosh file dialog from which you can name your data file. Text files are written as type 'TEXT', and binary files are written as type 'WBIN'. Binary files can be read by the MacWavelets program, or from Fortran, C, or other programs.


Contents | Previous Section | Next Section


MacWavelets 2.00 User's Manual.
"MacWavelets" is a trademark of Intergalactic Reality.
© Copyright Intergalactic Reality, 1996.
All rights reserved.

Photoshop is a trademark of Adobe, Inc.