LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
Options for scaling image pixels. More...
#include <fitsCompression.h>
Public Types | |
enum | ScalingAlgorithm { NONE , RANGE , STDEV_POSITIVE , STDEV_NEGATIVE , STDEV_BOTH , MANUAL } |
Public Member Functions | |
ImageScalingOptions () | |
Default Ctor. More... | |
ImageScalingOptions (ScalingAlgorithm algorithm_, int bitpix_, std::vector< std::string > const &maskPlanes_={}, int seed_=1, float quantizeLevel_=4.0, float quantizePad_=5.0, bool fuzz_=true, double bscale_=1.0, double bzero_=0.0) | |
General purpose Ctor. More... | |
ImageScalingOptions (int bitpix_, double bscale_=1.0, double bzero_=0.0) | |
Manual scaling Ctor. More... | |
template<typename T > | |
ImageScale | determine (image::ImageBase< T > const &image, std::shared_ptr< image::Mask< image::MaskPixel > const > mask=nullptr) const |
Determine the scaling for a particular image. More... | |
template<typename T , int N> | |
ImageScale | determine (ndarray::Array< T const, N, N > const &image, ndarray::Array< bool, N, N > const &mask) const |
Public Attributes | |
ScalingAlgorithm | algorithm |
Scaling algorithm to use. More... | |
int | bitpix |
Bits per pixel (0, 8,16,32,64,-32,-64) More... | |
bool | fuzz |
Fuzz the values when quantising floating-point values? More... | |
int | seed |
Seed for random number generator when fuzzing. More... | |
std::vector< std::string > | maskPlanes |
Mask planes to ignore when doing statistics. More... | |
float | quantizeLevel |
Divisor of the standard deviation for STDEV_* scaling. More... | |
float | quantizePad |
Number of stdev to allow on the low/high side (for STDEV_POSITIVE/NEGATIVE) More... | |
double | bscale |
Manually specified BSCALE (for MANUAL scaling) More... | |
double | bzero |
Manually specified BZERO (for MANUAL scaling) More... | |
Options for scaling image pixels.
Scaling (quantisation) of floating-point images is important in order to achieve respectable compression factors. Unfortunately, scaling a floating-point image means losing some information, in two ways: values are quantised so values in between the quanta will be rounded up or down; and values outside the range of supported values in the integer image will be clipped. This implementation is based on the successful implementation used by Pan-STARRS.
cfitsio provides a facility for scaling image pixels on write (see ImageCompressionOptions.quantizeLevel), but that facility is limited (it provides a single scaling option, and doesn't use our masks when collecting statistics). This scaling facility provides multiple scaling options, and could be extended to support more in the future (e.g., logarithmic or asinh scaling).
Scaling is specified by:
Scaling algorithms are:
Perhaps this one class could/should have been polymorphic, with different subclasses for different algorithms? But I went with a C-like approach keying off the enum, probably because I was influenced by Pan-STARRS' C code.
Definition at line 355 of file fitsCompression.h.
Definition at line 357 of file fitsCompression.h.
|
inlineexplicit |
Default Ctor.
Scaling is disabled by default.
Definition at line 378 of file fitsCompression.h.
lsst::afw::fits::ImageScalingOptions::ImageScalingOptions | ( | ScalingAlgorithm | algorithm_, |
int | bitpix_, | ||
std::vector< std::string > const & | maskPlanes_ = {} , |
||
int | seed_ = 1 , |
||
float | quantizeLevel_ = 4.0 , |
||
float | quantizePad_ = 5.0 , |
||
bool | fuzz_ = true , |
||
double | bscale_ = 1.0 , |
||
double | bzero_ = 0.0 |
||
) |
General purpose Ctor.
[in] | algorithm_ | Scaling algorithm to use |
[in] | bitpix_ | Bits per pixel (8,16,32,64,-32,-64), or 0 to match pixel type exactly. |
[in] | maskPlanes_ | Mask planes to ignore when doing statistics |
[in] | seed_ | Seed for random number generator when fuzzing |
[in] | quantizeLevel_ | Divisor of the standard deviation for STDEV_* scaling |
[in] | quantizePad_ | Number of stdev to allow on the low side (for STDEV_POSITIVE/NEGATIVE) |
[in] | fuzz_ | Fuzz the values when quantising floating-point values? |
[in] | bscale_ | Manually specified BSCALE (for MANUAL scaling) |
[in] | bzero_ | Manually specified BZERO (for MANUAL scaling) |
Definition at line 129 of file fitsCompression.cc.
|
inline |
Manual scaling Ctor.
[in] | bitpix_ | Bits per pixel (8,16,32,64,-32,-64), or 0 to match pixel type exactly. |
[in] | bscale_ | Manually specified BSCALE |
[in] | bzero_ | Manually specified BZERO |
Definition at line 403 of file fitsCompression.h.
|
inline |
Determine the scaling for a particular image.
[in] | image | Image for which to determine scaling |
[in] | mask | Mask for image (used to measuring statistics) |
Definition at line 412 of file fitsCompression.h.
ImageScale lsst::afw::fits::ImageScalingOptions::determine | ( | ndarray::Array< T const, N, N > const & | image, |
ndarray::Array< bool, N, N > const & | mask | ||
) | const |
ScalingAlgorithm lsst::afw::fits::ImageScalingOptions::algorithm |
Scaling algorithm to use.
Definition at line 365 of file fitsCompression.h.
int lsst::afw::fits::ImageScalingOptions::bitpix |
Bits per pixel (0, 8,16,32,64,-32,-64)
Definition at line 366 of file fitsCompression.h.
double lsst::afw::fits::ImageScalingOptions::bscale |
Manually specified BSCALE (for MANUAL scaling)
Definition at line 372 of file fitsCompression.h.
double lsst::afw::fits::ImageScalingOptions::bzero |
Manually specified BZERO (for MANUAL scaling)
Definition at line 373 of file fitsCompression.h.
bool lsst::afw::fits::ImageScalingOptions::fuzz |
Fuzz the values when quantising floating-point values?
Definition at line 367 of file fitsCompression.h.
std::vector<std::string> lsst::afw::fits::ImageScalingOptions::maskPlanes |
Mask planes to ignore when doing statistics.
Definition at line 369 of file fitsCompression.h.
float lsst::afw::fits::ImageScalingOptions::quantizeLevel |
Divisor of the standard deviation for STDEV_* scaling.
Definition at line 370 of file fitsCompression.h.
float lsst::afw::fits::ImageScalingOptions::quantizePad |
Number of stdev to allow on the low/high side (for STDEV_POSITIVE/NEGATIVE)
Definition at line 371 of file fitsCompression.h.
int lsst::afw::fits::ImageScalingOptions::seed |
Seed for random number generator when fuzzing.
Definition at line 368 of file fitsCompression.h.