SimpleITK  1.3.0.dev216
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
itk::simple::ImageFileReader Class Reference

Read an image file and return a SimpleITK Image. More...

#include <sitkImageFileReader.h>

+ Inheritance diagram for itk::simple::ImageFileReader:
+ Collaboration diagram for itk::simple::ImageFileReader:

Public Types

typedef ImageFileReader Self
 
- Public Types inherited from itk::simple::ImageReaderBase
typedef ImageReaderBase Self
 
- Public Types inherited from itk::simple::ProcessObject
typedef ProcessObject Self
 

Public Member Functions

Image Execute ()
 
const std::vector< int > & GetExtractIndex () const
 
const std::vector< unsigned int > & GetExtractSize () const
 
std::string GetFileName () const
 
std::string GetMetaData (const std::string &key) const
 Get the value of a meta-data dictionary entry as a string. More...
 
std::vector< std::string > GetMetaDataKeys (void) const
 Get the meta-data dictionary keys. More...
 
virtual std::string GetName () const
 
bool HasMetaDataKey (const std::string &key) const
 Query a meta-data dictionary for the existence of a key. More...
 
 ImageFileReader ()
 
void ReadImageInformation (void)
 Read only the meta-data and image information in the file. More...
 
SelfSetExtractIndex (const std::vector< int > &index)
 starting index from the image on disk to extract. More...
 
SelfSetExtractSize (const std::vector< unsigned int > &size)
 size of image to extract from file. More...
 
SelfSetFileName (const std::string &fn)
 
virtual std::string ToString () const
 
virtual ~ImageFileReader ()
 
PixelIDValueEnum GetPixelID (void) const
 Image information methods updated via ReadImageInformation. More...
 
PixelIDValueType GetPixelIDValue (void) const
 Image information methods updated via ReadImageInformation. More...
 
unsigned int GetDimension (void) const
 Image information methods updated via ReadImageInformation. More...
 
unsigned int GetNumberOfComponents (void) const
 Image information methods updated via ReadImageInformation. More...
 
const std::vector< double > & GetOrigin (void) const
 Image information methods updated via ReadImageInformation. More...
 
const std::vector< double > & GetSpacing (void) const
 Image information methods updated via ReadImageInformation. More...
 
const std::vector< double > & GetDirection () const
 Image information methods updated via ReadImageInformation. More...
 
const std::vector< uint64_t > & GetSize (void) const
 Image information methods updated via ReadImageInformation. More...
 
- Public Member Functions inherited from itk::simple::ImageReaderBase
virtual std::vector< std::string > GetRegisteredImageIOs () const
 Get a vector of the names of registered itk ImageIOs. More...
 
 ImageReaderBase ()
 
virtual ~ImageReaderBase ()
 
SelfSetOutputPixelType (PixelIDValueEnum pixelID)
 Set/Get The output PixelType of the image. More...
 
PixelIDValueEnum GetOutputPixelType (void) const
 Set/Get The output PixelType of the image. More...
 
virtual SelfSetLoadPrivateTags (bool loadPrivateTags)
 Set/Get loading private DICOM tags into Image's MetaData. More...
 
virtual bool GetLoadPrivateTags () const
 Set/Get loading private DICOM tags into Image's MetaData. More...
 
virtual void LoadPrivateTagsOn ()
 Set/Get loading private DICOM tags into Image's MetaData. More...
 
virtual void LoadPrivateTagsOff ()
 Set/Get loading private DICOM tags into Image's MetaData. More...
 
virtual SelfSetImageIO (const std::string &imageio)
 Set/Get name of ImageIO to use. More...
 
virtual std::string GetImageIO (void) const
 Set/Get name of ImageIO to use. More...
 
- Public Member Functions inherited from itk::simple::ProcessObject
virtual void Abort ()
 
virtual int AddCommand (itk::simple::EventEnum event, itk::simple::Command &cmd)
 Add a Command Object to observer the event. More...
 
virtual float GetProgress () const
 An Active Measurement of the progress of execution. More...
 
virtual bool HasCommand (itk::simple::EventEnum event) const
 Query of this object has any registered commands for event. More...
 
 ProcessObject ()
 
