Struct ImageScale

Struct Documentation

struct ImageScale

Scale to apply to image

Images are scaled to the type implied by the provided BITPIX using the provided scale and zero-point:

value in memory = BZERO + BSCALE * value in FITS

In addition to scaling, a random field of values distributed [0,1) may be added before quantisation (“fuzz”); this preserves the expectation value of the floating-point image, while increasing the variance by 1/12.

Public Functions

ImageScale(int bitpix_, double bscale_, double bzero_)

Constructor

We make BZERO an integer multiple of BSCALE, because cfitsio notes: “This helps to ensure the same scaling will be performed if the

file undergoes multiple fpack/funpack cycles”.

The BLANK is 255 for BITPIX=8 since FITS specifies that uses unsigned char; otherwise it is set to the maximum int for the appropriate signed integer.

template<typename T>
std::shared_ptr<detail::PixelArrayBase> toFits(ndarray::Array<T const, 2, 2> const &image, bool forceNonfiniteRemoval, bool fuzz = true, ndarray::Array<long, 1> const &tiles = ndarray::Array<long, 1, 1>(), int seed = 1) const

Convert to an array of pixel values to write to FITS

Return

Array of pixel values, appropriately scaled.

Parameters
  • [in] image: Image to scale

  • [in] forceNonfiniteRemoval: Force removal of non-finite values? This is useful for lossless compression, because cfitsio doesn’t mask out non-finite values, and they end up contaminating the entire tile.

  • [in] fuzz: Add random values before quantising?

  • [in] tiles: Tile dimensions

  • [in] seed: Seed for random number generator

template<typename T>
ndarray::Array<T, 2, 2> fromFits(ndarray::Array<T, 2, 2> const &image) const

Convert to an array

Use of this method is generally not necessary, since cfitsio automatically applies the scaling on read. However, it may be useful for applying novel scalings (e.g., logarithmic).

Public Members

int bitpix

Bits per pixel; negative means floating-point: 8,16,32,64,-32,-64.

double bscale

Scale to apply when reading from FITS.

double bzero

Zero-point to apply when reading from FITS.

long blank

Value for integer images indicating non-finite values.