18 #ifndef itkImageIOBase_h 19 #define itkImageIOBase_h 20 #include "ITKIOImageBaseExport.h" 22 #include "itkIOConfigure.h" 34 #include "vnl/vnl_vector.h" 35 #include "vcl_compiler.h" 43 template <
typename TValue>
class VariableLengthVector;
85 itkSetStringMacro(FileName);
86 itkGetStringMacro(FileName);
103 typedef enum { UNKNOWNPIXELTYPE, SCALAR, RGB, RGBA, OFFSET,
VECTOR,
111 typedef enum { UNKNOWNCOMPONENTTYPE, UCHAR, CHAR,
USHORT, SHORT, UINT, INT,
117 void SetNumberOfDimensions(
unsigned int);
119 itkGetConstMacro(NumberOfDimensions,
unsigned int);
124 virtual void SetDimensions(
unsigned int i, SizeValueType dim);
128 {
return m_Dimensions[i]; }
132 virtual void SetOrigin(
unsigned int i,
double origin);
141 virtual void SetSpacing(
unsigned int i,
double spacing);
150 virtual void SetDirection(
unsigned int i,
const std::vector< double > & direction);
152 virtual void SetDirection(
unsigned int i,
const vnl_vector< double > & direction);
156 return m_Direction[i];
161 virtual std::vector< double > GetDefaultDirection(
unsigned int i)
const;
178 itkSetEnumMacro(PixelType, IOPixelType);
179 itkGetEnumMacro(PixelType, IOPixelType);
184 itkSetEnumMacro(ComponentType, IOComponentType);
185 itkGetEnumMacro(ComponentType, IOComponentType);
192 virtual const std::type_info & GetComponentTypeInfo()
const;
198 itkSetMacro(NumberOfComponents,
unsigned int);
199 itkGetConstReferenceMacro(NumberOfComponents,
unsigned int);
203 itkSetMacro(UseCompression,
bool);
204 itkGetConstMacro(UseCompression,
bool);
205 itkBooleanMacro(UseCompression);
209 itkSetMacro(UseStreamedReading,
bool);
210 itkGetConstMacro(UseStreamedReading,
bool);
211 itkBooleanMacro(UseStreamedReading);
215 itkSetMacro(UseStreamedWriting,
bool);
216 itkGetConstMacro(UseStreamedWriting,
bool);
217 itkBooleanMacro(UseStreamedWriting);
222 static std::string GetComponentTypeAsString(IOComponentType);
225 static IOComponentType GetComponentTypeFromString(
const std::string &typeString);
229 static std::string GetPixelTypeAsString(IOPixelType);
232 static IOPixelType GetPixelTypeFromString(
const std::string &pixelString);
236 typedef enum { ASCII, Binary, TypeNotApplicable }
FileType;
240 typedef enum { BigEndian, LittleEndian, OrderNotApplicable }
ByteOrder;
244 itkSetEnumMacro(FileType, FileType);
245 itkGetEnumMacro(FileType, FileType);
248 this->SetFileType(ASCII);
254 this->SetFileType(Binary);
268 itkSetEnumMacro(ByteOrder, ByteOrder);
269 itkGetEnumMacro(ByteOrder, ByteOrder);
272 this->SetByteOrder(BigEndian);
278 this->SetByteOrder(LittleEndian);
283 std::string GetFileTypeAsString(FileType)
const;
287 std::string GetByteOrderAsString(ByteOrder)
const;
302 virtual SizeType GetPixelStride()
const;
305 SizeType GetImageSizeInPixels()
const;
308 SizeType GetImageSizeInBytes()
const;
312 SizeType GetImageSizeInComponents()
const;
318 virtual unsigned int GetComponentSize()
const;
324 virtual bool CanReadFile(
const char *) = 0;
337 virtual void ReadImageInformation() = 0;
340 virtual void Read(
void *buffer) = 0;
346 virtual bool CanWriteFile(
const char *) = 0;
361 virtual void WriteImageInformation() = 0;
366 virtual void Write(
const void *buffer) = 0;
392 GenerateStreamableReadRegionFromRequestedRegion(
const ImageIORegion & requested)
const;
408 virtual unsigned int GetActualNumberOfSplitsForWriting(
unsigned int numberOfRequestedSplits,
418 virtual ImageIORegion GetSplitRegionForWriting(
unsigned int ithPiece,
419 unsigned int numberOfActualSplits,
430 const ArrayOfExtensionsType & GetSupportedReadExtensions()
const;
436 const ArrayOfExtensionsType & GetSupportedWriteExtensions()
const;
438 template <
typename TPixel>
439 void SetTypeInfo(
const TPixel *);
442 template <
typename TPixel>
445 static ITK_CONSTEXPR IOComponentType CType =
446 UNKNOWNCOMPONENTTYPE;
448 template <
typename TPixel>
451 this->SetNumberOfComponents(1);
452 this->SetPixelType(SCALAR);
455 template <
typename TPixel>
458 this->SetNumberOfComponents(3);
459 this->SetPixelType(RGB);
462 template <
typename TPixel>
465 this->SetNumberOfComponents(4);
466 this->SetPixelType(RGBA);
469 template <
typename TPixel,
unsigned VLength>
472 this->SetNumberOfComponents(VLength);
473 this->SetPixelType(VECTOR);
476 template <
typename TPixel>
479 this->SetNumberOfComponents(1);
480 this->SetPixelType(VECTOR);
483 template <
typename TPixel,
unsigned VLength>
486 this->SetNumberOfComponents(VLength);
487 this->SetPixelType(COVARIANTVECTOR);
490 template <
typename TPixel,
unsigned VLength>
493 this->SetNumberOfComponents(VLength);
494 this->SetPixelType(COVARIANTVECTOR);
499 template <
typename TPixel,
unsigned VLength>
502 this->SetNumberOfComponents(VLength * (VLength + 1) / 2 );
503 this->SetPixelType(SYMMETRICSECONDRANKTENSOR);
507 template <
typename TPixel>
510 this->SetNumberOfComponents(6);
511 this->SetPixelType(DIFFUSIONTENSOR3D);
515 template <
typename TPixel,
unsigned VLength>
518 this->SetNumberOfComponents(VLength * VLength);
519 this->SetPixelType(MATRIX);
523 template <
typename TPixel>
526 this->SetNumberOfComponents(2);
527 this->SetPixelType(COMPLEX);
531 template <
unsigned VLength>
534 this->SetNumberOfComponents(VLength);
542 virtual void PrintSelf(std::ostream & os,
Indent indent)
const ITK_OVERRIDE;
602 virtual void Reset(
const bool freeDynamic =
true);
605 void Resize(
const unsigned int numDimensions,
606 const unsigned int *dimensions);
610 virtual unsigned int GetPixelSize()
const;
618 void ComputeStrides();
622 SizeType GetComponentStride()
const;
626 SizeType GetRowStride()
const;
630 SizeType GetSliceStride()
const;
643 virtual void OpenFileForReading(std::ifstream & inputStream,
const std::string & filename,
661 virtual void OpenFileForWriting(std::ofstream & outputStream,
const std::string & filename,
662 bool truncate =
true,
bool ascii =
false);
665 virtual void WriteBufferAsASCII(std::ostream & os,
const void *buffer,
666 IOComponentType ctype,
667 SizeType numberOfBytesToWrite);
670 virtual void ReadBufferAsASCII(std::istream & os,
void *buffer,
671 IOComponentType ctype,
672 SizeType numberOfBytesToBeRead);
675 bool ReadBufferAsBinary(std::istream & os,
void *buffer, SizeType numberOfBytesToBeRead);
678 void AddSupportedReadExtension(
const char *extension);
681 void AddSupportedWriteExtension(
const char *extension);
685 virtual unsigned int GetActualNumberOfSplitsForWritingCanStreamWrite(
unsigned int numberOfRequestedSplits,
690 virtual ImageIORegion GetSplitRegionForWritingCanStreamWrite(
unsigned int ithPiece,
691 unsigned int numberOfActualSplits,
696 void operator=(const Self &) ITK_DELETE_FUNCTION;
698 ArrayOfExtensionsType m_SupportedReadExtensions;
699 ArrayOfExtensionsType m_SupportedWriteExtensions;
702 #define IMAGEIOBASE_TYPEMAP(type,ctype) \ 703 template <> struct ImageIOBase::MapPixelType<type> \ 705 static ITK_CONSTEXPR IOComponentType CType = ctype; \ 709 #if VCL_CHAR_IS_SIGNED 711 #endif // VCL_CHAR_IS_SIGNED 722 #undef IMAGIOBASE_TYPEMAP 727 #endif // itkImageIOBase_h void SetPixelTypeInfo(const Offset< VLength > *)
A templated class holding a M x N size Matrix.
unsigned int m_NumberOfComponents
Represent the offset between two n-dimensional indexes in a n-dimensional image.
virtual bool SupportsDimension(unsigned long dim)
void SetPixelTypeInfo(const DiffusionTensor3D< TPixel > *)
An ImageIORegion represents a structured region of data.
virtual SizeValueType GetDimensions(unsigned int i) const
void SetByteOrderToLittleEndian()
Abstract superclass defines image IO interface.
signed long OffsetValueType
Represent Red, Green, Blue and Alpha components for color images.
Represent a symmetric tensor of second rank.
signed long IndexValueType
void SetPixelTypeInfo(const Matrix< TPixel, VLength, VLength > *)
std::vector< double > m_Origin
void SetPixelTypeInfo(const VariableLengthVector< TPixel > *)
std::vector< double > m_Spacing
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes...
LightProcessObject Superclass
virtual double GetSpacing(unsigned int i) const
std::vector< std::string > ArrayOfExtensionsType
unsigned long SizeValueType
virtual std::vector< double > GetDirection(unsigned int i) const
void SetFileTypeToBinary()
unsigned int m_NumberOfDimensions
Simulate a standard C array with copy semnatics.
bool m_UseStreamedWriting
bool m_UseStreamedReading
void SetPixelTypeInfo(const Vector< TPixel, VLength > *)
void SetPixelTypeInfo(const TPixel *)
virtual double GetOrigin(unsigned int i) const
Represents an array whose length can be defined at run-time.
A templated class holding a n-Dimensional vector.
std::vector< std::vector< double > > m_Direction
Divide an image region into several pieces.
void SetPixelTypeInfo(const SymmetricSecondRankTensor< TPixel, VLength > *)
void SetPixelTypeInfo(const std::complex< TPixel > *)
virtual bool CanStreamRead()
::itk::SizeValueType SizeValueType
IOComponentType m_ComponentType
void SetPixelTypeInfo(const CovariantVector< TPixel, VLength > *)
::itk::OffsetValueType BufferSizeType
void SetPixelTypeInfo(const RGBPixel< TPixel > *)
::itk::IndexValueType IndexValueType
std::vector< SizeType > m_Strides
LightProcessObject is the base class for all process objects (source, filters, mappers) in the Insigh...
Control indentation during Print() invocation.
void SetFileTypeToASCII()
IMAGEIOBASE_TYPEMAP(char, CHAR)
SmartPointer< Self > Pointer
void SetByteOrderToBigEndian()
Represent a diffusion tensor as used in DTI images.
A templated class holding a n-Dimensional covariant vector.
void SetPixelTypeInfo(const RGBAPixel< TPixel > *)
std::vector< SizeValueType > m_Dimensions
void SetPixelTypeInfo(const FixedArray< TPixel, VLength > *)
virtual bool CanStreamWrite()