virtual void RemoveAllCommands ()
 Remove all registered commands. More...
 
virtual ~ProcessObject ()
 
virtual void DebugOn ()
 
virtual void DebugOff ()
 
virtual bool GetDebug () const
 
virtual void SetDebug (bool debugFlag)
 
virtual void SetNumberOfThreads (unsigned int n)
 
virtual unsigned int GetNumberOfThreads () const
 

Protected Member Functions

template<class TImageType >
Image ExecuteInternal (itk::ImageIOBase *)
 
void UpdateImageInformationFromImageIO (const itk::ImageIOBase *iobase)
 
- Protected Member Functions inherited from itk::simple::ImageReaderBase
unsigned int GetDimensionFromImageIO (const std::string &fileName, unsigned int i)
 
unsigned int GetDimensionFromImageIO (const itk::ImageIOBase *iobase, unsigned int i)
 
itk::SmartPointer< ImageIOBaseGetImageIOBase (const std::string &fileName)
 
void GetPixelIDFromImageIO (const std::string &fileName, PixelIDValueType &outPixelType, unsigned int &outDimensions)
 
void GetPixelIDFromImageIO (const itk::ImageIOBase *iobase, PixelIDValueType &outPixelType, unsigned int &outDimensions)
 
- Protected Member Functions inherited from itk::simple::ProcessObject
virtual unsigned long AddITKObserver (const itk::EventObject &, itk::Command *)
 
virtual itk::ProcessObjectGetActiveProcess ()
 
virtual void OnActiveProcessDelete ()
 
virtual void onCommandDelete (const itk::simple::Command *cmd) SITK_NOEXCEPT
 
virtual void PreUpdate (itk::ProcessObject *p)
 
virtual void RemoveITKObserver (EventCommand &e)
 
- Protected Member Functions inherited from itk::simple::NonCopyable
 NonCopyable ()
 

Private Types

typedef Image(Self::* MemberFunctionType) (itk::ImageIOBase *)
 

Private Member Functions

template<class TImageType , class TInternalImageType >
Image ExecuteExtract (TInternalImageType *itkImage)
 

Private Attributes

unsigned int m_Dimension
 
std::vector< double > m_Direction
 
std::vector< int > m_ExtractIndex
 
std::vector< unsigned int > m_ExtractSize
 
std::string m_FileName
 
nsstd::auto_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
 
nsstd::auto_ptr< MetaDataDictionarym_MetaDataDictionary
 
unsigned int m_NumberOfComponents
 
std::vector< double > m_Origin
 
nsstd::function< std::string(const std::string &)> m_pfGetMetaData
 
nsstd::function< std::vector< std::string >)> m_pfGetMetaDataKeys
 
nsstd::function< bool(const std::string &)> m_pfHasMetaDataKey
 
PixelIDValueEnum m_PixelType
 
std::vector< uint64_tm_Size
 
std::vector< double > m_Spacing
 

Friends

struct detail::MemberFunctionAddressor< MemberFunctionType >
 

Additional Inherited Members

- Static Public Member Functions inherited from itk::simple::ProcessObject
static bool GetGlobalDefaultDebug ()
 
static void GlobalDefaultDebugOff ()
 
static void GlobalDefaultDebugOn ()
 
static void SetGlobalDefaultDebug (bool debugFlag)
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static void SetGlobalWarningDisplay (bool flag)
 
static bool GetGlobalWarningDisplay ()
 
static void SetGlobalDefaultNumberOfThreads (unsigned int n)
 
static unsigned int GetGlobalDefaultNumberOfThreads ()
 
static double GetGlobalDefaultCoordinateTolerance ()
 Access the global tolerance to determine congruent spaces. More...
 
static void SetGlobalDefaultCoordinateTolerance (double)
 Access the global tolerance to determine congruent spaces. More...
 
static double GetGlobalDefaultDirectionTolerance ()
 Access the global tolerance to determine congruent spaces. More...
 
static void SetGlobalDefaultDirectionTolerance (double)
 Access the global tolerance to determine congruent spaces. More...
 
- Static Protected Member Functions inherited from itk::simple::ProcessObject
template<class TImageType >
static TImageType::ConstPointer CastImageToITK (const Image &img)
 
