dsp.VectorQuantizerEncoder System object

Package: dsp

Vector quantization encoding

Description

The VectorQuantizerEncoder object performs vector quantization encoding. The object finds the nearest codeword by computing a distortion based on Euclidean or weighted Euclidean distance.

To perform vector quantization encoding:

  1. Define and set up your vector quantizer encoder. See Construction.

  2. Call step to perform the quantization encoding according to the properties of dsp.VectorQuantizerEncoder. The behavior of step is specific to each object in the toolbox.

Construction

H = dsp.VectorQuantizerEncoder returns a vector quantizer encoder System object™, H. This object finds a zero-based index of the nearest codeword for each given input column vector.

H = dsp.VectorQuantizerEncoder('PropertyName',PropertyValue,...) returns a vector quantizer encoder System object, H, with each specified property set to the specified value.

Properties

CodebookSource

Source of codebook values

Specify how to determine the codebook values as Property or Input port. The default is Property.

Codebook

Codebook

Specify the codebook to which the input column vector or matrix is compared, as a k-by-N matrix. Each column of the codebook matrix is a codeword, and each codeword corresponds to an index value. The codeword vectors must have the same number of rows as the input. The first codeword vector corresponds to an index value of 0, the second codeword vector corresponds to an index value of 1, and so on. This property applies when you set the CodebookSource property to Property. The default is:

[1.5 13.3 136.4 6.82.5 14.3 137.4 7.83.5 15.3 138.4 8.8]

This property is tunable.

DistortionMeasure

Distortion calculation method

Specify how to calculate the distortion as Squared error or Weighted squared error. If you set this property to Squared error, the object calculates the distortion by evaluating the Euclidean distance between the input column vector and each codeword in the codebook. If you set this property to Weighted squared error, the object calculates the distortion by evaluating a weighted Euclidean distance using a weighting factor to emphasize or deemphasize certain input values. The default is Squared error.

WeightsSource

Source of weighting factor

Specify how to determine weighting factor as Property or Input port. This property applies when you set the DistortionMeasure property to Weighted squared error. The default is Property.

Weights

Weighting factor

Specify the weighting factor as a vector of length equal to the number of rows of the input. This property applies when you set the DistortionMeasure property to Weighted squared error and WeightsSource property is Property. The default is [1 1 1]. This property is tunable.

TiebreakerRule

Behavior when input column vector is equidistant from two codewords.

Specify whether to represent the input column vector by the lower index valued codeword or higher indexed valued codeword when an input column vector is equidistant from two codewords. You can set this property to Choose the lower index or Choose the higher index. The default is Choose the lower index.

CodewordOutputPort

Enable output of codeword value

Set this property to true to output the codeword vectors nearest to the input column vectors. The default is false.

QuantizationErrorOutputPort

Enable output of quantization error

Set this property to true to output the quantization error value that results when the object represents the input column vector by the nearest codeword. The default is false.

OutputIndexDataType

Data type of index output

Specify the data type of the index output as: int8, uint8, int16, uint16, int32, uint32. The default is int32.

 Fixed-Point Properties

Methods

cloneCreate vector quantizer encoder object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
stepPerform vector quantization encoding

Examples

Find the indices of nearest codewords based on Euclidean distances:

    hvqenc = dsp.VectorQuantizerEncoder(...
    'Codebook', [-1 -1 1 1;1 -1 -1 1], ...
    'CodewordOutputPort', true, ...
    'QuantizationErrorOutputPort', true, ...
    'OutputIndexDataType', 'uint8');
    % Generate an input signal with some additive noise
    x = sign(rand(2,40)-0.5) + 0.1*randn(2,40);
    [ind, cw, err] = step(hvqenc, x);
    plot(cw(1,:), cw(2,:), 'rO', x(1,:), x(2,:), 'g.');
    legend('Quantized', 'Inputs', 'location', 'best');

Algorithms

This object implements the algorithm, inputs, and outputs described on the Vector Quantizer Encoder block reference page. The object properties correspond to the block parameters.

Was this topic helpful?