**Name**

**ezw** Wavelet transform compression via EZW algorithm

**Command Synopsis**

**ezw** [-p] [-r *NLevel*] [-w *WeightFac*] [-t *Threshold*] [-m *Max_Count_AC*] [-d] [-R *TargetRate*] [-P *TargetPSNR*] [-s *SelectArea*] [-o *Compress*] *WavTrans* *QWavTrans*

-p : Print full set of information

-rNLevel: Quantize wavelet transform up to level NLevel (Default : number of level in WavTrans)

-wWeightFac: Scaling factor for wavelet coefficients

-tThreshold: Fix initial threshold

-mMax_Count_AC: Number of counts for histogram in arithm. coding

-d : Computes distorsion-rate function

-RTargetRate: Target bit rate

-PTargetPSNR: Target PSNR

-sSelectArea: Polygonal regions to be encoded with a different rate or PSNR (polygons)

-oCompress: Output compressed representation of WavTrans (cimage)

WavTrans: Input wavelet transform (wtrans2d)

QWavTrans: Output quantized wavelet transform (wtrans2d)

**Function Summary**

void ezw (PrintFull , NumRec , WeightFac , Thres , Max_Count_AC , DistRate , Rate , PSNR , SelectedArea , Compress , Wtrans , Output , PtrDRC )

int *PrintFull ;

int *NumRec ;

float *WeightFac ;

float *Thres ;

int *Max_Count_AC ;

int *DistRate ;

float *Rate ;

float *PSNR ;

Polygons SelectedArea ;

Cimage Compress ;

Wtrans2d Wtrans ;

Wtrans2d Output ;

char *PtrDRC ;

**Description**

This module compresses the wavelet transform of an image using
Shapiro's EZW algorithm [Sha93].
It can produce both the compressed file and the quantized wavelet transform
(which can be reconstructed from the compressed file).

**Description of the algorithm**

This is a brief description of EZW algorithm. We refer the reader to [Sha93] for a full explanation.

The EZW algorithm is a two steps iterative algorithm. The first step
is called the *dominant pass,* and it alternates with the second step,
which is called the *subordinate pass.* Another important feature of
the EZW algorithm is that it strongly relies on the tree structure
of the wavelet transform.

- For the
*dominant pass,*a threshold*T*is chosen (usually it is the half of the threshold used for the preceding dominant pass). Each coefficient in the wavelet transform is compared to this threshold*T*; if its amplitude is bigger than*T*, then it is said significant, otherwise it is said non-significant and it is quantized to zero. If a coefficient is found significant for the first time (which means that it was found non-significant at the preceding dominant pass), then it is quantized to -3*T*/2 or 3*T*/2, according to its sign. If it was already found significant at the preceding dominant pass, then it is put on a list, called the*subordinate list*; its quantization shall be refined during the next subordinate pass.During the dominant pass, one constructs a

*significance map*by associating to each coefficient in the wavelet tree a symbol, according to its significance. More precisely, among significant coefficients, one distinguishes between coefficients which have already be found significant at a preceding dominant pass, coefficients which are newly significant and positive, and coefficients which are newly significant and negative. Among coefficients which are non-significant, one distinguishes between those which are*isolated zero*(which means that one of their descendents is significant), those which are*zero tree root*(which means that all their descendents are non-significant, and their parent is significant or isolated zero), and those which are part of a zero tree (which means that they are a descendent of a zero tree root).To encode the changes in the significance map, one scans the wavelet tree, beginning with the root and following an order such that a parent is scanned before its children. For each coefficient, one encodes 0 if it is a zero tree root, 1 if it is an isolated zero, 2 if it is newly significant positive, 3 if it is newly significant negative, and nothing otherwise. This list of symbols (with a four-letters alphabet) is arithmetically encoded [WNC87] using a customized version of the algorithm presented in [Sha93]).

- During the
*subordinate pass*one refines the quantization of the coefficients on the subordinate list (those coefficients which have been found significant). This is done by dividing by two the incertitude interval of their value. More precisely, this incertitude interval has always the form [2*nT*,(2*n*+ 2)*T*[ (which means that the coefficient is quantized to (2*n*+ 1)*T*). Thus, one checks if the wavelet coefficient in the original transform is bigger or smaller than (2*n*+ 1)*T*, and encodes the information (which requires one bit). The incertitude interval then becomes [2*nT*,(2*n*+ 1)*T*[ or [(2*n*+ 1)*T*,(2*n*+ 2)*T*[. Again, the resulting sequence of bits is arithmetically encoded.The threshold

*T*is divided by two for the next dominant pass.

For the first dominant pass, one has to choose an initial threshold.
This should be preferably smaller than the amplitude *S* of the biggest
wavelet coefficient in the transform, and larger than *S*/2.

An important feature of the algorithm is that one can compute at any moment
the number of bit transmitted or encoded, as well as the error between
the original and the quantized wavelet transform. Thus one can stop
the algorithm whenever a target bit rate or SNR (error) is reached.
This is the *progressive transmission* capability of the EZW algorithm.

**Options**

- *p* :

- *r* *NLevel* :

- *w* *WeightFac* :

:

- *t* *Threshold* :

- *d* :

- *R* *TargetRate* :

- *P* *TargetPSNR* :

- *s* *SelectArea* :

- *o* *Compress* :

**Input**

*WavTrans* is a wavelet transform of an image in the Wtrans2d format.
It is the wavelet transform to be compressed.

**Output**

*QWavTrans* is a wavelet transform of an image in the Wtrans2d format.
It is the result of the quantization of *WavTrans*. It can be reconstructed
from *Compress*.

**See Also**

`fezw`.

**Version 1.30**

Last Modification date : Thu Nov 29 20:23:57 2001

**Author**

Jean-Pierre D'Ales