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"
47template <
typename TValue>
94 itkSetStringMacro(FileName);
95 itkGetStringMacro(FileName);
102#ifndef ITK_LEGACY_REMOVE
108 class [[deprecated(
"This class is intended to be removed from ITK 6.")]] UnknownType
112#if !defined(ITK_LEGACY_REMOVE)
115 static constexpr IOPixelEnum UNKNOWNPIXELTYPE = IOPixelEnum::UNKNOWNPIXELTYPE;
116 static constexpr IOPixelEnum SCALAR = IOPixelEnum::SCALAR;
117 static constexpr IOPixelEnum RGB = IOPixelEnum::RGB;
118 static constexpr IOPixelEnum RGBA = IOPixelEnum::RGBA;
119 static constexpr IOPixelEnum OFFSET = IOPixelEnum::OFFSET;
120 static constexpr IOPixelEnum VECTOR = IOPixelEnum::VECTOR;
121 static constexpr IOPixelEnum POINT = IOPixelEnum::POINT;
122 static constexpr IOPixelEnum COVARIANTVECTOR = IOPixelEnum::COVARIANTVECTOR;
123 static constexpr IOPixelEnum SYMMETRICSECONDRANKTENSOR = IOPixelEnum::SYMMETRICSECONDRANKTENSOR;
124 static constexpr IOPixelEnum DIFFUSIONTENSOR3D = IOPixelEnum::DIFFUSIONTENSOR3D;
125 static constexpr IOPixelEnum COMPLEX = IOPixelEnum::COMPLEX;
126 static constexpr IOPixelEnum FIXEDARRAY = IOPixelEnum::FIXEDARRAY;
127 static constexpr IOPixelEnum MATRIX = IOPixelEnum::MATRIX;
131#if !defined(ITK_LEGACY_REMOVE)
134 static constexpr IOComponentEnum UNKNOWNCOMPONENTTYPE = IOComponentEnum::UNKNOWNCOMPONENTTYPE;
143 static constexpr IOComponentEnum ULONGLONG = IOComponentEnum::ULONGLONG;
150#if !defined(ITK_LEGACY_REMOVE)
152 static constexpr IOFileEnum ASCII = IOFileEnum::ASCII;
153 static constexpr IOFileEnum Binary = IOFileEnum::Binary;
154 static constexpr IOFileEnum TypeNotApplicable = IOFileEnum::TypeNotApplicable;
158#if !defined(ITK_LEGACY_REMOVE)
161 static constexpr IOByteOrderEnum BigEndian = IOByteOrderEnum::BigEndian;
162 static constexpr IOByteOrderEnum LittleEndian = IOByteOrderEnum::LittleEndian;
163 static constexpr IOByteOrderEnum OrderNotApplicable = IOByteOrderEnum::OrderNotApplicable;
172 itkGetConstMacro(NumberOfDimensions,
unsigned int);
218 virtual std::vector<double>
226 virtual std::vector<double>
255#ifndef ITK_LEGACY_REMOVE
263 itkLegacyMacro(
virtual const std::type_info & GetComponentTypeInfo()
const);
271 itkSetMacro(NumberOfComponents,
unsigned int);
272 itkGetConstReferenceMacro(NumberOfComponents,
unsigned int);
277 itkSetMacro(UseCompression,
bool);
278 itkGetConstMacro(UseCompression,
bool);
279 itkBooleanMacro(UseCompression);
289 itkGetConstMacro(CompressionLevel,
int);
303 itkGetConstReferenceMacro(Compressor, std::string);
307 itkSetMacro(UseStreamedReading,
bool);
308 itkGetConstMacro(UseStreamedReading,
bool);
309 itkBooleanMacro(UseStreamedReading);
314 itkSetMacro(UseStreamedWriting,
bool);
315 itkGetConstMacro(UseStreamedWriting,
bool);
316 itkBooleanMacro(UseStreamedWriting);
324 itkSetMacro(ExpandRGBPalette,
bool);
325 itkGetConstMacro(ExpandRGBPalette,
bool);
326 itkBooleanMacro(ExpandRGBPalette);
332 itkSetMacro(WritePalette,
bool);
333 itkGetConstMacro(WritePalette,
bool);
334 itkBooleanMacro(WritePalette);
341 itkGetConstMacro(IsReadAsScalarPlusPalette,
bool);
348 static constexpr bool
355 static constexpr bool
362 static constexpr size_t
373 for (
const auto componentEnum : { IOComponentEnum::UINT8,
374 IOComponentEnum::INT8,
375 IOComponentEnum::UINT16,
376 IOComponentEnum::INT16,
377 IOComponentEnum::UINT32,
378 IOComponentEnum::INT32,
379 IOComponentEnum::UINT64,
380 IOComponentEnum::INT64,
381 IOComponentEnum::FLOAT32,
382 IOComponentEnum::FLOAT64 })
385 typeTraits.isFloatingPoint == isFloatingPoint && typeTraits.isUnsigned == isUnsigned &&
386 typeTraits.sizeOfComponent *
size_t{ CHAR_BIT } == numberOfBits)
388 return componentEnum;
391 return IOComponentEnum::UNKNOWNCOMPONENTTYPE;
605 unsigned int numberOfActualSplits,
626#ifndef ITK_LEGACY_REMOVE
628 template <
typename TPixel>
629 itkLegacyMacro(
void SetTypeInfo(
const TPixel *));
634 template <
typename TComponent>
638 std::is_same_v<TComponent, char> ? (std::is_signed_v<char> ? IOComponentEnum::CHAR : IOComponentEnum::UCHAR)
654 template <
typename TPixel>
662 template <
typename TComponent>
670 template <
typename TComponent>
678 template <
unsigned int VLength>
686 template <
typename TComponent,
unsigned int VLength>
694 template <
typename TCoordinate,
unsigned int VPo
intDimension>
702 template <
typename TComponent,
unsigned int VLength>
710 template <
typename TComponent,
unsigned int VLength>
715 this->
SetPixelType(IOPixelEnum::SYMMETRICSECONDRANKTENSOR);
718 template <
typename TComponent>
726 template <
typename TComponent>
734 template <
typename TComponent,
unsigned int VLength>
742 template <
typename TComponent>
750 template <
typename TValue>
758 template <
typename TComponent,
unsigned int VLength>
766 template <
typename TValue>
833 itkGetConstMacro(MaximumCompressionLevel,
int);
881 Reset(
const bool freeDynamic =
true);
885 Resize(
const unsigned int numDimensions,
const unsigned int * dimensions);
947 const std::string & filename,
948 bool truncate =
true,
987 unsigned int numberOfActualSplits,
997 template <
typename... TComponent>
1003 ? result = { std::is_floating_point_v<TComponent>, std::is_unsigned_v<TComponent>,
sizeof(TComponent) }
1010 static constexpr ComponentTypeTraits
1024 double>(componentEnum);
1035extern ITKIOImageBase_EXPORT
void
1037 const void * buffer,
1038 std::ofstream & file,
1044extern ITKIOImageBase_EXPORT
void
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)
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
SmartPointer< const Self > ConstPointer
void SetByteOrderToBigEndian()
virtual void SetOrigin(unsigned int i, double origin)
std::vector< SizeValueType > m_Dimensions
void SetPixelTypeInfo(const RGBAPixel< TComponent > *)
void SetPixelTypeInfo(const CovariantVector< TComponent, 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 SymmetricSecondRankTensor< TComponent, 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
SizeType GetImageSizeInComponents() const
static constexpr IOComponentEnum GetComponentTypeFromTypeTraits(const bool isFloatingPoint, const bool isUnsigned, const vcl_size_t numberOfBits)
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
void SetPixelTypeInfo(const FixedArray< TComponent, VLength > *)
virtual const ImageRegionSplitterBase * GetImageRegionSplitter() const
SizeType GetImageSizeInBytes() const
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 Offset< VLength > *)
void SetPixelTypeInfo(const Array< TValue > *)
void SetPixelTypeInfo(const Vector< TComponent, VLength > *)
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
itk::IOByteOrderEnum IOByteOrderEnum
void SetPixelTypeInfo(const Matrix< TComponent, VLength, VLength > *)
void SetByteOrderToLittleEndian()
void SetSupportedWriteExtensions(const ArrayOfExtensionsType &)
virtual SizeValueType GetDimensions(unsigned int i) const
static constexpr bool IsComponentTypeUnsigned(const IOComponentEnum componentEnum)
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
static constexpr vcl_size_t GetNumberOfBitsOfComponentType(const IOComponentEnum componentEnum)
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 RGBPixel< TComponent > *)
void SetPixelTypeInfo(const VariableLengthVector< TComponent > *)
void SetPixelTypeInfo(const TPixel *)
static constexpr ComponentTypeTraits GetComponentTypeTraits(const IOComponentEnum componentEnum)
virtual void SetPixelType(const itk::CommonEnums::IOPixel _arg)
void SetNumberOfDimensions(unsigned int)
void SetPixelTypeInfo(const std::complex< TComponent > *)
itk::SizeValueType SizeValueType
void SetFileTypeToASCII()
virtual bool CanStreamRead()
void SetPixelTypeInfo(const DiffusionTensor3D< TComponent > *)
void AddSupportedWriteExtension(const char *extension)
virtual void ReadImageInformation()=0
static constexpr bool IsComponentTypeFloatingPoint(const IOComponentEnum componentEnum)
std::vector< std::string > ArrayOfExtensionsType
virtual std::vector< double > GetDefaultDirection(unsigned int k) const
virtual void Read(void *buffer)=0
int m_MaximumCompressionLevel
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.
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)
unsigned int sizeOfComponent
static constexpr ComponentTypeTraits Get(const IOComponentEnum componentEnum)
static constexpr IOComponentEnum CType
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.