#include <itkNrrdImageIO.h>
Read and write the "Nearly Raw Raster Data" (Nrrd) image format. The Nrrd format was developed as part of the Teem package (teem.sourceforge.net).
The compressor supported may include "gzip" (default) and "bzip2". Only the "gzip" compressor support the compression level in the range 0-9.
The NRRD file format supports two types of metadata, fields, "<field>:<desc>" and key/value pairs, "<key>:=<value>" (https://teem.sourceforge.net/nrrd/format.html#general.2). General, non NRRD specific, metadata entries added to an image's metadata dictionary will be written to file using key/value notation. NRRD specific metadata entries must be added to the image's metadata dictionary using "NRRD_<field>" as the key. For example, the information for the NRRD "content" field is added using the key "NRRD_content". When a field consists of multiple values, per axis fields (https://teem.sourceforge.net/nrrd/format.html#per-axis), a per axis key is used. For example, to set the information in the image's metadata dictionary so that when written to file the result is, "thicknesses: 0.7 0.8 0.9", we need to add three entries to the dictionary with keys: "NRRD_thicknesses[0]", "NRRD_thicknesses[1]" and "NRRD_thicknesses[2]".
Definition at line 84 of file itkNrrdImageIO.h.
Public Member Functions | |
bool | CanReadFile (const char *) override |
bool | CanWriteFile (const char *) override |
virtual::itk::LightObject::Pointer | CreateAnother () const |
virtual AxesReorderEnum | GetAxesReorder () const |
virtual const char * | GetNameOfClass () const |
void | Read (void *buffer) override |
void | ReadImageInformation () override |
virtual void | SetAxesReorder (AxesReorderEnum _arg) |
void | SetAxesReorderToUseAnyRangeAxisAsPixel () |
void | SetAxesReorderToUseNonListRangeAxisAsPixel () |
void | SetAxesReorderToUseScalarPixel () |
bool | SupportsDimension (unsigned long) override |
void | Write (const void *buffer) override |
void | WriteImageInformation () override |
![]() | |
virtual bool | CanStreamRead () |
virtual bool | CanStreamWrite () |
virtual ImageIORegion | GenerateStreamableReadRegionFromRequestedRegion (const ImageIORegion &requested) const |
virtual unsigned int | GetActualNumberOfSplitsForWriting (unsigned int numberOfRequestedSplits, const ImageIORegion &pasteRegion, const ImageIORegion &largestPossibleRegion) |
std::string | GetByteOrderAsString (IOByteOrderEnum) const |
virtual unsigned int | GetComponentSize () const |
virtual IOComponentEnum | GetComponentType () const |
virtual int | GetCompressionLevel () const |
virtual const std::string & | GetCompressor () const |
virtual std::vector< double > | GetDefaultDirection (unsigned int k) const |
virtual std::vector< double > | GetDirection (unsigned int i) const |
std::string | GetFileTypeAsString (IOFileEnum) const |
SizeType | GetImageSizeInBytes () const |
SizeType | GetImageSizeInComponents () const |
SizeType | GetImageSizeInPixels () const |
virtual bool | GetIsReadAsScalarPlusPalette () const |
virtual unsigned int | GetNumberOfDimensions () const |
virtual double | GetOrigin (unsigned int i) const |
virtual SizeType | GetPixelStride () const |
virtual double | GetSpacing (unsigned int i) const |
virtual ImageIORegion | GetSplitRegionForWriting (unsigned int ithPiece, unsigned int numberOfActualSplits, const ImageIORegion &pasteRegion, const ImageIORegion &largestPossibleRegion) |
const ArrayOfExtensionsType & | GetSupportedReadExtensions () const |
const ArrayOfExtensionsType & | GetSupportedWriteExtensions () const |
void | SetByteOrderToLittleEndian () |
virtual void | SetComponentType (const IOComponentEnum _arg) |
virtual void | SetCompressionLevel (int _arg) |
virtual void | SetCompressor (std::string _c) |
virtual void | SetDirection (unsigned int i, const std::vector< double > &direction) |
virtual void | SetDirection (unsigned int i, const vnl_vector< double > &direction) |
void | SetFileTypeToBinary () |
void | SetNumberOfDimensions (unsigned int) |
virtual void | SetOrigin (unsigned int i, double origin) |
virtual void | SetSpacing (unsigned int i, double spacing) |
virtual void | SetFileName (const char *_arg) |
virtual const char * | GetFileName () const |
virtual void | SetDimensions (unsigned int i, SizeValueType dim) |
virtual SizeValueType | GetDimensions (unsigned int i) const |
virtual void | SetIORegion (ImageIORegion _arg) |
virtual const ImageIORegion & | GetIORegion () const |
virtual void | SetPixelType (const itk::CommonEnums::IOPixel _arg) |
virtual itk::CommonEnums::IOPixel | GetPixelType () const |
virtual void | SetNumberOfComponents (unsigned int _arg) |
virtual const unsigned int & | GetNumberOfComponents () const |
virtual void | SetUseCompression (bool _arg) |
virtual bool | GetUseCompression () const |
virtual void | UseCompressionOn () |
virtual void | UseCompressionOff () |
virtual void | SetUseStreamedReading (bool _arg) |
virtual bool | GetUseStreamedReading () const |
virtual void | UseStreamedReadingOn () |
virtual void | UseStreamedReadingOff () |
virtual void | SetUseStreamedWriting (bool _arg) |
virtual bool | GetUseStreamedWriting () const |
virtual void | UseStreamedWritingOn () |
virtual void | UseStreamedWritingOff () |
virtual void | SetExpandRGBPalette (bool _arg) |
virtual bool | GetExpandRGBPalette () const |
virtual void | ExpandRGBPaletteOn () |
virtual void | ExpandRGBPaletteOff () |
virtual void | SetWritePalette (bool _arg) |
virtual bool | GetWritePalette () const |
virtual void | WritePaletteOn () |
virtual void | WritePaletteOff () |
virtual void | SetFileType (const IOFileEnum _arg) |
virtual IOFileEnum | GetFileType () const |
void | SetFileTypeToASCII () |
virtual void | SetByteOrder (const IOByteOrderEnum _arg) |
virtual IOByteOrderEnum | GetByteOrder () const |
void | SetByteOrderToBigEndian () |
template<typename TPixel> | |
void | SetPixelTypeInfo (const TPixel *) |
template<typename TComponent> | |
void | SetPixelTypeInfo (const RGBPixel< TComponent > *) |
template<typename TComponent> | |
void | SetPixelTypeInfo (const RGBAPixel< TComponent > *) |
template<unsigned int VLength> | |
void | SetPixelTypeInfo (const Offset< VLength > *) |
template<typename TComponent, unsigned int VLength> | |
void | SetPixelTypeInfo (const Vector< TComponent, VLength > *) |
template<typename TCoordinate, unsigned int VPointDimension> | |
void | SetPixelTypeInfo (const Point< TCoordinate, VPointDimension > *) |
template<typename TComponent, unsigned int VLength> | |
void | SetPixelTypeInfo (const CovariantVector< TComponent, VLength > *) |
template<typename TComponent, unsigned int VLength> | |
void | SetPixelTypeInfo (const SymmetricSecondRankTensor< TComponent, VLength > *) |
template<typename TComponent> | |
void | SetPixelTypeInfo (const DiffusionTensor3D< TComponent > *) |
template<typename TComponent> | |
void | SetPixelTypeInfo (const std::complex< TComponent > *) |
template<typename TComponent, unsigned int VLength> | |
void | SetPixelTypeInfo (const FixedArray< TComponent, VLength > *) |
template<typename TComponent> | |
void | SetPixelTypeInfo (const VariableLengthVector< TComponent > *) |
template<typename TValue> | |
void | SetPixelTypeInfo (const Array< TValue > *) |
template<typename TComponent, unsigned int VLength> | |
void | SetPixelTypeInfo (const Matrix< TComponent, VLength, VLength > *) |
template<typename TValue> | |
void | SetPixelTypeInfo (const VariableSizeMatrix< TValue > *) |
![]() | |
virtual void | AbortGenerateDataOff () |
virtual void | AbortGenerateDataOn () |
virtual const bool & | GetAbortGenerateData () const |
virtual void | SetAbortGenerateData (bool _arg) |
virtual void | UpdateOutputData () |
void | UpdateProgress (float amount) |
virtual void | SetProgress (float _arg) |
virtual const float & | GetProgress () const |
![]() | |
unsigned long | AddObserver (const EventObject &event, Command *cmd) const |
unsigned long | AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const |
LightObject::Pointer | CreateAnother () const override |
virtual void | DebugOff () const |
virtual void | DebugOn () const |
Command * | GetCommand (unsigned long tag) |
bool | GetDebug () const |
MetaDataDictionary & | GetMetaDataDictionary () |
const MetaDataDictionary & | GetMetaDataDictionary () const |
virtual ModifiedTimeType | GetMTime () const |
virtual const TimeStamp & | GetTimeStamp () const |
bool | HasObserver (const EventObject &event) const |
void | InvokeEvent (const EventObject &) |
void | InvokeEvent (const EventObject &) const |
virtual void | Modified () const |
void | Register () const override |
void | RemoveAllObservers () |
void | RemoveObserver (unsigned long tag) const |
void | SetDebug (bool debugFlag) const |
void | SetReferenceCount (int) override |
void | UnRegister () const noexcept override |
void | SetMetaDataDictionary (const MetaDataDictionary &rhs) |
void | SetMetaDataDictionary (MetaDataDictionary &&rrhs) |
virtual void | SetObjectName (std::string _arg) |
virtual const std::string & | GetObjectName () const |
![]() | |
Pointer | Clone () const |
virtual void | Delete () |
virtual int | GetReferenceCount () const |
void | Print (std::ostream &os, Indent indent=0) const |
Static Public Member Functions | |
static Pointer | New () |
![]() | |
static std::string | GetComponentTypeAsString (IOComponentEnum) |
static IOComponentEnum | GetComponentTypeFromString (const std::string &typeString) |
static constexpr IOComponentEnum | GetComponentTypeFromTypeTraits (const bool isFloatingPoint, const bool isUnsigned, const vcl_size_t numberOfBits) |
static constexpr vcl_size_t | GetNumberOfBitsOfComponentType (const IOComponentEnum componentEnum) |
static std::string | GetPixelTypeAsString (IOPixelEnum) |
static IOPixelEnum | GetPixelTypeFromString (const std::string &pixelString) |
static constexpr bool | IsComponentTypeFloatingPoint (const IOComponentEnum componentEnum) |
static constexpr bool | IsComponentTypeUnsigned (const IOComponentEnum componentEnum) |
![]() | |
static Pointer | New () |
![]() | |
static bool | GetGlobalWarningDisplay () |
static void | GlobalWarningDisplayOff () |
static void | GlobalWarningDisplayOn () |
static Pointer | New () |
static void | SetGlobalWarningDisplay (bool val) |
![]() | |
static void | BreakOnError () |
static Pointer | New () |
Protected Member Functions | |
void | InternalSetCompressor (const std::string &_compressor) override |
int | ITKToNrrdComponentType (const IOComponentEnum) const |
NrrdImageIO () | |
IOComponentEnum | NrrdToITKComponentType (const int) const |
void | PrintSelf (std::ostream &os, Indent indent) const override |
~NrrdImageIO () override | |
![]() | |
void | AddSupportedReadExtension (const char *extension) |
void | AddSupportedWriteExtension (const char *extension) |
void | ComputeStrides () |
virtual unsigned int | GetActualNumberOfSplitsForWritingCanStreamWrite (unsigned int numberOfRequestedSplits, const ImageIORegion &pasteRegion) const |
SizeType | GetComponentStride () const |
virtual const ImageRegionSplitterBase * | GetImageRegionSplitter () const |
virtual unsigned int | GetPixelSize () const |
SizeType | GetRowStride () const |
SizeType | GetSliceStride () const |
virtual ImageIORegion | GetSplitRegionForWritingCanStreamWrite (unsigned int ithPiece, unsigned int numberOfActualSplits, const ImageIORegion &pasteRegion) const |
ImageIOBase () | |
virtual void | OpenFileForReading (std::ifstream &inputStream, const std::string &filename, bool ascii=false) |
virtual void | OpenFileForWriting (std::ofstream &outputStream, const std::string &filename, bool truncate=true, bool ascii=false) |
virtual void | ReadBufferAsASCII (std::istream &is, void *buffer, IOComponentEnum ctype, SizeType numComp) |
bool | ReadBufferAsBinary (std::istream &is, void *buffer, SizeType num) |
virtual void | Reset (const bool freeDynamic=true) |
void | Resize (const unsigned int numDimensions, const unsigned int *dimensions) |
void | SetSupportedReadExtensions (const ArrayOfExtensionsType &) |
void | SetSupportedWriteExtensions (const ArrayOfExtensionsType &) |
virtual void | WriteBufferAsASCII (std::ostream &os, const void *buffer, IOComponentEnum ctype, SizeType numComp) |
~ImageIOBase () override | |
virtual bool | HasSupportedReadExtension (const char *fileName, bool ignoreCase=true) |
virtual bool | HasSupportedWriteExtension (const char *fileName, bool ignoreCase=true) |
virtual void | SetMaximumCompressionLevel (int) |
virtual int | GetMaximumCompressionLevel () const |
![]() | |
virtual void | GenerateData () |
LightProcessObject () | |
~LightProcessObject () override | |
![]() | |
Object () | |
bool | PrintObservers (std::ostream &os, Indent indent) const |
void | PrintSelf (std::ostream &os, Indent indent) const override |
virtual void | SetTimeStamp (const TimeStamp &timeStamp) |
~Object () override | |
![]() | |
virtual LightObject::Pointer | InternalClone () const |
LightObject () | |
virtual void | PrintHeader (std::ostream &os, Indent indent) const |
virtual void | PrintTrailer (std::ostream &os, Indent indent) const |
virtual | ~LightObject () |
Protected Attributes | |
AxesReorderEnum | m_AxesReorder { AxesReorderEnum::UseAnyRangeAxisAsPixel } |
const NrrdEncoding_t * | m_NrrdCompressionEncoding { nullptr } |
![]() | |
IOByteOrderEnum | m_ByteOrder { IOByteOrderEnum::OrderNotApplicable } |
IOComponentEnum | m_ComponentType { IOComponentEnum::UNKNOWNCOMPONENTTYPE } |
int | m_CompressionLevel { 30 } |
std::string | m_Compressor { "uninitialized" } |
std::vector< SizeValueType > | m_Dimensions {} |
std::vector< std::vector< double > > | m_Direction {} |
bool | m_ExpandRGBPalette {} |
std::string | m_FileName {} |
IOFileEnum | m_FileType { IOFileEnum::TypeNotApplicable } |
bool | m_Initialized {} |
ImageIORegion | m_IORegion {} |
bool | m_IsReadAsScalarPlusPalette {} |
int | m_MaximumCompressionLevel { 100 } |
unsigned int | m_NumberOfComponents {} |
unsigned int | m_NumberOfDimensions { 0 } |
std::vector< double > | m_Origin {} |
IOPixelEnum | m_PixelType { IOPixelEnum::SCALAR } |
std::vector< double > | m_Spacing {} |
std::vector< SizeType > | m_Strides {} |
bool | m_UseCompression { false } |
bool | m_UseStreamedReading {} |
bool | m_UseStreamedWriting {} |
bool | m_WritePalette {} |
![]() | |
std::atomic< int > | m_ReferenceCount {} |
using itk::NrrdImageIO::Pointer = SmartPointer<Self> |
Definition at line 92 of file itkNrrdImageIO.h.
using itk::NrrdImageIO::Self = NrrdImageIO |
Standard class type aliases.
Definition at line 90 of file itkNrrdImageIO.h.
Definition at line 91 of file itkNrrdImageIO.h.
|
protected |
Referenced by GetNameOfClass().
|
overrideprotected |
|
overridevirtual |
Determine the file type. Returns true if this ImageIO can read the file specified.
Implements itk::ImageIOBase.
|
overridevirtual |
Determine the file type. Returns true if this ImageIO can write the file specified.
Implements itk::ImageIOBase.
|
virtual |
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.
Reimplemented from itk::LightProcessObject.
|
virtual |
|
virtual |
Reimplemented from itk::ImageIOBase.
References NrrdImageIO().
|
overrideprotectedvirtual |
Called when the compressor changes value. The compressor string is converted to uppercase for case insensitive comparisons.
Reimplemented from itk::ImageIOBase.
|
protected |
Utility functions for converting between enumerated data type representations
|
static |
Method for creation through the object factory.
|
protected |
|
overrideprotectedvirtual |
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from itk::ImageIOBase.
|
overridevirtual |
Reads the data from disk into the memory buffer provided.
Implements itk::ImageIOBase.
|
overridevirtual |
Set the spacing and dimension information for the set filename.
Implements itk::ImageIOBase.
|
virtual |
Set/Get the strategy for axis reordering. ITK image can be an Image object that can store scalar, RGB, CovariantVector, etc. pixels in an arbitrarily high dimensional array. If the number of components of the pixel has to be dynamic then the ITK image has to be a VectorImage object that can store multi-component pixels in an arbitrarily high dimensional array.
NRRD file can contain domain (space, time) axes and range (list, RGB, covariant-vector, etc.) axes in an arbitrary order. Therefore, axes of the NRRD file may have to be reordered to be able to read the NRRD file into an ITK image. In general, NRRD domain axes are mapped to ITK image axes then all range axes are used as additional image dimensions. The only exception is that it makes sense to pick one a range axis and use that as pixel component.
In early ITK versions, any kind of NRRD range axis was used as pixel component by default (this is the UseAnyRangeAxisAsPixel strategy). However, this resulted in more complicated application code (developers need to instantiate an Image or VectorImage depending on what kind of axes are in the NRRD file) and potential unnecessary reordering of axes (e.g., sequence of 3D images was always converted into a single multi-component 3D image).
Therefore additional strategies were introduced to allow more control over how NRRD axes are mapped to ITK image axes and pixel component. UseNonListRangeAxisAsPixel to ensure that the image can be always read into an Image object. UseScalarPixel to ensure that the image can be always read into an Image object with a scalar pixel type.
Examples:
NRRD file: list domain domain domain RGB-Color (or: domain domain domain list RGB-Color)
NRRD file: list domain domain domain (or: domain domain domain list)
Referenced by SetAxesReorderToUseAnyRangeAxisAsPixel(), SetAxesReorderToUseNonListRangeAxisAsPixel(), and SetAxesReorderToUseScalarPixel().
|
inline |
Use the first a range axis (i.e., non-domain axis) of the NRRD file as pixel component.
Definition at line 181 of file itkNrrdImageIO.h.
References SetAxesReorder().
|
inline |
UseNonListRangeAxisAsPixel Use the first non-list range axis (i.e., non-domain axis) of the NRRD file as pixel component.
Definition at line 189 of file itkNrrdImageIO.h.
References SetAxesReorder().
|
inline |
UseScalarPixel Pixel type is scalar. All range (i.e., non-domain) axes of the NRRD file are added as additional domain axes.
Definition at line 197 of file itkNrrdImageIO.h.
References SetAxesReorder().
|
overridevirtual |
The different types of ImageIO's can support data of varying dimensionality. For example, some file formats are strictly 2D while others can support 2D, 3D, or even n-D. This method returns true/false as to whether the ImageIO can support the dimension indicated.
Reimplemented from itk::ImageIOBase.
|
overridevirtual |
Writes the data to disk from the memory buffer provided. Make sure that the IORegions has been set properly.
Implements itk::ImageIOBase.
|
overridevirtual |
Set the spacing and dimension information for the set filename.
Implements itk::ImageIOBase.
|
protected |
Definition at line 221 of file itkNrrdImageIO.h.
|
protected |
Definition at line 219 of file itkNrrdImageIO.h.