Optimizing Quantization Parameters
Section Overview
Quantization distorts a signal. You can lessen the distortion
by choosing appropriate partition and codebook parameters. However,
testing and selecting parameters for large signal sets with a fine
quantization scheme can be tedious. One way to produce partition and codebook parameters easily
is to optimize them according to a set of so-called training
data.
Note
The training data you use should be typical of the kinds of
signals you will actually be quantizing. |
Back to Top
Example: Optimizing Quantization Parameters
The lloyds function
optimizes the partition and codebook according to the Lloyd algorithm.
The code below optimizes the partition and codebook for one period
of a sinusoidal signal, starting from a rough initial guess. Then
it uses these parameters to quantize the original signal using the
initial guess parameters as well as the optimized parameters. The
output shows that the mean square distortion after quantizing is much
less for the optimized parameters. The quantiz function
automatically computes the mean square distortion and returns it as
the third output parameter.
% Start with the setup from 2nd example in "Quantizing a Signal."
t = [0:.1:2*pi];
sig = sin(t);
partition = [-1:.2:1];
codebook = [-1.2:.2:1];
% Now optimize, using codebook as an initial guess.
[partition2,codebook2] = lloyds(sig,codebook);
[index,quants,distor] = quantiz(sig,partition,codebook);
[index2,quant2,distor2] = quantiz(sig,partition2,codebook2);
% Compare mean square distortions from initial and optimized
[distor, distor2] % parameters.
The output is
ans =
0.0148 0.0024
Back to Top
 | Quantizing a Signal | | Differential Pulse Code Modulation |  |
How much time do you spend on testing to ensure implementation meets system-level requirements?
Learn more