Image Class


Image class is the responsible of handling image files. According to the file extension it selects the specific algorithm for each format and then, It read the header. Finally, Image data is set into a MultidimArray. Image is a template class (i.e. its datatype is decided by the programmer). Therefore, if a Image<char> is used to read from a file whose datatype is, let say, float, then bytes are truncated for each pixel with an information loss.


The simplest way of reading an image is:

Image<double> img;

although the read method allows different special cases as follows:

Reading the header

It is possible to read only the values of the image file header. The information read is: image dimensions, data type, offset and bit order

Image<double> img;
img.read('filename.ext', HEADER);
ArrayDim aDim;
DataType datatype;
datatype = img.datatype();

Reading from stack

Reading independent images in a stack can be done in two ways: adding a prefix number to the filename separated by @,


or passing the selected image number as argument,

img.read('filename.ext', DATA, 2);


Single image writing

Stack writing


File format

Data type


How to map?

Map if possible


Creating images

Transform images (rotate, scale, shift)