Struct ImageCompressionOptions

Struct Documentation

struct ImageCompressionOptions

Options for tile compression of image pixels

Tile compression is a feature provided by cfitsio, where contiguous parts of the image (“tiles”, e.g., rows, multiple rows, blocks or the entire image) are compressed separately. The aim of this struct is to hold the parameters used to configure the compression.

Floating-point images can be losslessly compressed (quantizeLevel=0.0) using (only) the GZIP or GZIP_SHUFFLE compression algorithms, but the compression factor so achieved is modest (e.g., ~ 10% compression). Better compression factors can be achieved if floating-point images are first quantised into integer images. This can be done by cfitsio (through the quantizeLevel parameter) or through use of the ImageScalingOptions.

The Compression is specified by:

  • the compression algorithm

  • the tile size

  • the quantization level (for quantization applied by cfitsio; for floating-point images)

Due to bugs, cfitsio may require setting the quantizeLevel to a value other than zero when compressing integer data, but in this case it should have no effect.

Public Types

enum CompressionAlgorithm

Compression algorithms

cfitsio’s compression algorithms are #defines; these have a namespace.

We deliberately don’t support HCOMPRESS: it doesn’t appear to be useful to us (e.g., lossy) and it requires extra configuration.

Values:

NONE

No compression.

GZIP

Standard GZIP compression.

GZIP_SHUFFLE

GZIP compression with shuffle (most-significant byte first)

RICE

RICE compression.

PLIO

PLIO compression.

typedef ndarray::Array<long, 1, 1> Tiles

Public Functions

ImageCompressionOptions(CompressionAlgorithm algorithm_, Tiles tiles_, float quantizeLevel_ = 0.0)

Custom compression.

ImageCompressionOptions(CompressionAlgorithm algorithm_, std::vector<long> tiles_, float quantizeLevel_ = 0.0)
ImageCompressionOptions(CompressionAlgorithm algorithm_, int rows = 1, float quantizeLevel_ = 0.0)

Compression by rows or entire image

Parameters
  • [in] algorithm_: Compression algorithm to use

  • [in] rows: Number of rows per tile (0 = entire image)

  • [in] quantizeLevel_: cfitsio quantization level

template<typename T>
ImageCompressionOptions(image::Image<T> const &image)

Default compression for a particular style of image

Currently defaults to NONE; change to GZIP_SHUFFLE once use of compression by default has been approved (RFC-378).

template<typename T>
ImageCompressionOptions(image::Mask<T> const &mask)
ImageCompressionOptions(image::Image<std::int64_t> const &image)
ImageCompressionOptions(image::Mask<std::int64_t> const &mask)
ImageCompressionOptions(image::Image<std::uint64_t> const &image)
ImageCompressionOptions(image::Mask<std::uint64_t> const &mask)

Public Members

CompressionAlgorithm algorithm

Compresion algorithm to use.

Tiles tiles

Tile size; a dimension with 0 means infinite (e.g., to specify one row: 0,1)

float quantizeLevel

quantization level: 0.0 = none requires use of GZIP or GZIP_SHUFFLE