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.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionQuantizeOption(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.doubleReturns the quantization level.doublegetBZero()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 ICompressOptionReturns the options for the compression algorithm that accompanies quantization.<T> TgetCompressOption(Class<T> clazz) Returns the compression or quantization options, recast for the selected option class.intReturns the maximum integer level in the quantized representation.intReturns the maximum integer level in the quantized representation.doubleReturns the maximum floating-point value in the datadoubleReturns the minimum floating-point value in the datadoubleReturns the floating-point value that indicates anulldatum in the image before quantization is applied.final IntegerDeprecated.doubleReturns the quantization resolution level used for automatic qunatization.longgetSeed()Gets the random seed value used for ditheringintReturns the tile heightlongReturns the sequential tile index that this option is currently configured for.intReturns the tile widthbooleanChecks whether we force the integer quantized level 0 to correspond to a floating-point level 0.0, when using automatic quantization.booleanWhether the floating-point data may containnullvalues (normally NaNs).booleanWhether automatic quantization treats 0.0 as a special value.booleanisDither()Whether dithering is enabledbooleanWhether dither method 2 is used.booleanChecks 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 thanNaNfor floating-point data types is not standard in FITS.voidsetParameters(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:ICompressOptionReturns an independent copy of this option. Modifications to the original or the copy will not affect the other.- Specified by:
copyin 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 (
nullvalue). - 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:
getCompressionParametersin 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.classfor our own options.- Returns:
- the recast options for the requested class or
nullid 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 anulldatum in the image before quantization is applied. Normally, the FITS standard is that NaN values indicatenullvalues 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
nullvalue (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 (
nullvalue). - 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:
getTileHeightin interfaceICompressOption- Returns:
- the tile height in pixels
- See Also:
-
getTileWidth
public int getTileWidth()Returns the tile width- Specified by:
getTileWidthin 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:
trueif we want to keep `BZERO` at 0 when quantizing automatically.- See Also:
-
isCheckNull
public boolean isCheckNull()Whether the floating-point data may containnullvalues (normally NaNs).- Returns:
trueif we should expectnullin the floating-point data. This is automaticallytrueifsetBNull(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:
trueto treat 0.0 (exact) as a special value, orfalseto treat is as any other measured value (recommended).- See Also:
-
isDither
public boolean isDither()Whether dithering is enabled- Returns:
trueif dithering is enabled, or elsefalse- See Also:
-
isDither2
public boolean isDither2()Whether dither method 2 is used.- Returns:
trueif dither method 2 is used, or elsefalse- See Also:
-
isLossyCompression
public boolean isLossyCompression()Description copied from interface:ICompressOptionChecks if this type of compression is inherently lossy- Specified by:
isLossyCompressionin interfaceICompressOption- Returns:
trueif 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 ornulldatum). Setting this option tonulldisables the treatment of issing ornulldata.- 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-trueto keep `BZERO` at 0 when quantizing automatically, that is keep the integer quantized level 0 correspond to floating-point level 0.0. Or,falseto 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 containnullvalues (normally NaNs).- Parameters:
value-trueif the floating-point data may containnullvalues.- 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-trueto enable dithering, or elsefalseto disable- Returns:
- itself
- See Also:
-
setDither2
Sets whether dithering is to use method 2.- Parameters:
value-trueto use dither method 2, or elsefalsefor 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 thanNaNfor 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 anulldatum in the image before quantization is applied. Normally, the FITS standard is that NaN values indicatenullvalues 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 anullvalue (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:
setParametersin 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.ZDITHER0value).- Parameters:
index- The 0-based tile index- Returns:
- itself
- See Also:
-
setTileHeight
Description copied from interface:ICompressOptionSet 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:
setTileHeightin interfaceICompressOption- Parameters:
value- the new tile height in pixels- Returns:
- itself
- See Also:
-
setTileWidth
Description copied from interface:ICompressOptionSet 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:
setTileWidthin 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:
unwrapin interfaceICompressOption- Type Parameters:
T- these options recast to the designated implementation type.- Parameters:
clazz- the implementation class- Returns:
- the recast version of us or
nullif the recasting is not available for the specified class type.
-
getBNull()instead (duplicate method).