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>
92 itkSetStringMacro(FileName);
93 itkGetStringMacro(FileName);
108#if !defined(ITK_LEGACY_REMOVE)
111 static constexpr IOPixelEnum UNKNOWNPIXELTYPE = IOPixelEnum::UNKNOWNPIXELTYPE;
112 static constexpr IOPixelEnum SCALAR = IOPixelEnum::SCALAR;
113 static constexpr IOPixelEnum RGB = IOPixelEnum::RGB;
114 static constexpr IOPixelEnum RGBA = IOPixelEnum::RGBA;
115 static constexpr IOPixelEnum OFFSET = IOPixelEnum::OFFSET;
116 static constexpr IOPixelEnum VECTOR = IOPixelEnum::VECTOR;
117 static constexpr IOPixelEnum POINT = IOPixelEnum::POINT;
118 static constexpr IOPixelEnum COVARIANTVECTOR = IOPixelEnum::COVARIANTVECTOR;
119 static constexpr IOPixelEnum SYMMETRICSECONDRANKTENSOR = IOPixelEnum::SYMMETRICSECONDRANKTENSOR;
120 static constexpr IOPixelEnum DIFFUSIONTENSOR3D = IOPixelEnum::DIFFUSIONTENSOR3D;
121 static constexpr IOPixelEnum COMPLEX = IOPixelEnum::COMPLEX;
122 static constexpr IOPixelEnum FIXEDARRAY = IOPixelEnum::FIXEDARRAY;
123 static constexpr IOPixelEnum MATRIX = IOPixelEnum::MATRIX;
127#if !defined(ITK_LEGACY_REMOVE)
130 static constexpr IOComponentEnum UNKNOWNCOMPONENTTYPE = IOComponentEnum::UNKNOWNCOMPONENTTYPE;
139 static constexpr IOComponentEnum ULONGLONG = IOComponentEnum::ULONGLONG;
146#if !defined(ITK_LEGACY_REMOVE)
148 static constexpr IOFileEnum ASCII = IOFileEnum::ASCII;
149 static constexpr IOFileEnum Binary = IOFileEnum::Binary;
150 static constexpr IOFileEnum TypeNotApplicable = IOFileEnum::TypeNotApplicable;
154#if !defined(ITK_LEGACY_REMOVE)
157 static constexpr IOByteOrderEnum BigEndian = IOByteOrderEnum::BigEndian;
158 static constexpr IOByteOrderEnum LittleEndian = IOByteOrderEnum::LittleEndian;
159 static constexpr IOByteOrderEnum OrderNotApplicable = IOByteOrderEnum::OrderNotApplicable;
168 itkGetConstMacro(NumberOfDimensions,
unsigned int);
213 virtual std::vector<double>
221 virtual std::vector<double>
253 virtual const std::type_info &
260 itkSetMacro(NumberOfComponents,
unsigned int);
261 itkGetConstReferenceMacro(NumberOfComponents,
unsigned int);
265 itkSetMacro(UseCompression,
bool);
266 itkGetConstMacro(UseCompression,
bool);
267 itkBooleanMacro(UseCompression);
277 itkGetConstMacro(CompressionLevel,
int);
291 itkGetConstReferenceMacro(Compressor, std::string);
294 itkSetMacro(UseStreamedReading,
bool);
295 itkGetConstMacro(UseStreamedReading,
bool);
296 itkBooleanMacro(UseStreamedReading);
300 itkSetMacro(UseStreamedWriting,
bool);
301 itkGetConstMacro(UseStreamedWriting,
bool);
302 itkBooleanMacro(UseStreamedWriting);
309 itkSetMacro(ExpandRGBPalette,
bool);
310 itkGetConstMacro(ExpandRGBPalette,
bool);
311 itkBooleanMacro(ExpandRGBPalette);
316 itkSetMacro(WritePalette,
bool);
317 itkGetConstMacro(WritePalette,
bool);
318 itkBooleanMacro(WritePalette);
325 itkGetConstMacro(IsReadAsScalarPlusPalette,
bool);
540 unsigned int numberOfActualSplits,
561 template <
typename TPixel>
566 template <
typename TPixel>
571 template <
typename TPixel>
579 template <
typename TPixel>
587 template <
typename TPixel>
595 template <
unsigned int VLength>
603 template <
typename TPixel,
unsigned int VLength>
611 template <
typename TCoordinate,
unsigned int VPo
intDimension>
619 template <
typename TPixel,
unsigned int VLength>
627 template <
typename TPixel,
unsigned int VLength>
632 this->
SetPixelType(IOPixelEnum::SYMMETRICSECONDRANKTENSOR);
635 template <
typename TPixel>
643 template <
typename TPixel>
651 template <
typename TPixel,
unsigned int VLength>
659 template <
typename TPixel>
667 template <
typename TValue>
675 template <
typename TPixel,
unsigned int VLength>
683 template <
typename TValue>
749 itkGetConstMacro(MaximumCompressionLevel,
int);
797 Reset(
const bool freeDynamic =
true);
801 Resize(
const unsigned int numDimensions,
const unsigned int * dimensions);
863 const std::string & filename,
864 bool truncate =
true,
903 unsigned int numberOfActualSplits,
915extern ITKIOImageBase_EXPORT
void
918 std::ofstream & file,
924extern ITKIOImageBase_EXPORT
void
930#define IMAGEIOBASE_TYPEMAP(type, ctype) \
932 struct ImageIOBase::MapPixelType<type> \
934 static constexpr IOComponentEnum CType = ctype; \
939IMAGEIOBASE_TYPEMAP(
char, std::numeric_limits<char>::is_signed ? IOComponentEnum::CHAR : IOComponentEnum::UCHAR);
951#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.