template<class TImageType >
static Image CastITKToImage (TImageType *img)
 
template<class TPixelType , unsigned int VImageDimension, unsigned int VLength, template< typename, unsigned int > class TVector>
static Image CastITKToImage (itk::Image< TVector< TPixelType, VLength >, VImageDimension > *img)
 
static const itk::EventObjectGetITKEventObject (EventEnum e)
 
template<typename T >
static std::ostream & ToStringHelper (std::ostream &os, const T &v)
 
static std::ostream & ToStringHelper (std::ostream &os, const char &v)
 
static std::ostream & ToStringHelper (std::ostream &os, const signed char &v)
 
static std::ostream & ToStringHelper (std::ostream &os, const unsigned char &v)
 

Detailed Description

Read an image file and return a SimpleITK Image.

The reader can handle scalar images, and vector images. Pixel types such as RGB, RGBA are loaded as multi-component images with vector pixel types. Additionally, tensor images are loaded with the pixel type being a 1-d vector.

An interface is also provided to access the information from the underlying itk::ImageIO. This information can be loaded with the ReadImageInformation method. The information is from the itk::ImageIO interface. In some degenerate cases reading the bulk data may produce different results. Please see itk::ImageFileReader for more details.

Reading takes place by the ITK ImageIO factory mechanism. ITK contains many ImageIO classes which are responsible for reading separate file formats. By default, each ImageIO is asked if it "can read" the file, and the first one which "can read" the format is used. The list of available ImageIOs can be obtained using the GetRegisteredImageIOs method. The ImageIO used can be overridden with the SetImageIO method. This is useful in cases when multiple ImageIOs "can read" the file and the user wants to select a specific IO (not the first).

See also
itk::simple::ReadImage for the procedural interface
Examples:
FilterProgressReporting/FilterProgressReporting.cxx, ITKIntegration/ITKIntegration.cxx, Segmentation/ConnectedThresholdImageFilter.cxx, Segmentation/NeighborhoodConnectedImageFilter.cxx, and SimpleGaussian/SimpleGaussian.cxx.

Definition at line 60 of file sitkImageFileReader.h.

Member Typedef Documentation

typedef Image(Self::* itk::simple::ImageFileReader::MemberFunctionType) (itk::ImageIOBase *)
private

Definition at line 200 of file sitkImageFileReader.h.

Definition at line 64 of file sitkImageFileReader.h.

Constructor & Destructor Documentation

virtual itk::simple::ImageFileReader::~ImageFileReader ( )
virtual
itk::simple::ImageFileReader::ImageFileReader ( )

Member Function Documentation

Image itk::simple::ImageFileReader::Execute ( )
virtual
template<class TImageType , class TInternalImageType >
Image itk::simple::ImageFileReader::ExecuteExtract ( TInternalImageType *  itkImage)
private
template<class TImageType >
Image itk::simple::ImageFileReader::ExecuteInternal ( itk::ImageIOBase )
protected
unsigned int itk::simple::ImageFileReader::GetDimension ( void  ) const

Image information methods updated via ReadImageInformation.

These accessor methods are valid after a call to ReadImageInformation or Execute. They contain the image information from the file via the itk::ImageIO. Information such as NumberOfComponents is based of the file format, so the number of components for internal types such as RGB or complex may not be described the same as with SimpleITK's Image interface.

The PixelID has been converted from the ITK type to SimpleITK's interpretation, and will not change when loaded as a SimpleITK Image.

const std::vector<double>& itk::simple::ImageFileReader::GetDirection ( ) const

Image information methods updated via ReadImageInformation.

These accessor methods are valid after a call to ReadImageInformation or Execute. They contain the image information from the file via the itk::ImageIO. Information such as NumberOfComponents is based of the file format, so the number of components for internal types such as RGB or complex may not be described the same as with SimpleITK's Image interface.

The PixelID has been converted from the ITK type to SimpleITK's interpretation, and will not change when loaded as a SimpleITK Image.

const std::vector<int>& itk::simple::ImageFileReader::GetExtractIndex ( ) const
const std::vector<unsigned int>& itk::simple::ImageFileReader::GetExtractSize ( ) const
std::string itk::simple::ImageFileReader::GetFileName ( ) const
std::string itk::simple::ImageFileReader::GetMetaData ( const std::string &  key) const

