Vector quantization encoding
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:
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.
Source of codebook values
Specify how to determine the codebook values as Property or Input port. The default is Property.
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:
This property is tunable.
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.
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.
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.
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.
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.
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.
Data type of index output
Specify the data type of the index output as: int8, uint8, int16, uint16, int32, uint32. The default is int32.
|clone||Create vector quantizer encoder object with same property values|
|getNumInputs||Number of expected inputs to step method|
|getNumOutputs||Number of outputs of step method|
|isLocked||Locked status for input attributes and nontunable properties|
|release||Allow property value and input characteristics changes|
|step||Perform vector quantization encoding|
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');
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.