ITK  4.2.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions
itk::StreamingImageIOBase Class Reference

#include <itkStreamingImageIOBase.h>

+ Inheritance diagram for itk::StreamingImageIOBase:
+ Collaboration diagram for itk::StreamingImageIOBase:

List of all members.

Public Types

typedef SmartPointer< SelfPointer
typedef StreamingImageIOBase Self
typedef ImageIOBase Superclass
- Public Types inherited from itk::ImageIOBase
typedef std::vector< std::string > ArrayOfExtensionsType
typedef ::itk::OffsetValueType BufferSizeType
enum  ByteOrder {
  BigEndian,
  LittleEndian,
  OrderNotApplicable
}
enum  FileType {
  ASCII,
  Binary,
  TypeNotApplicable
}
typedef ::itk::IndexValueType IndexValueType
enum  IOComponentType {
  UNKNOWNCOMPONENTTYPE,
  UCHAR,
  CHAR,
  USHORT,
  SHORT,
  UINT,
  INT,
  ULONG,
  LONG,
  FLOAT,
  DOUBLE
}
enum  IOPixelType {
  UNKNOWNPIXELTYPE,
  SCALAR,
  RGB,
  RGBA,
  OFFSET,
  VECTOR,
  POINT,
  COVARIANTVECTOR,
  SYMMETRICSECONDRANKTENSOR,
  DIFFUSIONTENSOR3D,
  COMPLEX,
  FIXEDARRAY,
  MATRIX
}
typedef ::itk::intmax_t SizeType
typedef ::itk::SizeValueType SizeValueType
- Public Types inherited from itk::LightProcessObject
typedef SmartPointer< const SelfConstPointer
- Public Types inherited from itk::Object
- Public Types inherited from itk::LightObject

Public Member Functions