Get the value of a meta-data dictionary entry as a string.

If the key is not in the dictionary then an exception is thrown.

String types in the dictionary are returned as their native string. Other types are printed to string before returning.

std::vector<std::string> itk::simple::ImageFileReader::GetMetaDataKeys ( void  ) const

Get the meta-data dictionary keys.

This is only valid after successful ReadImageInformation or Execute of this filter.

Returns a vector of keys to the key/value entries in the file's meta-data dictionary. Iterate through with these keys to get the values.

virtual std::string itk::simple::ImageFileReader::GetName ( ) const
inlinevirtual

return user readable name of the filter

Implements itk::simple::ProcessObject.

Definition at line 74 of file sitkImageFileReader.h.

unsigned int itk::simple::ImageFileReader::GetNumberOfComponents ( void  ) const

Image information methods updated via ReadImageInformation.

These accessor methods are valid after a call to ReadImageInformation or Execute. They contain the image information from the file via the itk::ImageIO. Information such as NumberOfComponents is based of the file format, so the number of components for internal types such as RGB or complex may not be described the same as with SimpleITK's Image interface.

The PixelID has been converted from the ITK type to SimpleITK's interpretation, and will not change when loaded as a SimpleITK Image.

const std::vector<double>& itk::simple::ImageFileReader::GetOrigin ( void  ) const

Image information methods updated via ReadImageInformation.

These accessor methods are valid after a call to ReadImageInformation or Execute. They contain the image information from the file via the itk::ImageIO. Information such as NumberOfComponents is based of the file format, so the number of components for internal types such as RGB or complex may not be described the same as with SimpleITK's Image interface.

The PixelID has been converted from the ITK type to SimpleITK's interpretation, and will not change when loaded as a SimpleITK Image.

PixelIDValueEnum itk::simple::ImageFileReader::GetPixelID ( void  ) const

Image information methods updated via ReadImageInformation.

These accessor methods are valid after a call to ReadImageInformation or Execute. They contain the image information from the file via the itk::ImageIO. Information such as NumberOfComponents is based of the file format, so the number of components for internal types such as RGB or complex may not be described the same as with SimpleITK's Image interface.

The PixelID has been converted from the ITK type to SimpleITK's interpretation, and will not change when loaded as a SimpleITK Image.

PixelIDValueType itk::simple::ImageFileReader::GetPixelIDValue ( void  ) const

Image information methods updated via ReadImageInformation.

These accessor methods are valid after a call to ReadImageInformation or Execute. They contain the image information from the file via the itk::ImageIO. Information such as NumberOfComponents is based of the file format, so the number of components for internal types such as RGB or complex may not be described the same as with SimpleITK's Image interface.

The PixelID has been converted from the ITK type to SimpleITK's interpretation, and will not change when loaded as a SimpleITK Image.

const std::vector<uint64_t>& itk::simple::ImageFileReader::GetSize ( void  ) const

Image information methods updated via ReadImageInformation.

These accessor methods are valid after a call to ReadImageInformation or Execute. They contain the image information from the file via the itk::ImageIO. Information such as NumberOfComponents is based of the file format, so the number of components for internal types such as RGB or complex may not be described the same as with SimpleITK's Image interface.

The PixelID has been converted from the ITK type to SimpleITK's interpretation, and will not change when loaded as a SimpleITK Image.

const std::vector<double>& itk::simple::ImageFileReader::GetSpacing ( void  ) const

Image information methods updated via ReadImageInformation.

These accessor methods are valid after a call to ReadImageInformation or Execute. They contain the image information from the file via the itk::ImageIO. Information such as NumberOfComponents is based of the file format, so the number of components for internal types such as RGB or complex may not be described the same as with SimpleITK's Image interface.

The PixelID has been converted from the ITK type to SimpleITK's interpretation, and will not change when loaded as a SimpleITK Image.

bool itk::simple::ImageFileReader::HasMetaDataKey ( const std::string &  key) const

Query a meta-data dictionary for the existence of a key.

