Scalar Quantizer (Obsolete)
Convert input signal into set of quantized output values or index values, or convert set of index values into quantized output signal
Library
dspobslib
Description
Note
The Scalar Quantizer block is still supported but is likely to be obsoleted in a future release. We strongly recommend replacing this block with the Scalar Quantizer Encoder block or the Scalar Quantizer Decoder block.
The Scalar Quantizer block has three modes of operation. In
Encoder
mode, the block maps each input value to a
quantization region by comparing the input value to the quantizer boundary points
defined in the Boundary points parameter. The block outputs the
index of the associated region. In Decoder
mode, the block
transforms the input index values into quantized output values, defined in the
Codebook parameter. In the Encoder and
Decoder
mode, the block performs both the encoding and decoding
operations. The block outputs the index values and the quantized output values.
You can select how you want to enter the Boundary points and/or
Codebook values using the Source of
quantizer parameters. When you select Specify via
dialog
, type the parameters into the block parameters dialog box.
Select Input ports
, and port B and/or C appears on the block.
In Encoder
and Encoder and decoder
mode, the input to port B is used as the Boundary points. In
Decoder
and Encoder and
decoder
mode, the input to port C is used as the
Codebook.
In Encoder
and Encoder and
decoder
mode, the Boundary points are the values
used to break up the input signal into regions. Each region is specified by an index
number. When your first boundary point is -inf
and your last boundary
point is inf
, your quantizer is unbounded. When your first and last
boundary point is finite, your quantizer is bounded. When only your first or last
boundary point is -inf
or inf
, your quantizer is
semi-bounded.
For instance, when your input signal ranges from 0 to 11, you can create a bounded quantizer using the following boundary points:
[0 0.5 3.7 5.8 6.0 11]
The boundary points can have equal or varied spacing. Any input values between 0 and 0.5 would correspond to index 0. Input values between 0.5 and 3.7 would correspond to index 1, and so on.
Suppose you wanted to create an unbounded quantizer with the following boundary points:
[-inf 0 2 5.5 7.1 10 inf]
When your input signal has values less than 0, these values would be assigned to index 0. When your input signal has values greater than 10, these values would be assigned to index 6.
When an input value is the same as a boundary point, the Tie-breaking
rule parameter defines the index to which the value is assigned. When you
want the input value to be assigned to the lower index value, select Choose
the lower index
. To assign the input value with the higher index,
select Choose the higher index
.
In Decoder
and Encoder and
decoder
mode, the Codebook is a vector of
quantized output values that correspond to each index value.
In Encoder
and Encoder and
decoder
mode, the Searching method determines how
the appropriate quantizer index is found. Select Linear
and
the Scalar Quantizer block compares the input value to the first region defined by the
first two boundary points. When the input value does not fall within this region, the
block then compares the input value to the next region. This process continues until the
input value is determined to be within a region and is associated with the appropriate
index value. The computational cost of this process is of the order P, where P is the
number of boundary points.
Select Binary
for the Searching method
and the block compares the input value to the middle value of the boundary points
vector. When the input value is larger than this boundary point, the block discards the
boundary points that are lower than this middle value. The block then compares the input
value to the middle boundary point of the new range, defined by the remaining boundary
points. This process continues until the input value is associated with the appropriate
index value. The computational cost of this process is of the order log2P, where P is the number of boundary points. In most
cases, the Binary
option is faster than the
Linear
option.
In Decoder
mode, the input to this block is a vector of
index values, where 0 ≤ index <N and N is the length of the codebook vector. Use the
Action for out of range input parameter to determine what
happens when an input index value is out of this range. When you want any index values
less than 0 to be set to 0 and any index values greater than or equal to
N to be set to N -1, select
Clip
. When you want to be warned when any index values
less than 0 are set to 0 and any index values greater than or equal to
N are set to N -1, select Clip
and warn
. When you want the simulation to stop and display an error
when the index values are out of range, select Error
.
In Encoder and decoder
mode, you can select the
Output the quantization error check box. The quantization error
is the difference between the input value and the quantized output value. Select this
check box to output the quantization error for each input value from the Err port on
this block.
Data Type Support
In Encoder
mode, the input data values and the boundary
points can be the input to the block at ports U and B. Similarly, in
Encoder and decoder
mode, the codebook values can
also be the input to the block at port C. The data type of the input data values,
boundary points, and codebook values can be double
,
single
, uint8
,
uint16
, uint32
,
int8
, int16
, or
int32
. In Decoder
mode,
the input to the block can be the index values and the codebook values. The data
type of the index input to the block at port Idx can be
uint8
, uint16
,
uint32
, int8
,
int16
, or int32
. The data
type of the codebook values can be double
,
single
, uint8
,
uint16
, uint32
,
int8
, int16
, or
int32
.
In Encoder
mode, the output of the block is the index
values. In Encoder and decoder
mode, the output can also
include the quantized output values and the quantization error. In
Encoder
and Encoder and
decoder
mode, use the Output index data type
parameter to specify the data type of the index output from the block at port Idx.
The data type of the index output can be uint8
,
uint16
, uint32
,
int8
, int16
, or
int32
. The data type of the quantized output and the
quantization error can be double
,
single
, uint8
,
uint16
, uint32
,
int8
, int16
, or
int32
. In Decoder
mode,
the output of the block is the quantized output values. Use the Output
data type parameter to specify the data type of the quantized output
values. The data type can be double
,
single
, uint8
,
uint16
, uint32
,
int8
, int16
,
int32
.
Note
The input data, codebook values, boundary points, quantization error, and the quantized output values must have the same data type whenever they are present in any of the quantizer modes.
Parameters
- Quantizer mode
Specify
Encoder
,Decoder
, orEncoder and decoder
as a mode of operation.- Source of quantizer parameters
Choose
Specify via dialog
to type the parameters into the block parameters dialog box. SelectInput ports
to specify the parameters using the block's input ports. InEncoder
andEncoder and decoder
mode, input the Boundary points using port B. InDecoder
andEncoder and decoder
mode, input the Codebook values using port C.- Boundary points
Enter a vector of values that represent the boundary points of the quantizer regions. Tunable (Simulink).
- Codebook
Enter a vector of quantized output values that correspond to each index value. Tunable (Simulink).
- Searching method
Select
Linear
and the block finds the region in which the input value is located using a linear search. SelectBinary
and the block finds the region in which the input value is located using a binary search.- Tie-breaking rule
Set this parameter to determine the behavior of the block when the input value is the same as the boundary point. When you select
Choose the lower index
, the input value is assigned to lower index value. When you selectChoose the higher index
, the value is assigned to the higher index.- Action for out of range input
Choose the block's behavior when an input index value is out of range, where 0 ≤ index <N and N is the length of the codebook vector. Select
Clip
, when you want any index values less than 0 to be set to 0 and any index values greater than or equal to N to be set to N -1. SelectClip and warn
, when you want to be warned when any index values less than 0 are set to 0 and any index values greater than or equal to N are set to N -1. SelectError
, when you want the simulation to stop and display an error when the index values are out of range.- Output the quantization error
In
Encoder and decoder
mode, select this check box to output the quantization error from the Err port on this block.- Output index data type
In
Encoder
andEncoder and decoder
mode, specify the data type of the index output from the block at port Idx. The data type can beuint8
,uint16
,uint32
,int8
,int16
, orint32
. This parameter becomes visible when you select the Show additional parameters check box.- Output data type
In
Decoder
mode, specify the data type of the quantized output. The data type can beuint8
,uint16
,uint32
,int8
,int16
,int32
,single
, ordouble
. This parameter becomes visible when you selectSpecify via dialog
for the Source of quantizer parameters and you select the Show additional parameters check box.
References
Gersho, A. and R. Gray. Vector Quantization and Signal Compression. Boston: Kluwer Academic Publishers, 1992.
Supported Data Types
Double-precision floating point
Single-precision floating point
Fixed point
8-, 16-, and 32-bit signed integers
8-, 16-, and 32-bit unsigned integers
For more information on what data types are supported for each quantizer mode, see Data Type Support.
See Also
Quantizer (Simulink) | Simulink |
Scalar Quantizer Decoder | DSP System Toolbox |
Scalar Quantizer Encoder | DSP System Toolbox |
Uniform Encoder | DSP System Toolbox |
Uniform Decoder | DSP System Toolbox |
Version History
Introduced in R2008b