LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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. | |
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. | |
ImageScalingOptions (int bitpix_, double bscale_=1.0, double bzero_=0.0) | |
Manual scaling Ctor. | |
template<typename T > | |
ImageScale | determine (image::ImageBase< T > const &image, image::Mask< image::MaskPixel > const *mask=nullptr) const |
Determine the scaling for a particular image. | |
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. | |
int | bitpix |
Bits per pixel (0, 8,16,32,64,-32,-64) | |
bool | fuzz |
Fuzz the values when quantising floating-point values? | |
int | seed |
Seed for random number generator when fuzzing. | |
std::vector< std::string > | maskPlanes |
Mask planes to ignore when doing statistics. | |
float | quantizeLevel |
Divisor of the standard deviation for STDEV_* scaling. | |
float | quantizePad |
Number of stdev to allow on the low/high side (for STDEV_POSITIVE/NEGATIVE) | |
double | bscale |
Manually specified BSCALE (for MANUAL scaling) | |
double | bzero |
Manually specified BZERO (for MANUAL scaling) | |
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.