**Name**

**wlbg_adap** Generates training set(s) (starting from wavelet transform(s)) and constructs a codebook sequence for wavelet transform vector quantization using LBG algorithm

**Command Synopsis**

**wlbg_adap** [-r *MaxLevel*] [-q *Level*] [-o *Orient*] [-d *Dyad*] [-l] [-e *Edge*] [-w *VectorWidth*] [-h *VectorHeight*] [-M] [-s *Sizec1*] [-t *Size2*] [-u *Size3*] [-S *ThresVal1*] [-T *ThresVal2*] [-U *ThresVal3*] [-O *OldCodeBook*] [-X *OldAdapCodeBook1*] [-Y *OldAdapCodeBook2*] [-x *AdapCodeBook2*] [-y *AdapCodeBook3*] [-A *TrainWavTrans2*] [-B *TrainWavTrans3*] [-C *TrainWavTrans4*] [-Q *ResCodeBook*] [-R *ResResCodeBook*] *TrainWavTrans1* *CodeBook1*

-rMaxLevel: Quantization is performed on MaxLevel scales

-qLevel: Create codebook(s) at scale Level

-oOrient: Create codebook(s) for orientation Orient

-dDyad: Training wav. trans. are dyadic from scale Dyad

-l : Take overlapping vectors in training images

-eEdge: Do not take overlapping vectors if the distance to an edge is smaller than Edge (default : 0)

-wVectorWidth: Width of vectors (default : 2)

-hVectorHeight: Height of vectors (default : 2)

-M : Generate codebooks of size equal to a power of two

-sSizec1: Size of output codebook for first class

-tSize2: Size of output codebook for second class

-uSize3: Size of output codebook for third class

-SThresVal1: First threshold value for classified VQ

-TThresVal2: Second threshold value for classified VQ

-UThresVal3: Third threshold value for classified VQ

-OOldCodeBook: Modify the first class codebook sequence (wtrans2d)

-XOldAdapCodeBook1: Modify the second class codebook sequence (wtrans2d)

-YOldAdapCodeBook2: Modify the third class codebook sequence (wtrans2d)

-xAdapCodeBook2: Sequence of second class codebooks (wtrans2d)

-yAdapCodeBook3: Sequence of third class codebooks (wtrans2d)

-ATrainWavTrans2: Training wavelet transform (wtrans2d)

-BTrainWavTrans3: Training wavelet transform (wtrans2d)

-CTrainWavTrans4: Training wavelet transform (wtrans2d)

-QResCodeBook: Generate codebook(s) for residu of quantization with ResCodeBook (wtrans2d)

-RResResCodeBook: Generate codebook(s) for residu of quantization with ResCodeBook and ResResCodeBook (wtrans2d)

TrainWavTrans1: Training wavelet transform (wtrans2d)

CodeBook1: Sequence of first class codebooks (wtrans2d)

**Function Summary**

void wlbg_adap (NumRecMax , Level , Orient , Dyadic , Lap , Edge , Width , Height , MultiCB , Sizec1 , Sizec2 , Sizec3 , ThresVal1 , ThresVal2 , ThresVal3 , OldCodeBook , OldAdapCodeBook2 , OldAdapCodeBook3 , Output2 , Output3 , TrainWtrans2 , TrainWtrans3 , TrainWtrans4 , ResCodeBook , ResResCodeBook , TrainWtrans1 , Output1 )

int *NumRecMax ;

int *Level ;

int *Orient ;

int *Dyadic ;

int *Lap ;

int *Edge ;

int *Width ;

int *Height ;

int *MultiCB ;

int *Sizec1 , *Sizec2 , *Sizec3 ;

float *ThresVal1 , *ThresVal2 , *ThresVal3 ;

Wtrans2d OldCodeBook ;

Wtrans2d OldAdapCodeBook2 , OldAdapCodeBook3 ;

Wtrans2d *Output2 , *Output3 ;

Wtrans2d TrainWtrans2 , TrainWtrans3 , TrainWtrans4 ;

Wtrans2d ResCodeBook , ResResCodeBook ;

Wtrans2d TrainWtrans1 ;

Wtrans2d *Output1 ;

**Description**

This module generates a sequence fo codebooks adapted
for classified and/or residual vector quantization
of image wavelet tranforms.
It is based on the LBG algorithm (see *flbg_train* documentation),
and it operates on training sets of wavelet coefficients vectors.

The training sets of wavelet coefficients vectors which are necessary
for the LBG algorithm are build using the wavelet transforms
read in the files *TrainWavtrans1*, ..., *TrainWavtrans4*.
Notice that one training set is generated separately for each subimage
of the wavelet transform (this training set can be further divided
in sub-training sets if codebooks for classified vector quantization
are generated).

The only difference here is that there is a possiblity of stopping the decimation in the subband decomposition using the -d option. StopDecimLevel is a positive integer. From this level on, the decimation is not performed. This enables to obtain larger training sets.

The -q option specifies that only the codebooks at scale Level should be generated (Level is a positive integer).

The -o option specifies that only the codebooks in orientation Orient should be generated (Orient is an integer ranging from 0 to 3). Here Orient is 0 for average, 1 for horizontal details, 2 for vertical details, and 3 for diagonal details. Notice that if the option -o is not selected, then the average subimage is generated only at level MaxLevel.

The -h and -w options specify the height and width of vectors. Here the codebooks for higher levels are generated first. When going to a lower scale, VectorWidth and VectorHeight are multipied by 2, unless they are bigger than 2, or the size of the subimage is less than 128×128 (This is done because the size of the vectors must be negligible compared to the subimage size).

If the -l option is selected, then overlapping vectors are taken in the wavelet transform. This enables to get larger training sets.

CodeBook1, AdapCodeBook2 and AdapCodeBook3 contain the sets of generated codebooks for the first, second and third classes respectively.

If the -M option is selected, then codebooks for each power of two is generated, with size ranging from 1 to Size1, Size2 or Size3 (respectively for CodeBook1, AdapCodeBook2 and AdapCodeBook3). If it is not selected then only one codebook of size Size1, Size2 or Size3 is generated.

The -s, -t, -u, -S, -T and -U options have the same meaning as for
*flbg_adap*.

The -W, -M and -p options have the same effect as in *flbg_train*
module.

The -Q and -R options enable to generate codebooks adapted to multistaged vector quantization. If for example the -Q option is selected then the input set of codebooks in ResCodeBook is used to quantize the training set, and the residual errors of this quantization are used to form a new codebook. The process can be iterated with the -R option. Notice that these options should not be used in conjonction with the -x and -y options.

The -O, -X, -Y options enable to modify existing codebook(s). This can be used in conjonction with the -q and -o options. It can be used for example to generate the codebooks for the different subimages separately, in order to get customized sizes of codebooks and vectors.

**See Also**

**Version 2.00**

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

**Author**

Jean-Pierre D'Ales