void itk::simple::ImageFileReader::ReadImageInformation ( void  )

Read only the meta-data and image information in the file.

This method can be used to determine what the size and pixel type of an image file is without reading the whole image. Even if SimpleITK does not support an image of a certain dimension or type, the meta-information can still be read.

Self& itk::simple::ImageFileReader::SetExtractIndex ( const std::vector< int > &  index)

starting index from the image on disk to extract.

Missing dimensions are treated the same as 0.

/sa ExtractImageFilter

Self& itk::simple::ImageFileReader::SetExtractSize ( const std::vector< unsigned int > &  size)

size of image to extract from file.

By default the reader loads the entire image, this is specified when the size has zero length.

If specified, then the image returned from Execute will be of this size. If the ImageIO and file support reading just a region, then the reader will perform streaming.

The dimension of the image can be reduced by specifying a dimension's size as 0. For example a size of $[10,20,30,0,0]$ results in a 3D image with size of $[10,20,30]$. This enables reading a 5D image into a 3D image. If the length of the specified size is greater than the dimension of the image file, an exception will be generated. If the size's length is less than the image's dimension then the missing values are assumed to be zero.

When the dimension of the image is reduced, the direction cosine matrix will be set to the identity. However, the spacing for the selected axis will remain. The matrix from the file can still be obtained by ImageFileReader::GetDirection.

/sa ExtractImageFilter

Self& itk::simple::ImageFileReader::SetFileName ( const std::string &  fn)
virtual std::string itk::simple::ImageFileReader::ToString ( ) const
virtual

Print ourselves to string

Reimplemented from itk::simple::ImageReaderBase.

void itk::simple::ImageFileReader::UpdateImageInformationFromImageIO ( const itk::ImageIOBase iobase)
protected

Internal method which update's this classes stored meta-data and image information.

Friends And Related Function Documentation

Definition at line 203 of file sitkImageFileReader.h.

Member Data Documentation

unsigned int itk::simple::ImageFileReader::m_Dimension
private

Definition at line 216 of file sitkImageFileReader.h.

std::vector<double> itk::simple::ImageFileReader::m_Direction
private

Definition at line 218 of file sitkImageFileReader.h.

std::vector<int> itk::simple::ImageFileReader::m_ExtractIndex
private

Definition at line 225 of file sitkImageFileReader.h.

std::vector<unsigned int> itk::simple::ImageFileReader::m_ExtractSize
private

Definition at line 224 of file sitkImageFileReader.h.

std::string itk::simple::ImageFileReader::m_FileName
private

Definition at line 211 of file sitkImageFileReader.h.

nsstd::auto_ptr<detail::MemberFunctionFactory<MemberFunctionType> > itk::simple::ImageFileReader::m_MemberFactory
private

Definition at line 204 of file sitkImageFileReader.h.

nsstd::auto_ptr<MetaDataDictionary> itk::simple::ImageFileReader::m_MetaDataDictionary
private

Definition at line 213 of file sitkImageFileReader.h.

unsigned int itk::simple::ImageFileReader::m_NumberOfComponents
private

Definition at line 217 of file sitkImageFileReader.h.

std::vector<double> itk::simple::ImageFileReader::m_Origin
private

Definition at line 219 of file sitkImageFileReader.h.

nsstd::function<std::string(const std::string &)> itk::simple::ImageFileReader::m_pfGetMetaData
private

Definition at line 209 of file sitkImageFileReader.h.

nsstd::function<std::vector<std::string>)> itk::simple::ImageFileReader::m_pfGetMetaDataKeys
private

Definition at line 207 of file sitkImageFileReader.h.

nsstd::function<bool(const std::string &)> itk::simple::ImageFileReader::m_pfHasMetaDataKey
private

Definition at line 208 of file sitkImageFileReader.h.

PixelIDValueEnum itk::simple::ImageFileReader::m_PixelType
private

Definition at line 215 of file sitkImageFileReader.h.

std::vector<uint64_t> itk::simple::ImageFileReader::m_Size
private

Definition at line 222 of file sitkImageFileReader.h.

std::vector<double> itk::simple::ImageFileReader::m_Spacing
private

Definition at line 220 of file sitkImageFileReader.h.


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