ITK features a powerful plugin-based IO mechanism for reading and writing images, which is covered in detail in Chapter 7 (PDF page 219) of the ITK Software Guide.
File Formats and Pixel Types
The itk::Image<> class can be templated over virtually any pixel type, however not all file formats support all data types for reading and writing. In some cases, it may be necessary to add an itk::CastImageFilter<> to convert the output to a pixel format appropriate for the target file. It is important not to truncate the data by converting to a smaller type (ie. short -> char). In this case, the itk::RescaleIntensityImageFilter<> can be used before casting.
The following table lists the built-in file format support against each data type:
char unsigned char short unsigned short int unsigned int float double RGB<unsigned char>
- BMP (2D only)
unsigned char RGB<unsigned char>
float char unsigned char short unsigned short RGB<char> RGB<short>
unsigned char char unsigned short short unsigned int int double
binary char unsigned char short unsigned short unsigned int int float double short surface polygon
- JPEG (2D only)
- MetaImage (mhd): raw, compressed
char unsigned char short unsigned short long ulong int unsigned int float double vector<> Also supports reading and writing - itk's SpatialObjects (i.e., scenes containing ellipses, images, vessels, dti fiber tracks, etc) - Patient Meta Data (orientation, scan date, comments, modality, etc. - user extensible) - data stored in multiple files (e.g., a metaImage file could be a text file pointing to a series of 2D images that are stacked to form the 3D metaImage).
char unsigned char short unsigned short int unsigned int float double
- PNG (2D)
unsigned char unsigned short RGB RGBA
char short int float double
- TIFF (2D only)
unsigned char unsigned short RGB
float double unsigned char char unsigned short short unsigned int int unsigned long long RGB