EleFits  4.0.0
A modern C++ API on top of CFitsIO
Public Member Functions | List of all members
Euclid::Fits::PtrRaster< T, n > Class Template Reference

#include <Raster.h>

Class Description

template<typename T, long n = 2>
class Euclid::Fits::PtrRaster< T, n >

Raster of a n-dimensional image (2D by default).

Template Parameters
TThe value type, which can be const-qualified for read-only rasters
nThe dimension, which can be >= 0 for fixed dimension, or -1 for variable dimension

A raster is a contiguous container for the pixel data of an image. It features access and view services.

This class is abstract, as the actual pixel container is not defined. Two concrete implementations are provided:

There are two ways of defining the dimension of a Raster:

In the former case, index and size computations are optimized, and the dimension is enforced. For example, it is not possible to read a 3D image HDU as a 2D Raster. Which is nice, because an exception will be raised early! In contrast, it is possible to read a 2D image HDU as a 3D Raster of third axis lenght =1.

In the latter case, the dimension may vary or be deduced from the file, which is also nice sometimes but puts more responsibility on the shoulders of the user code, as it should check that the returned dimension is acceptable.

Raster ensures constant-time access to elements, whatever the dimension of the data, through subscipt operator Raster::operator[](). Bound checking and backward indexing (index <0) are enabled in Raster::at().

Example usages:

Position<2> shape { 2, 3 };
// Read/write Raster
float data[] = { 1, 2, 3, 4, 5, 6 };
Raster<float> raster(shape, data);
// Read-only Raster
const float cData[] = { 1, 2, 3, 4, 5, 6 };
Raster<const float> cRaster(shape, cData);
// Read/write VecRaster
std::vector<float> vec(&data[0], &data[6]);
VecRaster<float> vecRaster(shape, std::move(vec));
// Read-only VecRaster
std::vector<const float> cVec(&data[0], &data[6]);
VecRaster<const float> cVecRaster(shape, std::move(cVec));

The raster data can be viewed region-wise as a PtrRaster, given that the region is contiguous in memory. Reading and writing non contiguous region is possible: see ImageRaster.

Note
Why "raster" and not simply image or array? Mostly for disambiguation purpose: "image" refers to the extension type, while "array" has already several meanings in C/C++. NdArray would have been an option, but every related class should have been prefixed with Nd for homogeneity: NdPosition, NdRegion, VecNdArray... From the cathodic television era, raster also historically carries the concept of contiguous pixels, is very common in the field of Earth observation, and also belongs to the Java library. All in all, Raster seems to be a fair compromise.
See also
Position for details on the fixed- and variable-dimension cases.
makeRaster() for creation shortcuts.

Public Member Functions

 ~PtrRaster ()=default
 Destructor.
 
 PtrRaster (const PtrRaster &)=default
 Copy constructor.
 
 PtrRaster (PtrRaster &&)=default
 Move constructor.
 
PtrRasteroperator= (const PtrRaster &)=default
 Copy assignment operator.
 
PtrRasteroperator= (PtrRaster &&)=default
 Move assignment operator.
 
 PtrRaster (Position< n > shape, T *data)
 Constructor.
 

The documentation for this class was generated from the following file:
std::move
T move(T... args)
std::vector
STL class.