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"
46 template <
typename TValue>
47 class 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)
166 SetNumberOfDimensions(
unsigned int);
168 itkGetConstMacro(NumberOfDimensions,
unsigned int);
180 return m_Dimensions[i];
186 SetOrigin(
unsigned int i,
double origin);
197 SetSpacing(
unsigned int i,
double spacing);
208 SetDirection(
unsigned int i,
const std::vector<double> & direction);
211 SetDirection(
unsigned int i,
const vnl_vector<double> & direction);
213 virtual std::vector<double>
216 return m_Direction[i];
221 virtual std::vector<double>
222 GetDefaultDirection(
unsigned int k)
const;
253 virtual const std::type_info &
254 GetComponentTypeInfo()
const;
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);
290 SetCompressor(std::string _c);
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);
333 GetComponentTypeFromString(
const std::string & typeString);
337 static std::string GetPixelTypeAsString(
IOPixelEnum);
341 GetPixelTypeFromString(
const std::string & pixelString);
388 std::string GetFileTypeAsString(
IOFileEnum)
const;
408 GetPixelStride()
const;
412 GetImageSizeInPixels()
const;
416 GetImageSizeInBytes()
const;
421 GetImageSizeInComponents()
const;
428 GetComponentSize()
const;
435 CanReadFile(
const char *) = 0;
450 ReadImageInformation() = 0;
454 Read(
void * buffer) = 0;
461 CanWriteFile(
const char *) = 0;
478 WriteImageInformation() = 0;
484 Write(
const void * buffer) = 0;
511 GenerateStreamableReadRegionFromRequestedRegion(
const ImageIORegion & requested)
const;
528 GetActualNumberOfSplitsForWriting(
unsigned int numberOfRequestedSplits,
539 GetSplitRegionForWriting(
unsigned int ithPiece,
540 unsigned int numberOfActualSplits,
552 GetSupportedReadExtensions()
const;
559 GetSupportedWriteExtensions()
const;
561 template <
typename TPixel>
563 SetTypeInfo(
const 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 TCoordinate,
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);
698 PrintSelf(std::ostream & os,
Indent indent)
const override;
701 GetImageRegionSplitter()
const;
708 HasSupportedReadExtension(
const char * fileName,
bool ignoreCase =
true);
710 HasSupportedWriteExtension(
const char * fileName,
bool ignoreCase =
true);
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" };
748 SetMaximumCompressionLevel(
int);
749 itkGetConstMacro(MaximumCompressionLevel,
int);
756 InternalSetCompressor(
const std::string & _compressor);
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);
806 GetPixelSize()
const;
820 GetComponentStride()
const;
825 GetRowStride()
const;
830 GetSliceStride()
const;
844 OpenFileForReading(std::ifstream & inputStream,
const std::string & filename,
bool ascii =
false);
862 OpenFileForWriting(std::ofstream & outputStream,
863 const std::string & filename,
864 bool truncate =
true,
877 ReadBufferAsBinary(std::istream & is,
void * buffer,
SizeType num);
881 AddSupportedReadExtension(
const char * extension);
885 AddSupportedWriteExtension(
const char * extension);
889 SetSupportedReadExtensions(
const ArrayOfExtensionsType &);
891 SetSupportedWriteExtensions(
const ArrayOfExtensionsType &);
896 GetActualNumberOfSplitsForWritingCanStreamWrite(
unsigned int numberOfRequestedSplits,
902 GetSplitRegionForWritingCanStreamWrite(
unsigned int ithPiece,
903 unsigned int numberOfActualSplits,
908 HasSupportedExtension(
const char *,
const ArrayOfExtensionsType &,
bool ignoreCase =
true);
915 extern ITKIOImageBase_EXPORT
void
918 std::ofstream & file,
924 extern ITKIOImageBase_EXPORT
void
930 #define IMAGEIOBASE_TYPEMAP(type, ctype) \
932 struct ImageIOBase::MapPixelType<type> \
934 static constexpr IOComponentEnum CType = ctype; \
951 #undef IMAGIOBASE_TYPEMAP
955 #endif // itkImageIOBase_h