18#ifndef itkImageIOBase_h
19#define itkImageIOBase_h
20#include "ITKIOImageBaseExport.h"
22#include "itkIOConfigure.h"
37#include "vnl/vnl_vector.h"
38#include "vcl_compiler.h"
46template <
typename TValue>
93 itkSetStringMacro(FileName);
94 itkGetStringMacro(FileName);
109#if !defined(ITK_LEGACY_REMOVE)
112 static constexpr IOPixelEnum UNKNOWNPIXELTYPE = IOPixelEnum::UNKNOWNPIXELTYPE;
113 static constexpr IOPixelEnum SCALAR = IOPixelEnum::SCALAR;
114 static constexpr IOPixelEnum RGB = IOPixelEnum::RGB;
115 static constexpr IOPixelEnum RGBA = IOPixelEnum::RGBA;
116 static constexpr IOPixelEnum OFFSET = IOPixelEnum::OFFSET;
117 static constexpr IOPixelEnum VECTOR = IOPixelEnum::VECTOR;
118 static constexpr IOPixelEnum POINT = IOPixelEnum::POINT;
119 static constexpr IOPixelEnum COVARIANTVECTOR = IOPixelEnum::COVARIANTVECTOR;
120 static constexpr IOPixelEnum SYMMETRICSECONDRANKTENSOR = IOPixelEnum::SYMMETRICSECONDRANKTENSOR;
121 static constexpr IOPixelEnum DIFFUSIONTENSOR3D = IOPixelEnum::DIFFUSIONTENSOR3D;
122 static constexpr IOPixelEnum COMPLEX = IOPixelEnum::COMPLEX;
123 static constexpr IOPixelEnum FIXEDARRAY = IOPixelEnum::FIXEDARRAY;
124 static constexpr IOPixelEnum MATRIX = IOPixelEnum::MATRIX;
128#if !defined(ITK_LEGACY_REMOVE)
131 static constexpr IOComponentEnum UNKNOWNCOMPONENTTYPE = IOComponentEnum::UNKNOWNCOMPONENTTYPE;
140 static constexpr IOComponentEnum ULONGLONG = IOComponentEnum::ULONGLONG;
147#if !defined(ITK_LEGACY_REMOVE)
149 static constexpr IOFileEnum ASCII = IOFileEnum::ASCII;
150 static constexpr IOFileEnum Binary = IOFileEnum::Binary;
151 static constexpr IOFileEnum TypeNotApplicable = IOFileEnum::TypeNotApplicable;
155#if !defined(ITK_LEGACY_REMOVE)
158 static constexpr IOByteOrderEnum BigEndian = IOByteOrderEnum::BigEndian;
159 static constexpr IOByteOrderEnum LittleEndian = IOByteOrderEnum::LittleEndian;
160 static constexpr IOByteOrderEnum OrderNotApplicable = IOByteOrderEnum::OrderNotApplicable;
169 itkGetConstMacro(NumberOfDimensions,
unsigned int);
215 virtual std::vector<double>
223 virtual std::vector<double>
252#ifndef ITK_LEGACY_REMOVE
260 itkLegacyMacro(
virtual const std::type_info & GetComponentTypeInfo()
const);
268 itkSetMacro(NumberOfComponents,
unsigned int);
269 itkGetConstReferenceMacro(NumberOfComponents,
unsigned int);
274 itkSetMacro(UseCompression,
bool);
275 itkGetConstMacro(UseCompression,
bool);
276 itkBooleanMacro(UseCompression);
286 itkGetConstMacro(CompressionLevel,
int);
300 itkGetConstReferenceMacro(Compressor, std::string);
304 itkSetMacro(UseStreamedReading,
bool);
305 itkGetConstMacro(UseStreamedReading,
bool);
306 itkBooleanMacro(UseStreamedReading);
311 itkSetMacro(UseStreamedWriting,
bool);
312 itkGetConstMacro(UseStreamedWriting,
bool);
313 itkBooleanMacro(UseStreamedWriting);
321 itkSetMacro(ExpandRGBPalette,
bool);
322 itkGetConstMacro(ExpandRGBPalette,
bool);
323 itkBooleanMacro(ExpandRGBPalette);
329 itkSetMacro(WritePalette,
bool);
330 itkGetConstMacro(WritePalette,
bool);
331 itkBooleanMacro(WritePalette);
338 itkGetConstMacro(IsReadAsScalarPlusPalette,
bool);
555 unsigned int numberOfActualSplits,
576 template <
typename TPixel>
582 template <
typename TPixel>
587 template <
typename TPixel>
595 template <
typename TPixel>
603 template <
typename TPixel>
611 template <
unsigned int VLength>
619 template <
typename TPixel,
unsigned int VLength>
627 template <
typename TCoordinate,
unsigned int VPo
intDimension>
635 template <
typename TPixel,
unsigned int VLength>
643 template <
typename TPixel,
unsigned int VLength>
648 this->
SetPixelType(IOPixelEnum::SYMMETRICSECONDRANKTENSOR);
651 template <
typename TPixel>
659 template <
typename TPixel>
667 template <
typename TPixel,
unsigned int VLength>
675 template <
typename TPixel>
683 template <
typename TValue>
691 template <
typename TPixel,
unsigned int VLength>
699 template <
typename TValue>
766 itkGetConstMacro(MaximumCompressionLevel,
int);
814 Reset(
const bool freeDynamic =
true);
818 Resize(
const unsigned int numDimensions,
const unsigned int * dimensions);
880 const std::string & filename,
881 bool truncate =
true,
920 unsigned int numberOfActualSplits,
932extern ITKIOImageBase_EXPORT
void
935 std::ofstream & file,
941extern ITKIOImageBase_EXPORT
void
947#define IMAGEIOBASE_TYPEMAP(type, ctype) \
949 struct ImageIOBase::MapPixelType<type> \
951 static constexpr IOComponentEnum CType = ctype; \
956IMAGEIOBASE_TYPEMAP(
char, std::numeric_limits<char>::is_signed ? IOComponentEnum::CHAR : IOComponentEnum::UCHAR);
968#undef IMAGIOBASE_TYPEMAP
Array class with size defined at construction time.
A templated class holding a n-Dimensional covariant vector.
Represent a diffusion tensor as used in DTI images.
Simulate a standard C array with copy semantics.
virtual unsigned int GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits, const ImageIORegion &pasteRegion, const ImageIORegion &largestPossibleRegion)
void SetPixelTypeInfo(const VariableSizeMatrix< TValue > *)
virtual double GetOrigin(unsigned int i) const
virtual ImageIORegion GetSplitRegionForWriting(unsigned int ithPiece, unsigned int numberOfActualSplits, const ImageIORegion &pasteRegion, const ImageIORegion &largestPossibleRegion)
void SetPixelTypeInfo(const Matrix< TPixel, VLength, VLength > *)
std::vector< std::vector< double > > m_Direction
virtual void InternalSetCompressor(const std::string &_compressor)
bool ReadBufferAsBinary(std::istream &is, void *buffer, SizeType num)
bool m_UseStreamedReading
virtual void Reset(const bool freeDynamic=true)
void AddSupportedReadExtension(const char *extension)
virtual double GetSpacing(unsigned int i) const
void SetPixelTypeInfo(const DiffusionTensor3D< TPixel > *)
SmartPointer< const Self > ConstPointer
void SetByteOrderToBigEndian()
virtual void SetOrigin(unsigned int i, double origin)
std::vector< SizeValueType > m_Dimensions
void SetPixelTypeInfo(const CovariantVector< TPixel, VLength > *)
virtual void OpenFileForWriting(std::ofstream &outputStream, const std::string &filename, bool truncate=true, bool ascii=false)
Opens a file for writing and random access.
virtual bool CanReadFile(const char *)=0
IOByteOrderEnum m_ByteOrder
virtual void SetNumberOfComponents(unsigned int _arg)
virtual void ReadBufferAsASCII(std::istream &is, void *buffer, IOComponentEnum ctype, SizeType numComp)
virtual bool HasSupportedWriteExtension(const char *fileName, bool ignoreCase=true)
void SetPixelTypeInfo(const FixedArray< TPixel, VLength > *)
virtual std::vector< double > GetDirection(unsigned int i) const
std::vector< double > m_Spacing
virtual unsigned int GetPixelSize() const
SizeType GetRowStride() const
virtual void SetComponentType(const IOComponentEnum _arg)
IOComponentEnum m_ComponentType
std::vector< double > m_Origin
virtual ImageIORegion GetSplitRegionForWritingCanStreamWrite(unsigned int ithPiece, unsigned int numberOfActualSplits, const ImageIORegion &pasteRegion) const
void SetPixelTypeInfo(const SymmetricSecondRankTensor< TPixel, VLength > *)
SizeType GetImageSizeInComponents() const
virtual void WriteBufferAsASCII(std::ostream &os, const void *buffer, IOComponentEnum ctype, SizeType numComp)
virtual void SetDirection(unsigned int i, const std::vector< double > &direction)
void SetSupportedReadExtensions(const ArrayOfExtensionsType &)
virtual void SetMaximumCompressionLevel(int)
virtual unsigned int GetComponentSize() const
SizeType GetComponentStride() const
ArrayOfExtensionsType m_SupportedWriteExtensions
unsigned int m_NumberOfComponents
std::string GetByteOrderAsString(IOByteOrderEnum) const
virtual const ImageRegionSplitterBase * GetImageRegionSplitter() const
SizeType GetImageSizeInBytes() const
void SetTypeInfo(const TPixel *)
virtual bool SupportsDimension(unsigned long dim)
ArrayOfExtensionsType m_SupportedReadExtensions
virtual bool HasSupportedReadExtension(const char *fileName, bool ignoreCase=true)
virtual unsigned int GetActualNumberOfSplitsForWritingCanStreamWrite(unsigned int numberOfRequestedSplits, const ImageIORegion &pasteRegion) const
virtual void SetCompressor(std::string _c)
Set/Get the compression algorithm to use.
const ArrayOfExtensionsType & GetSupportedReadExtensions() const
void SetFileTypeToBinary()
virtual bool CanStreamWrite()
static IOComponentEnum GetComponentTypeFromString(const std::string &typeString)
SmartPointer< Self > Pointer
bool HasSupportedExtension(const char *, const ArrayOfExtensionsType &, bool ignoreCase=true)
static IOPixelEnum GetPixelTypeFromString(const std::string &pixelString)
void SetPixelTypeInfo(const Vector< TPixel, VLength > *)
void SetPixelTypeInfo(const Offset< VLength > *)
void SetPixelTypeInfo(const Array< TValue > *)
virtual void SetByteOrder(const IOByteOrderEnum _arg)
virtual bool CanWriteFile(const char *)=0
virtual void Write(const void *buffer)=0
bool m_UseStreamedWriting
virtual void SetDirection(unsigned int i, const vnl_vector< double > &direction)
virtual ImageIORegion GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion &requested) const
void SetPixelTypeInfo(const RGBPixel< TPixel > *)
itk::IOByteOrderEnum IOByteOrderEnum
void SetPixelTypeInfo(const std::complex< TPixel > *)
void SetByteOrderToLittleEndian()
void SetSupportedWriteExtensions(const ArrayOfExtensionsType &)
virtual SizeValueType GetDimensions(unsigned int i) const
bool m_IsReadAsScalarPlusPalette
const ArrayOfExtensionsType & GetSupportedWriteExtensions() const
SizeType GetImageSizeInPixels() const
void Resize(const unsigned int numDimensions, const unsigned int *dimensions)
std::string GetFileTypeAsString(IOFileEnum) const
itk::OffsetValueType BufferSizeType
virtual void WriteImageInformation()=0
itk::IOComponentEnum IOComponentEnum
static std::string GetComponentTypeAsString(IOComponentEnum)
virtual void SetFileType(const IOFileEnum _arg)
std::vector< SizeType > m_Strides
LightProcessObject Superclass
static std::string GetPixelTypeAsString(IOPixelEnum)
unsigned int m_NumberOfDimensions
virtual void SetDimensions(unsigned int i, SizeValueType dim)
virtual void SetSpacing(unsigned int i, double spacing)
void SetPixelTypeInfo(const RGBAPixel< TPixel > *)
void SetPixelTypeInfo(const TPixel *)
virtual void SetPixelType(const itk::CommonEnums::IOPixel _arg)
void SetNumberOfDimensions(unsigned int)
itk::SizeValueType SizeValueType
void SetFileTypeToASCII()
virtual bool CanStreamRead()
void AddSupportedWriteExtension(const char *extension)
virtual void ReadImageInformation()=0
std::vector< std::string > ArrayOfExtensionsType
virtual std::vector< double > GetDefaultDirection(unsigned int k) const
virtual void Read(void *buffer)=0
int m_MaximumCompressionLevel
void SetPixelTypeInfo(const VariableLengthVector< TPixel > *)
virtual void OpenFileForReading(std::ifstream &inputStream, const std::string &filename, bool ascii=false)
Opens a file for reading and random access.
itk::IOFileEnum IOFileEnum
virtual int GetMaximumCompressionLevel() const
virtual SizeType GetPixelStride() const
itk::IndexValueType IndexValueType
void PrintSelf(std::ostream &os, Indent indent) const override
SizeType GetSliceStride() const
void SetPixelTypeInfo(const Point< TCoordinate, VPointDimension > *)
An ImageIORegion represents a structured region of data.
Divide an image region into several pieces.
Control indentation during Print() invocation.
A templated class holding a M x N size Matrix.
A templated class holding a geometric point in n-Dimensional space.
Represent Red, Green, Blue and Alpha components for color images.
Represent Red, Green and Blue components for color images.
Implements transparent reference counting.
Represent a symmetric tensor of second rank.
A templated class holding a M x N size Matrix.
A templated class holding a n-Dimensional vector.
#define IMAGEIOBASE_TYPEMAP(type, ctype)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
CommonEnums::IOComponent IOComponentEnum
unsigned long SizeValueType
CommonEnums::IOFile IOFileEnum
CommonEnums::IOByteOrder IOByteOrderEnum
ITKIOImageBase_EXPORT void WriteRawBytesAfterSwapping(IOComponentEnum componentType, const void *buffer, std::ofstream &file, IOByteOrderEnum byteOrder, SizeValueType numberOfBytes, SizeValueType numberOfComponents)
CommonEnums::IOPixel IOPixelEnum
ITKIOImageBase_EXPORT void ReadRawBytesAfterSwapping(IOComponentEnum componentType, void *buffer, IOByteOrderEnum byteOrder, SizeValueType numberOfComponents)
static constexpr IOComponentEnum CType
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.