18 #ifndef __itkImageIOBase_h
19 #define __itkImageIOBase_h
20 #include "ITKIOImageBaseExport.h"
22 #include "itkIOConfigure.h"
35 #include "vnl/vnl_vector.h"
81 itkSetStringMacro(FileName);
82 itkGetStringMacro(FileName);
99 typedef enum { UNKNOWNPIXELTYPE, SCALAR, RGB, RGBA, OFFSET,
VECTOR,
101 DIFFUSIONTENSOR3D, COMPLEX, FIXEDARRAY, MATRIX } IOPixelType;
107 typedef enum { UNKNOWNCOMPONENTTYPE, UCHAR, CHAR,
USHORT, SHORT, UINT, INT,
108 ULONG, LONG, FLOAT, DOUBLE } IOComponentType;
113 void SetNumberOfDimensions(
unsigned int);
115 itkGetConstMacro(NumberOfDimensions,
unsigned int);
120 virtual void SetDimensions(
unsigned int i,
unsigned int dim);
124 {
return m_Dimensions[i]; }
128 virtual void SetOrigin(
unsigned int i,
double origin);
137 virtual void SetSpacing(
unsigned int i,
double spacing);
146 virtual void SetDirection(
unsigned int i,
const std::vector< double > & direction);
148 virtual void SetDirection(
unsigned int i,
const vnl_vector< double > & direction);
152 return m_Direction[i];
157 virtual std::vector< double > GetDefaultDirection(
unsigned int i)
const;
174 itkSetEnumMacro(PixelType, IOPixelType);
175 itkGetEnumMacro(PixelType, IOPixelType);
180 itkSetEnumMacro(ComponentType, IOComponentType);
181 itkGetEnumMacro(ComponentType, IOComponentType);
188 virtual const std::type_info & GetComponentTypeInfo()
const;
194 itkSetMacro(NumberOfComponents,
unsigned int);
195 itkGetConstReferenceMacro(NumberOfComponents,
unsigned int);
199 itkSetMacro(UseCompression,
bool);
200 itkGetConstMacro(UseCompression,
bool);
201 itkBooleanMacro(UseCompression);
205 itkSetMacro(UseStreamedReading,
bool);
206 itkGetConstMacro(UseStreamedReading,
bool);
207 itkBooleanMacro(UseStreamedReading);
211 itkSetMacro(UseStreamedWriting,
bool);
212 itkGetConstMacro(UseStreamedWriting,
bool);
213 itkBooleanMacro(UseStreamedWriting);
218 static std::string GetComponentTypeAsString(IOComponentType);
221 static IOComponentType GetComponentTypeFromString(
const std::string &typeString);
225 static std::string GetPixelTypeAsString(IOPixelType);
228 static IOPixelType GetPixelTypeFromString(
const std::string &pixelString);
232 typedef enum { ASCII, Binary, TypeNotApplicable } FileType;
236 typedef enum { BigEndian, LittleEndian, OrderNotApplicable } ByteOrder;
240 itkSetEnumMacro(FileType, FileType);
241 itkGetEnumMacro(FileType, FileType);
244 this->SetFileType(ASCII);
250 this->SetFileType(Binary);
264 itkSetEnumMacro(ByteOrder, ByteOrder);
265 itkGetEnumMacro(ByteOrder, ByteOrder);
268 this->SetByteOrder(BigEndian);
274 this->SetByteOrder(LittleEndian);
279 std::string GetFileTypeAsString(FileType)
const;
283 std::string GetByteOrderAsString(ByteOrder)
const;
298 virtual SizeType GetPixelStride()
const;
301 SizeType GetImageSizeInPixels()
const;
304 SizeType GetImageSizeInBytes()
const;
308 SizeType GetImageSizeInComponents()
const;
314 virtual unsigned int GetComponentSize()
const;
320 virtual bool CanReadFile(
const char *) = 0;
333 virtual void ReadImageInformation() = 0;
336 virtual void Read(
void *buffer) = 0;
342 virtual bool CanWriteFile(
const char *) = 0;
357 virtual void WriteImageInformation() = 0;
362 virtual void Write(
const void *buffer) = 0;
388 GenerateStreamableReadRegionFromRequestedRegion(
const ImageIORegion & requested)
const;
404 virtual unsigned int GetActualNumberOfSplitsForWriting(
unsigned int numberOfRequestedSplits,
414 virtual ImageIORegion GetSplitRegionForWriting(
unsigned int ithPiece,
415 unsigned int numberOfActualSplits,
434 template <
typename TPixel>
435 void SetTypeInfo(
const TPixel *);
438 template <
typename TPixel>
442 UNKNOWNCOMPONENTTYPE;
444 template <
typename TPixel>
447 this->SetNumberOfComponents(1);
448 this->SetPixelType(SCALAR);
451 template <
typename TPixel>
454 this->SetNumberOfComponents(3);
455 this->SetPixelType(RGB);
458 template <
typename TPixel>
461 this->SetNumberOfComponents(4);
462 this->SetPixelType(RGBA);
465 template <
typename TPixel,
unsigned VLength>
468 this->SetNumberOfComponents(VLength);
469 this->SetPixelType(VECTOR);
472 template <
typename TPixel>
475 this->SetNumberOfComponents(1);
476 this->SetPixelType(VECTOR);
479 template <
typename TPixel,
unsigned VLength>
482 this->SetNumberOfComponents(VLength);
483 this->SetPixelType(COVARIANTVECTOR);
486 template <
typename TPixel,
unsigned VLength>
489 this->SetNumberOfComponents(VLength);
490 this->SetPixelType(COVARIANTVECTOR);
495 template <
typename TPixel,
unsigned VLength>
498 this->SetNumberOfComponents(VLength * (VLength + 1) / 2 );
499 this->SetPixelType(SYMMETRICSECONDRANKTENSOR);
503 template <
typename TPixel>
506 this->SetNumberOfComponents(6);
507 this->SetPixelType(DIFFUSIONTENSOR3D);
511 template <
typename TPixel,
unsigned VLength>
514 this->SetNumberOfComponents(VLength * VLength);
515 this->SetPixelType(MATRIX);
519 template <
typename TPixel>
522 this->SetNumberOfComponents(2);
523 this->SetPixelType(COMPLEX);
527 template <
unsigned VLength>
530 this->SetNumberOfComponents(VLength);
538 void PrintSelf(std::ostream & os,
Indent indent)
const;
598 virtual void Reset(
const bool freeDynamic =
true);
601 void Resize(
const unsigned int numDimensions,
602 const unsigned int *dimensions);
606 virtual unsigned int GetPixelSize()
const;
614 void ComputeStrides();
618 SizeType GetComponentStride()
const;
629 virtual void WriteBufferAsASCII(std::ostream & os,
const void *buffer,
634 virtual void ReadBufferAsASCII(std::istream & os,
void *buffer,
639 bool ReadBufferAsBinary(std::istream & os,
void *buffer,
SizeType numberOfBytesToBeRead);
642 void AddSupportedReadExtension(
const char *extension);
645 void AddSupportedWriteExtension(
const char *extension);
649 virtual unsigned int GetActualNumberOfSplitsForWritingCanStreamWrite(
unsigned int numberOfRequestedSplits,
654 virtual ImageIORegion GetSplitRegionForWritingCanStreamWrite(
unsigned int ithPiece,
655 unsigned int numberOfActualSplits,
660 void operator=(
const Self &);
666 #define IMAGEIOBASE_TYPEMAP(type,ctype) \
667 template <> struct ImageIOBase::MapPixelType<type> \
669 static const IOComponentType CType = ctype; \
682 #undef IMAGIOBASE_TYPEMAP
687 #endif // __itkImageIOBase_h
void SetPixelTypeInfo(const Offset< VLength > *)
A templated class holding a M x N size Matrix.
unsigned int m_NumberOfComponents
Light weight base class for most itk classes.
virtual itk::SizeValueType GetDimensions(unsigned int i) const
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.
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
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
ArrayOfExtensionsType m_SupportedReadExtensions
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
ArrayOfExtensionsType m_SupportedWriteExtensions
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()
Base class for most ITK classes.
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()