The WTN function returns a multi-dimensional discrete wavelet transform of the input array A. The transform is based on a Daubechies wavelet filter.
WTN is based on the routine
described in section 13.10 of
Numerical Recipes in C: The Art of Scientific Computing
(Second Edition), published by Cambridge University Press, and is used by permission.
This example demonstrates the use of IDL's discrete wavelet transform and sparse array storage format to compress and store an 8-bit gray-scale digital image. First, an image selected from the
data file is transformed into its wavelet representation and written to a separate data file using the WRITEU procedure.
Next, the transformed image is converted, using the SPRSIN function, to row-indexed sparse storage format retaining only elements with an absolute magnitude greater than or equal to a specified threshold. The sparse image is written to a data file using the WRITE_SPR procedure.
Now, we convert the wavelet representation of the image to a row-indexed sparse storage format using the SPRSIN function, write the data to a file using the WRITE_SPR procedure, and check the size of the "compressed" file.
Determine the number of elements (as a percentage of total elements) whose absolute magnitude is less than the specified threshold. These elements are not retained in the row-indexed sparse storage format.
This means the sparse array contains only 13% of the elements contained in the original array. Next, read the row-indexed sparse data back from the file
using the READ_SPR function and reconstruct the image from the non-zero data using the FULSTR function.
The image on the left is the original 256 by 256 image. The image on the right was compressed by the above process and was reconstructed from 13% of the original data. The size of the compressed image's data file is 26.6% of the size of the original image's data file. Note that due to limitations in the printing process, differences between the images may not be as evident as they would be on a high-resolution printer or monitor.