• No results found

Chapter 3 - Data Compression

3.5 Stream codes

3.6.1 Scalar quantization

With scalar quantization the entities being quantized are scalars — ordinary real numbers. In general quantization is achieved by selecting certain input intervals and for each such interval selecting a value that will represent all the values contained in that interval. The endpoints of the intervals are called the decision boundaries, and can be denoted by di. The representative values for each interval are called reconstruction levels, and can be denoted by yi. Figure3.6 illustrates a generic quantizer. If M intervals are specified then the resulting quantizer is called an M-level quantizer. Note that for an M-level quantizer there will always be M+ 1 decision boundaries; the first decision boundary may be designated by d0. With these definitions we can now formalize the operation of a quantizer as a function Q(x):

Q(x)= yi ⇐⇒ di−1< x ≤ di

The difference between the original signal and the quantized signal, x − Q(x), is called the quantization error. The quantization error can also be seen as a kind of additive “noise” that influences the original signal, producing the quantized signal. Modelling the quantization error as additive noise is sometimes beneficial conceptually.

3.6. QUANTIZATION 45

Figure 3.6: Generic scalar quantization.

The amount of quantization error can be characterized by the mean squared error between the original signal and the quantized signal, as follows:

σ2q= Z

−∞

[x − Q(x)]2p(x)dx

where p(x) is the probability density function governing the behaviour of the input values x.

Using the definition of Q(x) the expression above can be written more explicitly as:

σ2q=

M

X

i=1

Z di

di−1

(x − yi)2p(x)dx (3.5) These definitions enable us to state the problem of quantizer design as follows [70]: given an input probabability distribution function, p(x), and the number of levels M in the quantizer, find the decision boundaries diand the reconstruction levels yiso as to minimize the mean squared quantization error.

An important property of scalar quantizers is whether they include zero as one of their reconstruction levels. For many applications this is important, an example being lossy audio compression where it is important to be able to accurately represent silence, a zero value. Quantizers including zero as a reconstruction value are called midtread quantizers while those that do not are

called midrise quantizers. Figure3.7illustrates the difference between these two types of quantizers.

(a) Midrise quantizer. (b) Midtread quantizer.

Figure 3.7: Midrise and midtread quantizers.

It should also be noted that the scalar quantization operators as defined here commute with all compositions of the basic LULU operators as mentioned in Section2.4.3.6.

3.6.1.1 Uniform quantization

The uniform quantizer is a quantizer where both the decision boundaries and reconstruction levels are evenly spaced, so that they are all the same size, i.e.

they are all uniform, except for possibly the two outer intervals which may be infinite in size, which might be the case when dealing with a large input range.

The constant spacing of the decision boundaries and reconstruction levels is called the step size,∆ [70].

The expression for the mean squared error of a uniform quantizer can be found by using equation3.5and the fact that the decision boundaries diand the reconstruction levels yiare governed by the step size∆. After some algebra this becomes:

σ2q(∆) = 2

M 2−1

X

i=1

Z i∆

(i−1)∆



x −2i − 1 2 ∆2

p(x)dx

+2 Z

(M2−1)



x −M − 1 2 ∆2

p(x)dx (3.6)

Designing an optimal uniform quantizer for an input with a probability distribution p(x) amounts to finding the value of∆ that minimizes equation 3.6. This can be done by taking the derivative of equation3.6, setting it to zero, and solving for∆.

3.6. QUANTIZATION 47

2q d∆ = −

M 2−1

X

i=1

(2i − 1) Z i

(i−1)



x −2i − 1 2 ∆

p(x)dx

−(M − 1) Z

(M2−1)



x −M − 1 2 ∆

p(x)dx= 0 (3.7)

Due to the complexity of this equation and the presence of a possibly non-analytic probability distribution function p(x) it is usually solved numerically.

3.6.1.2 Nonuniform quantization

Like its name suggests, a nonuniform quantizer is a quantizer where the decision boundaries and reconstruction levels are not evenly spaced. This is motivated by the observation that the distortion caused by quantization can be mini-mized if we represent values that have a high probabality of occurring more accurately than other less probable values. This amounts to decreasing the spacing between the decision boundaries for sections of input that have a high probability of occurring [70]. The effect of this scheme on the quantization error can be seen directly when looking at Equation3.5.

Figure 3.8: Non-uniform quantization.

While the basic problem of nonuniform quantization can be approached in the same way as uniform quantization, that is, finding the decision

bound-aries and reconstruction levels that will minimize the mean squared error, the solution is much more complex than that of uniform quantization. Figure3.8 illustrates a generic nonuniform quantizer.

Designing an optimal M-level nonuniform quantizer for a source with a known probability distribution function amounts to finding decision bound-aries diand reconstruction levels yithat minimizes the mean squared quanti-zation error given in Equation3.5. To find an expression for the reconstruction levels yiwe take the partial derivative of Equation3.5with respect to yi, and set it to zero. The resulting expression is:

yj=

The decision boundaries are defined as the midpoints of neighbouring reconstruction levels:

dj= yj+1+ yj

2 (3.9)

These two equations are interdependent so to solve them simultaneously an iterative numerical procedure is needed. This iterative numerical procedure is called the Lloyd-Max algorithm, and was discovered independently at least three times [46,49,45]. The algorithm works as follows:

1. Choose the initial reconstruction levels yjarbitrarily.

2. For 1 ≤ j ≤ M − 1, set dj= 12(yj+1+ yj).

3. For 1 ≤ j ≤ M, set yjequal to the mean of p(x) in the interval x ∈ (dj−1, dj].

4. Repeat steps (2) and (3) until there is no more significant improvement in the mean squared errorσ2q.

As the Lloyd-Max algorithm is executed, the mean squared error σ2q de-creases monotonically, and since the mean squared error is non-negative it approaches some limit. Consequently, if the algorithm terminates if the im-provement in mean squared error is less than someε > 0, then the algorithm must terminate in a finite number of iterations.

Optimized nonuniform quantizers give more accurate results than opti-mized uniform quantizers for a given number of reconstruction levels, as can be seen in Table3.4, where the signal-to-noise ratios of optimized uniform and nonuniform quantizers for Gaussian and Laplacian sources are compared.

The difference in accuracy is more apparent with the Laplacian distribution since it is more peaked than the Gaussian distribution. In general, the more peaked the probability distribution of a source is6, the bigger the accuracy gap between an optimized uniform quantizer and an optimized nonuniform quantizer will be, with the nonuniform quantizer always outperforming the uniform quantizer.

6Or equivalently, the lower its entropy is.

3.6. QUANTIZATION 49

Gaussian Laplacian

M Uniform Nonuniform Uniform Nonuniform

4 9.24 9.3 7.05 7.54

6 12.18 12.41 9.56 10.51

8 14.27 14.62 11.39 12.64

Table 3.4: Signal-to-noise ratios (in dB) of optimal uniform and nonuniform quantizers for Gaussian and Laplacian distributions (adapted from [70]).

Gaussian Laplacian

M Uniform Nonuniform Uniform Nonuniform

4 1.904 1.911 1.751 1.728

6 2.409 2.442 2.127 2.207

8 2.759 2.824 2.394 2.479

16 3.602 3.765 3.063 3.473

32 4.449 4.730 3.779 4.427

Table 3.5: Output entropies (in bits) of optimal uniform and nonuniform quantizers for Gaussian and Laplacian distributions (adapted from [70]).

3.6.2 Properties of Probabilistically Optimized Scalar Quantizers

Related documents