public class StdQuantizer extends Quantizer
Sign magnitude representation is used (instead of two's complement) for the output data. The most significant bit is used for the sign (0 if positive, 1 if negative). Then the magnitude of the quantized coefficient is stored in the next M most significat bits. The rest of the bits (least significant bits) can contain a fractional value of the quantized coefficient. This fractional value is not to be coded by the entropy coder. However, it can be used to compute rate-distortion measures with greater precision.
The value of M is determined for each subband as the sum of the number of guard bits G and the nominal range of quantized wavelet coefficients in the corresponding subband (Rq), minus 1:
M = G + Rq -1
The value of G should be the same for all subbands. The value of Rq depends on the quantization step size, the nominal range of the component before the wavelet transform and the analysis gain of the subband (see Subband).
The blocks of data that are requested should not cross subband boundaries.
Modifier and Type | Field and Description |
---|---|
private GuardBitsSpec |
gbs
The guard bits specifications
|
private CBlkWTDataFloat |
infblk
The 'CBlkWTDataFloat' object used to request data, used when
quantizing floating-point data.
|
private static double |
log2
Natural log of 2, used as a convenience variable
|
private QuantStepSizeSpec |
qsss
The quantization step size specifications
|
static int |
QSTEP_EXPONENT_BITS
The number of exponent bits for the quantization steps
|
static int |
QSTEP_MANTISSA_BITS
The number of mantissa bits for the quantization steps
|
static int |
QSTEP_MAX_EXPONENT
The maximum value of the exponent for the quantization steps
|
static int |
QSTEP_MAX_MANTISSA
The maximum value of the mantissa for the quantization steps
|
private QuantTypeSpec |
qts
The quantization type specifications
|
OPT_PREFIX, src
imgdatasrc, tIdx
Constructor and Description |
---|
StdQuantizer(CBlkWTDataSrc src,
J2KImageWriteParamJava wp)
Initializes the source of wavelet transform coefficients.
|
Modifier and Type | Method and Description |
---|---|
protected void |
calcSbParams(SubbandAn sb,
int c)
Calculates the parameters of the SubbandAn objects that depend on the
Quantizer.
|
private static float |
convertFromExpMantissa(int ems)
Converts the exponent-mantissa representation to its floating-point
value.
|
static int |
convertToExpMantissa(float step)
Converts the floating point value to its exponent-mantissa
representation.
|
int |
getMaxMagBits(int c)
Returns the maximum number of magnitude bits in any subband of the
current tile.
|
private int |
getMaxMagBitsDerived(Subband sb,
int t,
int c)
Returns the maximum number of magnitude bits in any subband in the
given tile-component if derived quantization is used
|
private int |
getMaxMagBitsExpounded(Subband sb,
int t,
int c)
Returns the maximum number of magnitude bits in any subband in the
given tile-component if expounded quantization is used
|
private int |
getMaxMagBitsRev(Subband sb,
int c)
Returns the maximum number of magnitude bits in any subband of the
current tile if reversible quantization is used
|
CBlkWTData |
getNextCodeBlock(int c,
CBlkWTData cblk)
Returns the next code-block in the current tile for the specified
component, as a copy (see below).
|
CBlkWTData |
getNextInternCodeBlock(int c,
CBlkWTData cblk)
Returns the next code-block in the current tile for the specified
component.
|
int |
getNumGuardBits(int t,
int c)
Returns the number of guard bits used by this quantizer in the given
tile-component.
|
QuantTypeSpec |
getQuantTypeSpec()
Returns the quantization type spec object associated to the quantizer.
|
boolean |
isDerived(int t,
int c)
Returns true if given tile-component uses derived quantization step
sizes.
|
boolean |
isReversible(int t,
int c)
Returns true if the quantized data is reversible, for the specified
tile-component.
|
createInstance, getAnSubbandTree, getCbULX, getCbULY, getParameterInfo
getCompImgHeight, getCompImgWidth, getCompSubsX, getCompSubsY, getCompULX, getCompULY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomRangeBits, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getTile, getTileCompHeight, getTileCompWidth, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth, nextTile, setTile
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCompImgHeight, getCompImgWidth, getCompSubsX, getCompSubsY, getCompULX, getCompULY, getImgHeight, getImgULX, getImgULY, getImgWidth, getNomRangeBits, getNomTileHeight, getNomTileWidth, getNumComps, getNumTiles, getNumTiles, getTile, getTileCompHeight, getTileCompWidth, getTileHeight, getTileIdx, getTilePartULX, getTilePartULY, getTileWidth, nextTile, setTile
public static final int QSTEP_MANTISSA_BITS
public static final int QSTEP_EXPONENT_BITS
public static final int QSTEP_MAX_MANTISSA
public static final int QSTEP_MAX_EXPONENT
private static double log2
private QuantTypeSpec qts
private QuantStepSizeSpec qsss
private GuardBitsSpec gbs
private CBlkWTDataFloat infblk
public StdQuantizer(CBlkWTDataSrc src, J2KImageWriteParamJava wp)
After initializing member attributes, getAnSubbandTree is called for all components setting the 'stepWMSE' for all subbands in the current tile.
src
- The source of wavelet transform coefficients.wp
- The encoder parameterspublic QuantTypeSpec getQuantTypeSpec()
public int getNumGuardBits(int t, int c)
getNumGuardBits
in class Quantizer
t
- Tile indexc
- Component indexpublic boolean isReversible(int t, int c)
t
- The tile to test for reversibilityc
- The component to test for reversibilitypublic boolean isDerived(int t, int c)
public CBlkWTData getNextCodeBlock(int c, CBlkWTData cblk)
When changing the current tile (through 'setTile()' or 'nextTile()') this method will always return the first code-block, as if this method was never called before for the new current tile.
The data returned by this method is always a copy of the data. Therfore it can be modified "in place" without any problems after being returned. The 'offset' of the returned data is 0, and the 'scanw' is the same as the code-block width. See the 'CBlkWTData' class.
The 'ulx' and 'uly' members of the returned 'CBlkWTData' object contain the coordinates of the top-left corner of the block, with respect to the tile, not the subband.
c
- The component for which to return the next code-block.cblk
- If non-null this object will be used to return the new
code-block. If null a new one will be allocated and returned. If the
"data" array of the object is non-null it will be reused, if possible,
to return the data.CBlkWTData
public final CBlkWTData getNextInternCodeBlock(int c, CBlkWTData cblk)
When changing the current tile (through 'setTile()' or 'nextTile()') this method will always return the first code-block, as if this method was never called before for the new current tile.
The data returned by this method can be the data in the internal buffer of this object, if any, and thus can not be modified by the caller. The 'offset' and 'scanw' of the returned data can be arbitrary. See the 'CBlkWTData' class.
The 'ulx' and 'uly' members of the returned 'CBlkWTData' object contain the coordinates of the top-left corner of the block, with respect to the tile, not the subband.
c
- The component for which to return the next code-block.cblk
- If non-null this object will be used to return the new
code-block. If null a new one will be allocated and returned. If the
"data" array of the object is non-null it will be reused, if possible,
to return the data.CBlkWTData
protected void calcSbParams(SubbandAn sb, int c)
calcSbParams
in class Quantizer
sb
- The root of the subband tree.c
- The component indexSubbandAn.stepWMSE
public static int convertToExpMantissa(float step)
step
- The quantization step, normalized to a dynamic range of 1.private static float convertFromExpMantissa(int ems)
ems
- The exponent-mantissa representation of the step.public int getMaxMagBits(int c)
getMaxMagBits
in class Quantizer
c
- the component numberprivate int getMaxMagBitsRev(Subband sb, int c)
sb
- The root of the subband tree of the current tilec
- the component numberprivate int getMaxMagBitsDerived(Subband sb, int t, int c)
sb
- The root of the subband tree of the tile-componentt
- Tile indexc
- Component indexprivate int getMaxMagBitsExpounded(Subband sb, int t, int c)
sb
- The root of the subband tree of the tile-componentt
- Tile indexc
- Component indexCopyright © 2016 Open Microscopy Environment