Wavelet Image Compression Library

3.4.0

Author:
Daniel Vollmer <>
Date:
2007-07-10
Attention:
Online documentation, Kompressor.app (Mac OS 10.4 Universal), source code, and Mercurial repository

Kompressor.app

There now is a graphical user-interface for Mac OS 10.4 called Kompressor.app, which can be used to easily create, inspect and modify ".wko" files. It exercises most features of the library and can open files from the wako command-line compressor (of the same library version). Feedback on the application and its UI is much appreciated, it's my first proper try of a Mac OS / Cocoa application.

Example code

The included command-line application (in main.c) (badly) illustrates the use of the rest of the library. It can be used to compress and decompress .raw images and handles color-space conversion by remembering the colorspace of each channel in its retained data.

To build an executable on Mac OS or Linux use the following: gcc -O2 -W -Wall -lm *.c -o wako

Many command-line parameters (such as -offset and -mse for example) can be given repeatedly and are then set for the current channel and onwards until the option is changed again, for example ./wako -y 1 -i test_r.raw -mse 2.0 -i test_g.raw -mse 4.0 -i test_b.raw uses a maximum MSE of 2.0 for the Y channel (as we specified color-space conversion with -y), and 4.0 for the two color channels.

Usage in your own program

The functions provided by the library usually work on channels, e.g. the red channel of an RGB image, or the Y channel of a YCrCb image. By default, it supports up to 16 channels in a single file, all of which have to have matching dimensions. The compile-time configuration and types can be changed in config.h to allow for higher bit-depths or more channels, etc.

Compression

To compress an image, you simply do the following:
  1. Create a reorder-table that is used for permuting coefficients for the size of channels you are about to compress with wv_create_reorder_table().
  2. Initialize each channel with wv_channel_compact() to obtain a t_wv_channel handle. You can then free the original data.
  3. Free the reorder-table with wv_free_reorder_table() if you won't need it again for channels of the same size.
  4. Optionally, request information on whether the given settings will work and how much error the would approximately yield with wv_query_scheduler().
  5. Write the channels to a t_bit_file with wv_encode(), giving the requested maximum errors and / or size as parameters.
  6. Free the t_wv_channel handles with wv_channel_free().

Decompression

To decompress an image again, you essentially reverse the above process:
  1. Read a set of t_wv_channel from a t_bit_file with wv_decode(). You can either manually read the header (if you want to know the dimensions beforehand for example) and provide it to wv_decode(), or let wv_decode() read it.
  2. Create a reorder-table with wv_create_reorder_table() with the dimensions from the t_wv_channel (unless you already have a table for that size or one for an exact multiple of the dimensions used).
  3. Use wv_channel_uncompact() to get the original image data back. You can then free the t_wv_channel handle.
  4. Free the reorder-table with wv_free_reorder_table() (if not needed for anything else).

Further Reading

For more information on how the code operate, have a look at the following pages, whose order is similar to the actual coding process.
  1. Algorithm Overview
  2. Wavelet Transform
  3. Reordering Process
  4. Coding Process

License

This code is licensed under a zlib-license, which can be found at the top of each source-file.
Generated on Tue Jul 10 20:44:34 2007 for wavelet by  doxygen 1.5.2