virtual bool CanStreamRead (void)
virtual bool CanStreamWrite (void)
virtual ImageIORegion GenerateStreamableReadRegionFromRequestedRegion (const ImageIORegion &requested) const
virtual unsigned int GetActualNumberOfSplitsForWriting (unsigned int numberOfRequestedSplits, const ImageIORegion &pasteRegion, const ImageIORegion &largestPossibleRegion)
virtual const char * GetNameOfClass () const
- Public Member Functions inherited from itk::ImageIOBase
virtual bool CanReadFile (const char *)=0
virtual bool CanWriteFile (const char *)=0
std::string GetByteOrderAsString (ByteOrder) const
virtual unsigned int GetComponentSize () const
virtual IOComponentType GetComponentType () const
virtual const std::type_info & GetComponentTypeInfo () const
virtual std::vector< double > GetDefaultDirection (unsigned int i) const
virtual unsigned int GetDimensions (unsigned int i) const
virtual std::vector< double > GetDirection (unsigned int i) const
std::string GetFileTypeAsString (FileType) const
SizeType GetImageSizeInBytes () const
SizeType GetImageSizeInComponents () const
SizeType GetImageSizeInPixels () const
virtual unsigned int GetNumberOfDimensions () const
virtual double GetOrigin (unsigned int i) const
virtual SizeType GetPixelStride () const
virtual double GetSpacing (unsigned int i) const
virtual ImageIORegion GetSplitRegionForWriting (unsigned int ithPiece, unsigned int numberOfActualSplits, const ImageIORegion &pasteRegion, const ImageIORegion &largestPossibleRegion)
const ArrayOfExtensionsTypeGetSupportedReadExtensions () const
const ArrayOfExtensionsTypeGetSupportedWriteExtensions () const
virtual void Read (void *buffer)=0
virtual void ReadImageInformation ()=0
void SetByteOrderToLittleEndian ()
virtual void SetComponentType (const IOComponentType _arg)
virtual void SetDirection (unsigned int i, std::vector< double > &direction)
virtual void SetDirection (unsigned int i, vnl_vector< double > &direction)
void SetFileTypeToBinary ()
void SetNumberOfDimensions (unsigned int)
virtual void SetOrigin (unsigned int i, double origin)
template<class TPixel , unsigned VLength>
void SetPixelTypeInfo (const SymmetricSecondRankTensor< TPixel, VLength > *)
template<typename TPixel >
void SetPixelTypeInfo (const DiffusionTensor3D< TPixel > *)
template<typename TPixel , unsigned VLength>
void SetPixelTypeInfo (const Matrix< TPixel, VLength, VLength > *)
template<typename TPixel >
void SetPixelTypeInfo (const std::complex< TPixel > *)
template<unsigned VLength>
void SetPixelTypeInfo (const Offset< VLength > *)
virtual void SetSpacing (unsigned int i, double spacing)
template<typename TPixel >
void SetTypeInfo (const TPixel *)
virtual bool SupportsDimension (unsigned long dim)
virtual void Write (const void *buffer)=0
virtual void WriteImageInformation ()=0
virtual void SetFileName (const char *_arg)
virtual const char * GetFileName () const
virtual void SetDimensions (unsigned int i, unsigned int dim)
virtual void SetIORegion (ImageIORegion _arg)
virtual const ImageIORegionGetIORegion ()
virtual void SetPixelType (const IOPixelType _arg)
virtual IOPixelType GetPixelType () const
virtual void SetNumberOfComponents (unsigned int _arg)
virtual const unsigned int & GetNumberOfComponents ()
virtual void SetUseCompression (bool _arg)
virtual bool GetUseCompression () const
virtual void UseCompressionOn ()
virtual void UseCompressionOff ()
virtual void SetUseStreamedReading (bool _arg)
virtual bool GetUseStreamedReading () const
virtual void UseStreamedReadingOn ()
virtual void UseStreamedReadingOff ()
virtual void SetUseStreamedWriting (bool _arg)
virtual bool GetUseStreamedWriting () const
virtual void UseStreamedWritingOn ()
virtual void UseStreamedWritingOff ()
virtual void SetFileType (const FileType _arg)
virtual FileType GetFileType () const
void SetFileTypeToASCII ()
virtual void SetByteOrder (const ByteOrder _arg)
virtual ByteOrder GetByteOrder () const
void SetByteOrderToBigEndian ()
template<typename TPixel >
void SetPixelTypeInfo (const TPixel *)
template<typename TPixel >
void SetPixelTypeInfo (const RGBPixel< TPixel > *)
template<typename TPixel >
void SetPixelTypeInfo (const RGBAPixel< TPixel > *)
template<typename TPixel , unsigned VLength>
void SetPixelTypeInfo (const Vector< TPixel, VLength > *)
template<typename TPixel >
void SetPixelTypeInfo (const VariableLengthVector< TPixel > *)
template<typename TPixel , unsigned VLength>
void SetPixelTypeInfo (const CovariantVector< TPixel, VLength > *)
template<typename TPixel , unsigned VLength>
void SetPixelTypeInfo (const FixedArray< TPixel, VLength > *)
- Public Member Functions inherited from itk::LightProcessObject
virtual void AbortGenerateDataOff ()
virtual void AbortGenerateDataOn ()
virtual ::itk::LightObject::Pointer CreateAnother (void) const
virtual const bool & GetAbortGenerateData ()
virtual void SetAbortGenerateData (bool _arg)
virtual void UpdateOutputData ()
void UpdateProgress (float amount)
virtual void SetProgress (float _arg)
virtual const float & GetProgress ()
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *)
unsigned long AddObserver (const EventObject &event, Command *) const
virtual void DebugOff () const
virtual void DebugOn () const
CommandGetCommand (unsigned long tag)
bool GetDebug () const
MetaDataDictionaryGetMetaDataDictionary (void)
const MetaDataDictionaryGetMetaDataDictionary (void) const
virtual unsigned long GetMTime () const
virtual const TimeStampGetTimeStamp () const
bool HasObserver (const EventObject &event) const
void InvokeEvent (const EventObject &)
void InvokeEvent (const EventObject &) const
virtual void Modified () const
virtual void Register () const
void RemoveAllObservers ()
void RemoveObserver (unsigned long tag)
void SetDebug (bool debugFlag) const
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
virtual void SetReferenceCount (int)
virtual void UnRegister () const
- Public Member Functions inherited from itk::LightObject
virtual void Delete ()
virtual int GetReferenceCount () const
 itkCloneMacro (Self)
void Print (std::ostream &os, Indent indent=0) const

Protected Member Functions

virtual SizeType GetDataPosition (void) const
virtual SizeType GetHeaderSize (void) const =0
virtual void OpenFileForReading (std::ifstream &os, const char *filename)
virtual void OpenFileForWriting (std::ofstream &os, const char *filename, bool truncate)
virtual void PrintSelf (std::ostream &os, Indent indent) const
virtual bool ReadBufferAsBinary (std::istream &is, void *buffer, SizeType num)
virtual bool RequestedToStream (void) const
 StreamingImageIOBase ()
virtual bool StreamReadBufferAsBinary (std::istream &os, void *buffer)
virtual bool StreamWriteBufferAsBinary (std::ostream &os, const void *buffer)
virtual bool WriteBufferAsBinary (std::ostream &is, const void *buffer, SizeType num)
- Protected Member Functions inherited from itk::ImageIOBase
void AddSupportedReadExtension (const char *extension)
void AddSupportedWriteExtension (const char *extension)
void ComputeStrides ()
virtual unsigned int GetActualNumberOfSplitsForWritingCanStreamWrite (unsigned int numberOfRequestedSplits, const ImageIORegion &pasteRegion) const
SizeType GetComponentStride () const
virtual unsigned int GetPixelSize () const
SizeType GetRowStride () const
SizeType GetSliceStride () const
virtual ImageIORegion GetSplitRegionForWritingCanStreamWrite (unsigned int ithPiece, unsigned int numberOfActualSplits, const ImageIORegion &pasteRegion) const
 ImageIOBase ()
