Class QuantizeOption
java.lang.Object
nom.tam.fits.compression.algorithm.quant.QuantizeOption
- All Implemented Interfaces:
Cloneable
,ICompressOption
- Direct Known Subclasses:
HCompressorQuantizeOption
,RiceQuantizeCompressOption
Quantization options when they are part of the compression scheme. When compressing tables and images includes
quantization (integer representation of floating point data), users can control how exactly the quantization should
be performed. When reading compressed FITS files, these options will be set automatically based on the header values
recorded in the compressed HDU.
-
Constructor Summary
ConstructorDescriptionQuantizeOption
(ICompressOption compressOption) Creates a new set of quantization options, to be used together with the specified compression options. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Returns an independent copy of this option.getBNull()
Returns the integer value that represents missing (null
) data in the quantized representation.double
Returns the quantization level.double
getBZero()
Returns the quantization offset.nom.tam.fits.compression.provider.param.api.ICompressParameters
(for internal use) Returns the parameters that represent the settings for this option in the FITS header or compressed data column.final ICompressOption
Returns the options for the compression algorithm that accompanies quantization.<T> T
getCompressOption
(Class<T> clazz) Returns the compression or quantization options, recast for the selected option class.int
Returns the maximum integer level in the quantized representation.int
Returns the maximum integer level in the quantized representation.double
Returns the maximum floating-point value in the datadouble
Returns the minimum floating-point value in the datadouble
Returns the floating-point value that indicates anull
datum in the image before quantization is applied.final Integer
Deprecated.double
Returns the quantization resolution level used for automatic qunatization.long
getSeed()
Gets the random seed value used for ditheringint
Returns the tile heightlong
Returns the sequential tile index that this option is currently configured for.int
Returns the tile widthboolean
Checks whether we force the integer quantized level 0 to correspond to a floating-point level 0.0, when using automatic quantization.boolean
Whether the floating-point data may containnull
values (normally NaNs).boolean
Whether automatic quantization treats 0.0 as a special value.boolean
isDither()
Whether dithering is enabledboolean
Whether dither method 2 is used.boolean
Checks if this type of compression is inherently lossySets the integer value that represents missing data (null
) in the quantized representation.setBScale
(double value) Sets the quantization level.setBZero
(double value) Sets the quantization offset.setCenterOnZero
(boolean value) Enabled or disables keeping `BZERO` at 0 when using automatic quantization.setCheckNull
(boolean value) Deprecated.setBNull(Integer)
controls this feature automatically as needed.setCheckZero
(boolean value) Deprecated.It is strongly discouraged to treat 0.0 values as special.setDither
(boolean value) Enables or disables dithering.setDither2
(boolean value) Sets whether dithering is to use method 2.setIntMaxValue
(int value) Sets the maximum integer level in the quantized representation.setIntMinValue
(int value) Sets the minimum integer level in the quantized representation.setMaxValue
(double value) Sets the maximum floating-point value in the datasetMinValue
(double value) Sets the minimum floating-point value in the datasetNullValue
(double value) Deprecated.The use of null values other thanNaN
for floating-point data types is not standard in FITS.void
setParameters
(nom.tam.fits.compression.provider.param.api.ICompressParameters parameters) (for internal use) Sets the parameters that link the options to how they are recorded in the FITS headers or compressed table columns.setQlevel
(double value) Sets the quantization resolution level to use for automatic quantization.setSeed
(long value) Sets the seed value for the dither random generatorsetTileHeight
(int value) Set the tile height (if the option supports it).setTileIndex
(int index) Sets the tile index for which to initialize the random number generator with the given seed (i.e.setTileWidth
(int value) Set the tile width (if the option supports it).<T> T
(for internal use) Recasts these options for the specific implementation class
-
Constructor Details
-
QuantizeOption
Creates a new set of quantization options, to be used together with the specified compression options.- Parameters:
compressOption
- Compression-specific options to pair with these quantization options, ornull
.- Since:
- 1.18
-
-
Method Details
-
copy
Description copied from interface:ICompressOption
Returns an independent copy of this option. Modifications to the original or the copy will not affect the other.- Specified by:
copy
in interfaceICompressOption
- Returns:
- copy the option (normally the option from with the copy happened is saved as original).
-
getBNull
Returns the integer value that represents missing (null
) data in the quantized representation.- Returns:
- the integer blanking value (
null
value). - See Also:
-
getBScale
public double getBScale()Returns the quantization level.- Returns:
- the floating-point difference between integer levels in the quantized data.
- See Also:
-
getBZero
public double getBZero()Returns the quantization offset.- Returns:
- the floating-point value corresponding to the integer level 0.
- See Also:
-
getCompressionParameters
public nom.tam.fits.compression.provider.param.api.ICompressParameters getCompressionParameters()Description copied from interface:ICompressOption
(for internal use) Returns the parameters that represent the settings for this option in the FITS header or compressed data column.- Specified by:
getCompressionParameters
in interfaceICompressOption
- Returns:
- the parameters that must be synchronized with the hdu meta data.
- See Also:
-
getCompressOption
Returns the compression or quantization options, recast for the selected option class.- Type Parameters:
T
- the generic type of the compression option- Parameters:
clazz
- the option class for the compression algorithm used with the quantization, orQunatizeOption.class
for our own options.- Returns:
- the recast options for the requested class or
null
id we do not have access to options of the requested class. - See Also:
-
getCompressOption
Returns the options for the compression algorithm that accompanies quantization.- Returns:
- the options for the compression algorithm, or
null
- See Also:
-
getIntMaxValue
public int getIntMaxValue()Returns the maximum integer level in the quantized representation.- Returns:
- the maximum integer level in the quantized data.
- See Also:
-
getIntMinValue
public int getIntMinValue()Returns the maximum integer level in the quantized representation.- Returns:
- the maximum integer level in the quantized data.
- See Also:
-
getMaxValue
public double getMaxValue()Returns the maximum floating-point value in the data- Returns:
- the maximum floating-point value in the data before quantization.
- See Also:
-
getMinValue
public double getMinValue()Returns the minimum floating-point value in the data- Returns:
- the minimum floating-point value in the data before quantization.
- See Also:
-
getNullValue
public double getNullValue()Returns the floating-point value that indicates anull
datum in the image before quantization is applied. Normally, the FITS standard is that NaN values indicatenull
values in floating-point images. While this class allows using other values also, they are not recommended since they are not supported by FITS in a standard way.- Returns:
- the floating-point value that represents a
null
value (missing data) in the image before quantization. - See Also:
-
getNullValueIndicator
Deprecated.usegetBNull()
instead (duplicate method). Returns the integer value that represents missing data (null
) in the quantized representation.- Returns:
- the integer blanking value (
null
value). - See Also:
-
getQLevel
public double getQLevel()Returns the quantization resolution level used for automatic qunatization. For Gaussian noise the quantization level is the standard deviation of the noise divided by this Q value. Thus Q values of a few will ensure that quantization retains just about all of the information in the noisy data.- Returns:
- The current Q value, defined as the number of quantized levels per standard deviation (for Gaussian noise).
- See Also:
-
getSeed
public long getSeed()Gets the random seed value used for dithering- Returns:
- the random seed value used for dithering
- See Also:
-
getTileIndex
public long getTileIndex()Returns the sequential tile index that this option is currently configured for.- Returns:
- the sequential tile index that the quantization is configured for
- See Also:
-
getTileHeight
public int getTileHeight()Returns the tile height- Specified by:
getTileHeight
in interfaceICompressOption
- Returns:
- the tile height in pixels
- See Also:
-
getTileWidth
public int getTileWidth()Returns the tile width- Specified by:
getTileWidth
in interfaceICompressOption
- Returns:
- the tile width in pixels
- See Also:
-
isCenterOnZero
public boolean isCenterOnZero()Checks whether we force the integer quantized level 0 to correspond to a floating-point level 0.0, when using automatic quantization.- Returns:
true
if we want to keep `BZERO` at 0 when quantizing automatically.- See Also:
-
isCheckNull
public boolean isCheckNull()Whether the floating-point data may containnull
values (normally NaNs).- Returns:
true
if we should expectnull
in the floating-point data. This is automaticallytrue
ifsetBNull(Integer)
was called with a non-null value.- See Also:
-
isCheckZero
public boolean isCheckZero()Whether automatic quantization treats 0.0 as a special value. Normally values within the `BSCALE` quantization level around 0.0 will be assigned the same integer quanta, and will become indistinguishable in the quantized data. Some software may, in their misguided ways, assign exact zero values a special meaning (such as no data) in which case we may want to distinguish these as we apply quantization. However, it is generally not a good idea to use 0 as a special value.- Returns:
true
to treat 0.0 (exact) as a special value, orfalse
to treat is as any other measured value (recommended).- See Also:
-
isDither
public boolean isDither()Whether dithering is enabled- Returns:
true
if dithering is enabled, or elsefalse
- See Also:
-
isDither2
public boolean isDither2()Whether dither method 2 is used.- Returns:
true
if dither method 2 is used, or elsefalse
- See Also:
-
isLossyCompression
public boolean isLossyCompression()Description copied from interface:ICompressOption
Checks if this type of compression is inherently lossy- Specified by:
isLossyCompression
in interfaceICompressOption
- Returns:
true
if the compression done with this specified options uses approximations. That means if the reconstruction of the data is excact the return should befalse
.
-
setBNull
Sets the integer value that represents missing data (null
) in the quantized representation.- Parameters:
blank
- the new integer blanking value (that is one that denotes a missing ornull
datum). Setting this option tonull
disables the treatment of issing ornull
data.- Returns:
- itself
- See Also:
-
setBScale
Sets the quantization level.- Parameters:
value
- the new floating-point difference between integer levels in the quantized data.- Returns:
- itself
- See Also:
-
setBZero
Sets the quantization offset.- Parameters:
value
- the new floating-point value corresponding to the integer level 0.- Returns:
- itself
- See Also:
-
setCenterOnZero
Enabled or disables keeping `BZERO` at 0 when using automatic quantization.- Parameters:
value
-true
to keep `BZERO` at 0 when quantizing automatically, that is keep the integer quantized level 0 correspond to floating-point level 0.0. Or,false
to let the automatic quantization algorithm determine the optimal quantization offset.- Returns:
- iftself
- See Also:
-
setCheckNull
Deprecated.setBNull(Integer)
controls this feature automatically as needed. Sets whether we should expect the floating-point data to containnull
values (normally NaNs).- Parameters:
value
-true
if the floating-point data may containnull
values.- Returns:
- itself
- See Also:
-
setCheckZero
Deprecated.It is strongly discouraged to treat 0.0 values as special. FITS only recognises NaN as a special floating-point value marking missing data. All other floating point values are considered valid measurements.Sets whether automatic quantization is to treat 0.0 as a special value. Normally values within the `BSCALE` quantization level around 0.0 will be assigned the same integer quanta, and will become indistinguishable in the quantized data. However some software may assign exact zero values a special meaning (such as no data) in which case we may want to distinguish these as we apply qunatization. However, it is generally not a good idea to use 0 as a special value. To mark missing data, the FITS standard recognises only NaN as a special value -- while all other values should constitute valid measurements.- Parameters:
value
- whether to treat values around 0.0 as special.- Returns:
- itself
- See Also:
-
setDither
Enables or disables dithering.- Parameters:
value
-true
to enable dithering, or elsefalse
to disable- Returns:
- itself
- See Also:
-
setDither2
Sets whether dithering is to use method 2.- Parameters:
value
-true
to use dither method 2, or elsefalse
for method 1.- Returns:
- itself
- See Also:
-
setIntMaxValue
Sets the maximum integer level in the quantized representation.- Parameters:
value
- the new maximum integer level in the quantized data.- Returns:
- itself
- See Also:
-
setIntMinValue
Sets the minimum integer level in the quantized representation.- Parameters:
value
- the new minimum integer level in the quantized data.- Returns:
- itself
- See Also:
-
setMaxValue
Sets the maximum floating-point value in the data- Parameters:
value
- the maximum floating-point value in the data before quantization.- Returns:
- itself
- See Also:
-
setMinValue
Sets the minimum floating-point value in the data- Parameters:
value
- the mininum floating-point value in the data before quantization.- Returns:
- itself
- See Also:
-
setNullValue
Deprecated.The use of null values other thanNaN
for floating-point data types is not standard in FITS. You should therefore avoid using this method to change it. Returns the floating-point value that indicates anull
datum in the image before quantization is applied. Normally, the FITS standard is that NaN values indicatenull
values in floating-point images. While this class allows using other values also, they are not recommended since they are not supported by FITS in a standard way.- Parameters:
value
- the new floating-point value that represents anull
value (missing data) in the image before quantization.- Returns:
- itself
- See Also:
-
setParameters
public void setParameters(nom.tam.fits.compression.provider.param.api.ICompressParameters parameters) Description copied from interface:ICompressOption
(for internal use) Sets the parameters that link the options to how they are recorded in the FITS headers or compressed table columns.- Specified by:
setParameters
in interfaceICompressOption
- Parameters:
parameters
- the parameters to synchronized- See Also:
-
setQlevel
Sets the quantization resolution level to use for automatic quantization. For Gaussian noise the quantization level is the standard deviation of the noise divided by this Q value. Thus Q values of a few will ensusre that quantization retains just about all of the information contained in the noisy data.- Parameters:
value
- The new Q value, defined as the number of quantized levels per standard deviation (for Gaussian noise).- Returns:
- itself
- See Also:
-
setSeed
Sets the seed value for the dither random generator- Parameters:
value
- The seed value, as inZDITHER0
, normally a number between 1 and 10000 (inclusive).- Returns:
- itself
- See Also:
-
setTileIndex
Sets the tile index for which to initialize the random number generator with the given seed (i.e.ZDITHER0
value).- Parameters:
index
- The 0-based tile index- Returns:
- itself
- See Also:
-
setTileHeight
Description copied from interface:ICompressOption
Set the tile height (if the option supports it). If the implementing option class does not have a setting for tile size, it should simply ignore the setting and return normally.- Specified by:
setTileHeight
in interfaceICompressOption
- Parameters:
value
- the new tile height in pixels- Returns:
- itself
- See Also:
-
setTileWidth
Description copied from interface:ICompressOption
Set the tile width (if the option supports it). If the implementing option class does not have a setting for tile size, it should simply ignore the setting and return normally.- Specified by:
setTileWidth
in interfaceICompressOption
- Parameters:
value
- the new tile with in pixels- Returns:
- itself
- See Also:
-
unwrap
Description copied from interface:ICompressOption
(for internal use) Recasts these options for the specific implementation class- Specified by:
unwrap
in interfaceICompressOption
- Type Parameters:
T
- these options recast to the designated implementation type.- Parameters:
clazz
- the implementation class- Returns:
- the recast version of us or
null
if the recasting is not available for the specified class type.
-
getBNull()
instead (duplicate method).