Help Lloyds

3
Non Uniform Quantization Functions Optimal Output Alphabets and Levels LLOYD S: Optimize quantization para meter s using the Lloyd algorith m. [PART ITIO N, CODEBOOK] = LLOYDS(TRAINING _SET , INI_CODEBOOK) opti mizes the sca lar qua nti zation PAR TITION and COD EBO OK bas ed on the pro vided tra ini ng vec tor TRA INING_SET usi ng the Llo yd algori thm . The dat a in the var iable TRA NIN G_SET sho uld be typ ica l data for the mes sag e source to be qua nti zed . INI_CODEBOOK is the ini tia l gue ss of the codebook val ues. The opt imized CODEBOOK has the sam e vec tor siz e as INI_CODEBOOK. Whe n INI_CODEBOOK is a scalar int ege r instead of vec tor, it is the len gth of the des ired CODEBO OK vec tor . PAR TIT ION is a vec tor with the vec tor length bei ng the CODEBOOK vector length  minus 1. The optimization will be terminated if the relative dis tortio n is less tha n 10^ (-7 ). [PART ITIO N, CODEBOOK] = LLOYDS(TRAINING _SET , INI_CODEBOOK, TOL) provi des the tole rance in the opti mizat ion. [PART ITIO N, CODEBOOK, DISTORTIO N] = LLOY DS(.. .) outpu ts the final disto rtio n valu e. [PART ITIO N, CODEBOOK, DISTORTION, REL_DISTO RTION ] = LLOYD S(... ) outputs the relative dis tor tion val ue in ter min ating the computation. See also QUANTIZ, DPCMOPT . Non-Uniform Quantization QUANTIZ: Pro duce a quantization index and a qua nti zed out put val ue. INDX = QUANTI Z(S IG, PAR TIT ION) produces a quantization index INDX of the input sig nal SIG based on the decision points PAR TIT ION. Eac h element in INDX is one of the N integers in range [0 : N-1]. PAR TITION is a strict asc end ing ord ered N-1 vec tor tha t spe cifies the boundaries. Elements of INDX = 0, 1, 2, ..., N-1 represent SIG in the range of (-In f, PARTI TION (1)], (PARTITI ON(1) , PART ITION (2)], (PART ITIO N(2), PARTI TION( 3)], ..., (PART ITION (N-1 ), Inf). [INDX , QUANT ] = QUAN TIZ(S IG, PARTI TION, CODEBOOK ) produces the output value of the quantiz er in QUANT. CODEBOO K is a length N vec tor tha t contains the out put set .

Transcript of Help Lloyds

Page 1: Help Lloyds

8/12/2019 Help Lloyds

http://slidepdf.com/reader/full/help-lloyds 1/3

Non Uniform Quantization Functions

Optimal Output Alphabets and Levels

LLOYDS: Optimize quantization parameters using the Lloyd algorithm.

[PARTITION, CODEBOOK] = LLOYDS(TRAINING_SET, INI_CODEBOOK) optimizes

the scalar quantization PARTITION and CODEBOOK based on the provided

training vector TRAINING_SET using the Lloyd algorithm. The data in

the variable TRANING_SET should be typical data for the message

source to be quantized. INI_CODEBOOK is the initial guess of the

codebook values. The optimized CODEBOOK has the same vector size as

INI_CODEBOOK. When INI_CODEBOOK is a scalar integer instead of

vector, it is the length of the desired CODEBOOK vector. PARTITIONis a vector with the vector length being the CODEBOOK vector length

 minus 1. The optimization will be terminated if the relative

distortion is less than 10^(-7).

[PARTITION, CODEBOOK] = LLOYDS(TRAINING_SET, INI_CODEBOOK, TOL)

provides the tolerance in the optimization.

[PARTITION, CODEBOOK, DISTORTION] = LLOYDS(...) outputs the final

distortion value.

[PARTITION, CODEBOOK, DISTORTION, REL_DISTORTION] = LLOYDS(...)

outputs the relative distortion value in terminating thecomputation.

See also QUANTIZ, DPCMOPT.

Non-Uniform Quantization

QUANTIZ: Produce a quantization index and a quantized output value.

INDX = QUANTIZ(SIG, PARTITION) produces a quantization index INDX of

the input signal SIG based on the decision points PARTITION. Each

element in INDX is one of the N integers in range [0 : N-1].

PARTITION is a strict ascending ordered N-1 vector that specifies

the boundaries. Elements of INDX = 0, 1, 2, ..., N-1 represent SIGin the range of (-Inf, PARTITION(1)], (PARTITION(1), PARTITION(2)],

(PARTITION(2), PARTITION(3)], ..., (PARTITION(N-1), Inf).

[INDX, QUANT] = QUANTIZ(SIG, PARTITION, CODEBOOK) produces the

output value of the quantizer in QUANT. CODEBOOK is a length N

vector that contains the output set.

Page 2: Help Lloyds

8/12/2019 Help Lloyds

http://slidepdf.com/reader/full/help-lloyds 2/3

[INDX, QUANT, DISTOR] = QUANTIZ(SIG, PARTITION, CODEBOOK) outputsDISTOR, the estimated distortion value of the quantization. There is

no decode quantizer function in this toolbox. The decode computation

can be done using the command Y = CODEBOOK(INDX+1).

See also LLOYDS, DPCMENCO, DPCMDECO.

Page 3: Help Lloyds

8/12/2019 Help Lloyds

http://slidepdf.com/reader/full/help-lloyds 3/3

0 500 1000 1500 2000 2500 3000

−4

−3

−2

−1

0

1

2

3

4

TIME SAMPLES

   R   E   A   L   I   Z   A   T   I   O   N

   O   F

   I   N   P   U   T

   S   O   U   R   C   E

LLOYD−MAX, GAUSSIAN PDF, N = 3000

(a)

−4 −3 −2 −1 0 1 2 3 40

100

200

300

400

500

600

700

800

900

RANGE OF INPUT , x[n]

   #

   O   F

   O   B   S   E   R   V   A   T   I   O   N   S

LLOYD−MAX, GAUSSIAN PDF, N = 3000

(b)

0 500 1000 1500 2000 2500 3000−0.02

−0.015

−0.01

−0.005

0

0.005

0.01

0.015

0.02

0.025

TIME SAMPLES

   Q   U   A   N   T   I   Z   A   T   I   O   N

   E   R   R   O   R

 ,

  x  q   [  n   ] −  x   [  n   ]

LLOYD−MAX, GAUSSIAN PDF, N = 3000, W = 8 bits, tol = 10−6

(c)

Figure 1: Lloyd Max quantization: (a) sample realization of standard Gaus-sian distributed input, (b) histogram of Gaussian distributed input, and (c)

quantization error of the non uniform quantizer for a word-length of 8 bits.