virtual void ReadBufferAsASCII (std::istream &os, void *buffer, IOComponentType ctype, SizeType numberOfBytesToBeRead)
virtual void Reset (const bool freeDynamic=true)
void Resize (const unsigned int numDimensions, const unsigned int *dimensions)
virtual void WriteBufferAsASCII (std::ostream &os, const void *buffer, IOComponentType ctype, SizeType numberOfBytesToWrite)
 ~ImageIOBase ()
- Protected Member Functions inherited from itk::LightProcessObject
 LightProcessObject ()
 ~LightProcessObject ()
virtual void GenerateData ()
- Protected Member Functions inherited from itk::Object
 Object ()
bool PrintObservers (std::ostream &os, Indent indent) const
virtual void SetTimeStamp (const TimeStamp &time)
virtual ~Object ()
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 LightObject ()
virtual void PrintHeader (std::ostream &os, Indent indent) const
virtual void PrintTrailer (std::ostream &os, Indent indent) const
virtual ~LightObject ()

Private Member Functions

void operator= (const Self &)
 StreamingImageIOBase (const Self &)

Additional Inherited Members

- Static Public Member Functions inherited from itk::ImageIOBase
static std::string GetComponentTypeAsString (IOComponentType)
static IOComponentType GetComponentTypeFromString (const std::string &typeString)
static std::string GetPixelTypeAsString (IOPixelType)
static IOPixelType GetPixelTypeFromString (const std::string &pixelString)
- Static Public Member Functions inherited from itk::LightProcessObject
static Pointer New ()
- Static Public Member Functions inherited from itk::Object
static bool GetGlobalWarningDisplay ()
static void GlobalWarningDisplayOff ()
static void GlobalWarningDisplayOn ()
static void SetGlobalWarningDisplay (bool flag)
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
- Protected Attributes inherited from itk::ImageIOBase
ByteOrder m_ByteOrder
IOComponentType m_ComponentType
std::vector< SizeValueTypem_Dimensions
std::vector< std::vector
< double > > 
m_Direction
std::string m_FileName
FileType m_FileType
bool m_Initialized
ImageIORegion m_IORegion
unsigned int m_NumberOfComponents
unsigned int m_NumberOfDimensions
std::vector< double > m_Origin
IOPixelType m_PixelType
std::vector< double > m_Spacing
std::vector< SizeTypem_Strides
bool m_UseCompression
bool m_UseStreamedReading
bool m_UseStreamedWriting

Detailed Description

A base class for specific ImageIO file formats which support streaming.

This class overloads the methods needed to enable streaming. These methods are utilized by the ImageFileReader and ImageFileWriter. The implementation supports streaming of an arbitrary sized region as well as pasting to new or existing file ( of the same name, size, and pixel type ).

See also:
CanStreamWrite CanStreamRead GenerateStreamableReadRegionFromRequestedRegion GetActualNumberOfSplitsForWriting

Additionally low level IO methods are provided to read and write an IORegion from a file.

See also:
StreamReadBufferAsBinary StreamWriteBufferAsBinary

This implementation was taken fron the Insight Joural: http://hdl.handle.net/10380/3171

See also:
itk::ImageFileReader itk::ImageFileWriter

Definition at line 51 of file itkStreamingImageIOBase.h.


Member Typedef Documentation

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

Definition at line 57 of file itkStreamingImageIOBase.h.

Standard class typedefs.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

Definition at line 55 of file itkStreamingImageIOBase.h.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

Definition at line 56 of file itkStreamingImageIOBase.h.


Constructor & Destructor Documentation

itk::StreamingImageIOBase::StreamingImageIOBase ( )
protected
itk::StreamingImageIOBase::StreamingImageIOBase ( const Self )
private

Member Function Documentation

virtual bool itk::StreamingImageIOBase::CanStreamRead ( void  )
virtual

Determine if the ImageIO can stream reading from the current settings. Default is false. If this is queried after the header of the file has been read then it will indicate if that file can be streamed

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::VTKImageIO.

virtual bool itk::StreamingImageIOBase::CanStreamWrite ( void  )
virtual

Determine if the ImageIO can stream write from the current settings.

There are two types of non exclusive streaming: pasteing subregions, and iterative

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::JPEG2000ImageIO, and itk::VTKImageIO.

virtual ImageIORegion itk::StreamingImageIOBase::GenerateStreamableReadRegionFromRequestedRegion ( const ImageIORegion requested) const
virtual

