4. Performing Data Compression/Expansion


4.1 Performing 1d Compression/Expansion


4.1.1 Sorting Coefficients

To sort a set of wavelet coefficients, first select a Wavelet window containing the results of a wavelet transform. Then, choose the Sort Coeffs item from the Wavelets menu. Your coefficients will then be sorted in order of decreasing absolute magnitude.

Here is an example of a set of sorted coefficients:

Notice the glyph along the bottom of the sorted Wavelet window. This glyph tells you that the data in this window has been sorted (and can therefore be unsorted).


4.1.2 Truncating Coefficients

To truncate a set of sorted wavelet coefficients, choose the Truncate Coeffs... item from the Wavelets menu. You will then see the following dialog:

Truncating coefficients means throwing some of them away (i.e. setting their values to zero, and then resizing the array to eliminate them). The Truncate Coeffs... dialog allows you to truncate wavelet coefficients in 4 ways:

  1. Keep a number of coefficients. Select this item and fill in the number of coefficients to keep. The truncation operation will then keep those N coefficients with the largest absolute values, for whatever N you entered.
  2. Keep a percentage of coefficients. Select this item and fill in the percent of coefficients to keep. The truncation operation will then keep those N% coefficients with the largest absolute values, for whatever N% you entered.
  3. Keep all coefficients greater than or equal to some value. Select this item and fill in the smallest coefficient value you want to keep. The truncation operation will then keep only those coefficients with absolute values greater than or equal to the value you entered.
  4. Keep all coefficients greater than or equal to some percentage of the largest coefficient value. Select this item and fill in the smallest percentage value you want to keep. The truncation operation will then keep only those coefficients with absolute values greater than or equal to that percentage of the maximum coefficient value.

Here is an example of a truncation operation which kept 50% of the previous set of coefficients:


4.1.3 Unsorting Coefficients

To unsort a set of sorted or truncated coefficients, first select the Wavelet window containing the coefficients. Then, choose the Unsort Coeffs item from the Wavelets menu. The coefficients will then be unsorted back into their original order within the coefficient array.

Notice that when data is unsorted:

Once the coefficient array has been unsorted, it can be used in an inverse wavelet transform to reconstruct the original dataset.


4.1.4 Compressing Data

Two of the three previous processes (sorting, truncation), as well as performing an initial discrete wavelet transform, can be combined into a single step with the Compress... item of the Wavelets menu.

Choosing this item will perform the following steps in sequence:

  1. Present the Truncate Coeffs... dialog.
  2. Perform a discrete wavelet transform on the input dataset using a filter set you select.
  3. Sort the resulting wavelet coefficients.
  4. Truncate the sorted coefficients based on the Truncate Coeffs... dialog settings.

To perform a compression, first select a Wavelet window containing 1-d data. Then, choose the Compress... item of the Wavelets menu, and one of the filter items of the attached submenu. Whatever filter set you choose from the submenu will be used to perform the wavelet transform as part of the compression operation. You can also perform compression using a custom filter by choosing the Custom... item of the submenu.

Here is an example of an input dataset and its compressed coefficients, based on keeping 50% of the sorted coefficients:


4.1.5 Expanding Data

The Expand... item of the Wavelets menu will perform the following steps in sequence:

  1. Unsort (and restore to original length) a set of truncated wavelet coefficients.
  2. Perform an inverse wavelet transform of the unsorted coefficients using the filter set you select.

To perform an expansion, first select a Wavelet window containing truncated wavelet coefficients. Then, choose the Expand... item of the Wavelets menu, and one of the filter items of the attached submenu. Whatever filter set you choose from the submenu will be used to perform the inverse wavelet transform as part of the expansion operation. You can also perform expansion using a custom filter by choosing the Custom... item of the submenu.

Here is an example of an expansion of the previously compressed dataset:

Note that this dataset appears very similar to the original dataset, even though 50% of the intermediate wavelet coefficients were eliminated.


4.1.6 Comparing Reconstructed Data

Wavelet compression ratios of much greater than 2x can be achieved by using an appropriate set of wavelet filter coefficients for a given dataset. Usually, selecting a longer filter will also improve compression. Here is an example of performing the previous compression and expansion with the Beylkin 18 set of filter coefficients, keeping only 15% of the intermediate wavelet coefficients (i.e. a compression ratio of 6.67x):

To compare the reconstructed data to the original, you can subtract the original dataset from the reconstructed one. To do this, first select the window containing the reconstructed dataset. Then, choose the Subtract Datasets... item from the Wavelets menu. You will see the following dialog:

From the pop-up menu of windows (every 1d window in the current document), choose the Original window. When performing subtraction and other math operations, you may want to name your windows first, so that you can distinguish one from another in the pop-up menu. The result of subtracting the original dataset from the reconstruction looks like the following:

Note that the magnitude of the difference is at most about 0.1% of the original.

One way to measure the accuracy of reconstruction of the data is to look at the average sum of squared differences between the original and the reconstruction. This information is available from the Data Stats... item of the Edit menu. To see this infomation, select the window showing the subtracted dataset, and then choose the Data Stats... menu item. You should see the following:

When compressing data, you may want to try different wavelet filter sets and different truncation options, until you find the method that eliminates the most coefficients, while minimizing the average sum of squares difference between the original data and its reconstruction.


4.1.7 Reading Compressed Data Files

To read a previously saved set of sorted or truncated coefficients into a Wavelet window, choose the Read Data File... item from the File menu. In the following dialog, select the Sorted/truncated coeffs button:

You may select either the Text or Binary Data type: button. The format of a text file of sorted/truncated coefficients is the following:

      Original number of points in data:   Text value
      Each data point:                     Text value
      Index of each data point:            Text value
The format of a binary file of sorted/truncated coefficients is the following:

      Original number of points in data:   4-byte integer value
      Current number of points in data:    4-byte integer value
      Each data point:                     4-byte real value
      Index of each data point:            4-byte integer value
The original number of points is the length of the unsorted array. The index of each point is the position (0-based) that the point occupied in the unsorted array.


4.1.8 Writing Compressed Data Files

To write a file of sorted or truncated coefficients, simply choose the Write Data File... item from the File menu, and then choose either the Text or Binary data type from the dialog which follows.


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.