Two sets of quantizers are included. The first set performs a uniform quantization and is fairly straightforward. The second is an embedded family of quantizers fully described in D. Taubman and A. Zakhor, "Multirate 3-D subband coding of video", IEEE Transactions on Image Processing, Vol 3, No. 5, Sept, 1994. The quantizers are equivalent to those used in J. Shapiro, "Embedded image coding using zerotrees of wavelet coefficients," IEEE Transactions on Signal Processing, Vol. 41, No. 12, pp. 3445--3462, Dec. 1993, but are coupled with a more effective entropy coding scheme. Two sets of adaptive entropy coding schemes are also included. The first performs histogram adaptation with escape codes. The escape codes keeps rare symbols from adding too much to the overall symbol cost during early stages of histogram adaptation (see _Text Compression_ by Bell, Cleary, and Witten for details). The second coder is an embedded coder designed for use with the embedded quantizer above (See Taubman and Zakhor for full details). It adapts very quickly and is very effective. The arithmetic coder is based on an implementation of Alistair Moffat's linear time coding histogram (see http://www.cs.mu.oz.au/~alistair/papers.html). The implementation is courtesy of John Danskin, and the full distribution (most of which is included here) may be obtained from http://www.cs.dartmouth.edu/~jmd. The bit allocation routines are based on integer programming algorithms described in Y. Shoham and A. Gersho, "Efficient bit allocation for an arbitrary set of quantizers," IEEE Transactions on Acoustics, Speech, and Signal Processing, Vol. 36, No. 9, pp. 1445-1453, Sept 1***8. They provide optimal or near-optimal allocations for the quantizers included here. --------------------------------------------------------------------------- Executables ----------- encode Code an image Usage: encode [image][width][height][output][ratio] image: image to be compressed width, height: width and height of image to be compressed output: name of compressed image ratio: target compression ratio decode Decode an image Usage: decode [encoded image][decoded image] compare Compare two pbm/pgm images. Returns MSE, RMS error, and PSNR Usage: compare [image 1][image 2][width][height] raw2pgm Convert an image in raw/raster format to PGM Usage: raw2pgm [raw image name][height][width][pgm image name] pgm2raw Convert an image in pgm/pbm format to a raw/raster format Usage: pgm2raw [pgm image name][raw image name] The source files in this directory can be broken up into several main classes, each pertaining to one of the above steps plus some global stuff. Global Stuff ------------ encode.cc Main encoding program -- puts together all steps in the coding process decode.cc Main decoding program -- puts together all steps in the decoding process compare.cc Useful utility for comparing images pgm2raw.cc Format conversion: pgm->raw raw2pgm.cc Format conversion: raw->pgm global.cc, global.hh Location of global functions and definitions Transform Step -------------- The routines below take an image (in pbm/pgm format) and perform a 2-D wavelet transform. image.cc, image.hh Handles loading/saving raw, pbm images wavelet.cc, wavelet.hh Performs a wavelet transform on an image. Handles non-square images (with aspect ratio < 2:1). Uses symmetric extension of boundaries for symmetric filters and periodic extension for asymmetric ones. filter.cc Contains filter coefficients for various wavelets. Contains all filters from J. Villasenor, B. Belzer, J. Liao, "Wavelet Filter Evaluation for Image Compression." IEEE Transactions on Image Processing, Vol. 2, pp. 1053-1060, August 1995 transform.cc, transform.hh Breaks wavelet transformed images up into subbands. This makes postprocessing more convenient and also independent of the method of transform (e.g. iterated filtering, lifting, etc.) Quantization Step ----------------- These routines take subsets of the transform coefficients (typically a subset corresponds to all coefficients in a given subband) and determine appropriate quantizer precisions for each subset. Quantizer resolutions are chosen to minimize total quantization error subject to a constraint on the total number of bits required to store the quantized coefficients. coeffset.cc, coeffset.hh Storage for different subsets of coefficients. Also stores total bit cost (rate) and total distortion for each quantizer resolution. metric.hh Functions for determining total quantization error. The most common error measure is squared distortion. quantizer.cc, quantizer.hh Quantizes coefficients at various resolutions. allocator.cc, allocator.hh Uses a constrained optimization procedure to determine quantizer resolutions for each set of coefficients. Entropy Coding Step ------------------- entropy.cc, entropy.hh High-level entropy coding routines. Writes/reads coefficients. Allows use of adaptive histograms and context-based coding. coder.cc, coder.hh High-level I/O interface for entropy coding routines above. Also allows efficient coding of individual bits and arbitrarily sized integers. Arith.cc, Arith.h Low-level arithmetic coding routines. Based on an implementation of Alistair Moffat's linear time coding histogram by John Danskin. The full distribution may be obtained from (http://www.cs.dartmouth.edu/~jmd) iHisto.cc, iHisto.h More low-level arithmetic coding routines from the above package. IntCoding.cc, IntCoding.hh Integer coding routines for coder.cc courtesy of John Danskin. BitIO.cc, BitIO.h Bit-level I/O routines from John's package. Wish list for future improvements (send me your code!) ------------------------------------------------------ * Modify wavelet.cc and transform.cc to handle images with different aspect ratios (shouldn't be too hard). * Add support for color! The easiest way to do this would be to take an RGB image and to transform it to something like YIQ or HUV and then code each layer separately. * Upgrade image.cc to support more image formats. Read/write .tiff's, .gif's, etc. * Add Lloyd-Max scalar quantizers. * Add trellis coding to reduce quantization errors. * Add zerotrees. * Add an 8x8 block DCT so that the code can be modified to do JPEG. * Add an 8x8 block DCT with folding. * Implement wavelet transform via lifting to improve speed. * Fix arithmetic coder so can switch back & forth between coding and writing ints/bits. * Upgrade the dequantize routines, the entropy coder, and the arithmetic coder so that the code can handle truncated bitstreams.