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>
47class VariableLengthVector;
92 itkSetStringMacro(FileName);
93 itkGetStringMacro(FileName);
108#if !defined(ITK_LEGACY_REMOVE)
127#if !defined(ITK_LEGACY_REMOVE)
146#if !defined(ITK_LEGACY_REMOVE)
154#if !defined(ITK_LEGACY_REMOVE)
168 itkGetConstMacro(NumberOfDimensions,
unsigned int);
180 return m_Dimensions[i];
213 virtual std::vector<double>
216 return m_Direction[i];
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);
276 itkSetClampMacro(CompressionLevel,
int, 1, this->GetMaximumCompressionLevel());
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>
575 this->SetNumberOfComponents(1);
579 template <
typename TPixel>
583 this->SetNumberOfComponents(3);
587 template <
typename TPixel>
591 this->SetNumberOfComponents(4);
595 template <
unsigned int VLength>
599 this->SetNumberOfComponents(VLength);
603 template <
typename TPixel,
unsigned int VLength>
607 this->SetNumberOfComponents(VLength);
611 template <
typename TCoordRep,
unsigned int VPo
intDimension>
615 this->SetNumberOfComponents(VPointDimension);
619 template <
typename TPixel,
unsigned int VLength>
623 this->SetNumberOfComponents(VLength);
627 template <
typename TPixel,
unsigned int VLength>
631 this->SetNumberOfComponents(VLength * (VLength + 1) / 2);
635 template <
typename TPixel>
639 this->SetNumberOfComponents(6);
643 template <
typename TPixel>
647 this->SetNumberOfComponents(2);
651 template <
typename TPixel,
unsigned int VLength>
655 this->SetNumberOfComponents(VLength);
659 template <
typename TPixel>
663 this->SetNumberOfComponents(1);
667 template <
typename TValue>
671 this->SetNumberOfComponents(1);
675 template <
typename TPixel,
unsigned int VLength>
679 this->SetNumberOfComponents(VLength * VLength);
683 template <
typename TValue>
687 this->SetNumberOfComponents(1);
726 bool m_Initialized{};
729 std::string m_FileName{};
733 unsigned int m_NumberOfComponents{};
736 unsigned int m_NumberOfDimensions{ 0 };
739 bool m_UseCompression{
false };
742 int m_CompressionLevel{ 30 };
743 int m_MaximumCompressionLevel{ 100 };
744 std::string m_Compressor{
"uninitialized" };
749 itkGetConstMacro(MaximumCompressionLevel,
int);
759 bool m_UseStreamedReading{};
762 bool m_UseStreamedWriting{};
765 bool m_ExpandRGBPalette{};
769 bool m_IsReadAsScalarPlusPalette{};
772 bool m_WritePalette{};
779 std::vector<SizeValueType> m_Dimensions{};
783 std::vector<double> m_Spacing{};
786 std::vector<double> m_Origin{};
789 std::vector<std::vector<double>> m_Direction{};
793 std::vector<SizeType> m_Strides{};
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; \
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.
Abstract superclass defines image IO interface.
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 > *)
virtual void InternalSetCompressor(const std::string &_compressor)
bool ReadBufferAsBinary(std::istream &is, void *buffer, SizeType num)
virtual void Reset(const bool freeDynamic=true)
void AddSupportedReadExtension(const char *extension)
virtual double GetSpacing(unsigned int i) const
void SetPixelTypeInfo(const DiffusionTensor3D< TPixel > *)
void SetByteOrderToBigEndian()
virtual void SetOrigin(unsigned int i, double origin)
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
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
virtual unsigned int GetPixelSize() const
SizeType GetRowStride() const
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
std::string GetByteOrderAsString(IOByteOrderEnum) const
virtual const ImageRegionSplitterBase * GetImageRegionSplitter() const
SizeType GetImageSizeInBytes() const
void SetTypeInfo(const TPixel *)
void SetPixelTypeInfo(const Point< TCoordRep, VPointDimension > *)
virtual bool SupportsDimension(unsigned long dim)
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)
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 bool CanWriteFile(const char *)=0
virtual void Write(const void *buffer)=0
virtual void SetDirection(unsigned int i, const vnl_vector< double > &direction)
virtual ImageIORegion GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion &requested) const
void SetPixelTypeInfo(const RGBPixel< TPixel > *)
void SetPixelTypeInfo(const std::complex< TPixel > *)
void SetByteOrderToLittleEndian()
void SetSupportedWriteExtensions(const ArrayOfExtensionsType &)
virtual SizeValueType GetDimensions(unsigned int i) const
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 std::string GetComponentTypeAsString(IOComponentEnum)
static std::string GetPixelTypeAsString(IOPixelEnum)
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 *)
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
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.
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
An ImageIORegion represents a structured region of data.
Divide an image region into several pieces.
Control indentation during Print() invocation.
Light weight base class for most itk classes.
LightProcessObject is the base class for all process objects (source, filters, mappers) in the Insigh...
A templated class holding a M x N size Matrix.
Base class for most ITK classes.
Represent Red, Green, Blue and Alpha components for color images.
Represent Red, Green and Blue components for color images.
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.
@ SYMMETRICSECONDRANKTENSOR
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
IMAGEIOBASE_TYPEMAP(signed char, IOComponentEnum::CHAR)
CommonEnums::IOComponent IOComponentEnum
CommonEnums::IOByteOrder IOByteOrderEnum
ITKIOImageBase_EXPORT void WriteRawBytesAfterSwapping(IOComponentEnum componentType, const void *buffer, std::ofstream &file, IOByteOrderEnum byteOrder, SizeValueType numberOfBytes, SizeValueType numberOfComponents)
CommonEnums::IOPixel IOPixelEnum
CommonEnums::IOFile IOFileEnum
unsigned long SizeValueType
ITKIOImageBase_EXPORT void ReadRawBytesAfterSwapping(IOComponentEnum componentType, void *buffer, IOByteOrderEnum byteOrder, SizeValueType numberOfComponents)
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.