EleFits
4.0.1
A modern C++ API on top of CFitsIO
|
#include <Raster.h>
Raster of a n-dimensional image (2D by default).
T | The value type, which can be const -qualified for read-only rasters |
n | The 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:
PtrRaster
doesn's itself own data: it is just a shell which stores a shape, and a pointer to some actual data;VecRaster
owns an std::vector
(and is compatible with move semantics, which allows borrowing the vector
).There are two ways of defining the dimension of a Raster
:
n = -1
.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:
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
.
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.Public Member Functions | |
~PtrRaster ()=default | |
Destructor. | |
PtrRaster (const PtrRaster &)=default | |
Copy constructor. | |
PtrRaster (PtrRaster &&)=default | |
Move constructor. | |
PtrRaster & | operator= (const PtrRaster &)=default |
Copy assignment operator. | |
PtrRaster & | operator= (PtrRaster &&)=default |
Move assignment operator. | |
PtrRaster (Position< n > shape, T *data) | |
Constructor. | |