Method for supporting streaming. Given a requested region, determine what could be the region that we can read from the file. This is called the streamable region, which will be equal or smaller than the LargestPossibleRegion (unless it was dimensionaly clipped) and greater or equal to the RequestedRegion

the resulting IORegion may be a greater dimensions the the requested IORegion, if the the derived class is unable to read the requested region. For example if the file has a size of [ 10, 10, 10] but the requested region is [10, 10] the return may be 3 dimensions.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::JPEG2000ImageIO.

virtual unsigned int itk::StreamingImageIOBase::GetActualNumberOfSplitsForWriting ( unsigned int  numberOfRequestedSplits,
const ImageIORegion pasteRegion,
const ImageIORegion largestPossibleRegion 
)
virtual

Before this method is called all the configuration will be done, that is Streaming/PasteRegion/Compression/Filename etc If pasting is being used the number of requested splits is for that region not the largest. The derived ImageIO class should verify that the file is capable of being written with this configuration. If pasted is enabled and is not support or does not work with the file, then an excepetion should be thrown.

The default implementation depends on CanStreamWrite. If false then 1 is returned (unless pasting is indicated), so that the whole file will be updated in one region. If true then its assumed that any arbitrary region can be written to any file. So the users request will be respected. If a derived class has more restictive conditions then they should be checked

Reimplemented from itk::ImageIOBase.

virtual SizeType itk::StreamingImageIOBase::GetDataPosition ( void  ) const
inlineprotectedvirtual

Returns the byte offset into the file where the data is located.

The default implementation is to return the header size.

Definition at line 152 of file itkStreamingImageIOBase.h.

virtual SizeType itk::StreamingImageIOBase::GetHeaderSize ( void  ) const
protectedpure virtual

Returns the size of the header in the file.

Implemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

virtual const char* itk::StreamingImageIOBase::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

virtual void itk::StreamingImageIOBase::OpenFileForReading ( std::ifstream &  os,
const char *  filename 
)
protectedvirtual

Opens a file for reading and random access.

The stream is closed if it's already opened. If an error is encountered then an exception will be thrown.

virtual void itk::StreamingImageIOBase::OpenFileForWriting ( std::ofstream &  os,
const char *  filename,
bool  truncate 
)
protectedvirtual

Opens a file for writing and random access.

Parameters:
osis an ostream presumed to be opened for writing
filenameis the name of the file
truncateif true then the file is truncated

The stream is closed if it's already opened. If an error is encountered then an exception will be thrown.

void itk::StreamingImageIOBase::operator= ( const Self )
private

This method causes the filter to generate its output.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::VTKImageIO, itk::MRCImageIO, and itk::JPEG2000ImageIO.

virtual void itk::StreamingImageIOBase::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
protectedvirtual

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::JPEG2000ImageIO, itk::MRCImageIO, and itk::VTKImageIO.

virtual bool itk::StreamingImageIOBase::ReadBufferAsBinary ( std::istream &  is,
void *  buffer,
SizeType  num 
)
protectedvirtual

Reimplemented from super class to get around 2GB read/write limitation.

Todo:
Move this method to itk::ImageIOBase

Reimplemented from itk::ImageIOBase.

virtual bool itk::StreamingImageIOBase::RequestedToStream ( void  ) const
protectedvirtual

Returns true if GetIORegion is not the same size as the largest region give by GetNumberOfDimensions.

This compares the IORegion to the size of the image in the file. With out regaurd to the dimensions of either, if the images represent the same region then false is returned.

virtual bool itk::StreamingImageIOBase::StreamReadBufferAsBinary ( std::istream &  os,
void *  buffer 
)
protectedvirtual

Reads the set IORegion from os into buffer.

Parameters:
osis an istream presumed to be opened for reading in binary mode
bufferis pointer to an allocated block of memory suitable to hold the IORegion of the pixel type

This methods relies on GetDataPosition to determin where the data is located in the file. It uses m_IORegion to determin the requested region to read.

The files data is assumed to be unpadded and continuous in the file for the size of the image in the dimensions of the m_IORegion. This means that the image file could be broken into slices, but not blocks for this methods to be used.

virtual bool itk::StreamingImageIOBase::StreamWriteBufferAsBinary ( std::ostream &  os,
const void *  buffer 
)
protectedvirtual

Writes the set IORegion from buffer into os.

Parameters:
osis an ostream presumed to be opened for writing and reading
bufferis a pointer to the data in a continuous block for the region

This methods relies on GetDataPosition to determin where the data is located in the file. It usesy m_IORegion determin the requested region to written.

virtual bool itk::StreamingImageIOBase::WriteBufferAsBinary ( std::ostream &  is,
const void *  buffer,
SizeType  num 
)
protectedvirtual

Reimplemented from super class to get around 2GB read/write limitation.

Todo:
Move this methods to itk::ImageIOBase

The documentation for this class was generated from the following file: