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>
257 virtual const std::type_info &
265 itkSetMacro(NumberOfComponents,
unsigned int);
266 itkGetConstReferenceMacro(NumberOfComponents,
unsigned int);
271 itkSetMacro(UseCompression,
bool);
272 itkGetConstMacro(UseCompression,
bool);
273 itkBooleanMacro(UseCompression);
283 itkGetConstMacro(CompressionLevel,
int);
297 itkGetConstReferenceMacro(Compressor, std::string);
301 itkSetMacro(UseStreamedReading,
bool);
302 itkGetConstMacro(UseStreamedReading,
bool);
303 itkBooleanMacro(UseStreamedReading);
308 itkSetMacro(UseStreamedWriting,
bool);
309 itkGetConstMacro(UseStreamedWriting,
bool);
310 itkBooleanMacro(UseStreamedWriting);
318 itkSetMacro(ExpandRGBPalette,
bool);
319 itkGetConstMacro(ExpandRGBPalette,
bool);
320 itkBooleanMacro(ExpandRGBPalette);
326 itkSetMacro(WritePalette,
bool);
327 itkGetConstMacro(WritePalette,
bool);
328 itkBooleanMacro(WritePalette);
335 itkGetConstMacro(IsReadAsScalarPlusPalette,
bool);
552 unsigned int numberOfActualSplits,
573 template <
typename TPixel>
579 template <
typename TPixel>
584 template <
typename TPixel>
592 template <
typename TPixel>
600 template <
typename TPixel>
608 template <
unsigned int VLength>
616 template <
typename TPixel,
unsigned int VLength>
624 template <
typename TCoordinate,
unsigned int VPo
intDimension>
632 template <
typename TPixel,
unsigned int VLength>
640 template <
typename TPixel,
unsigned int VLength>
645 this->
SetPixelType(IOPixelEnum::SYMMETRICSECONDRANKTENSOR);
648 template <
typename TPixel>
656 template <
typename TPixel>
664 template <
typename TPixel,
unsigned int VLength>
672 template <
typename TPixel>
680 template <
typename TValue>
688 template <
typename TPixel,
unsigned int VLength>
696 template <
typename TValue>
763 itkGetConstMacro(MaximumCompressionLevel,
int);
811 Reset(
const bool freeDynamic =
true);
815 Resize(
const unsigned int numDimensions,
const unsigned int * dimensions);
877 const std::string & filename,
878 bool truncate =
true,
917 unsigned int numberOfActualSplits,
929extern ITKIOImageBase_EXPORT
void
932 std::ofstream & file,
938extern ITKIOImageBase_EXPORT
void
944#define IMAGEIOBASE_TYPEMAP(type, ctype) \
946 struct ImageIOBase::MapPixelType<type> \
948 static constexpr IOComponentEnum CType = ctype; \
953IMAGEIOBASE_TYPEMAP(
char, std::numeric_limits<char>::is_signed ? IOComponentEnum::CHAR : IOComponentEnum::UCHAR);
965#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
virtual const std::type_info & GetComponentTypeInfo() const
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.