SimpleITK  1.1.0
sitkImageFileReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18 #ifndef sitkImageFileReader_h
19 #define sitkImageFileReader_h
20 
21 #include "sitkMacro.h"
22 #include "sitkImage.h"
23 #include "sitkImageReaderBase.h"
25 
26 
27 namespace itk {
28 
29  class MetaDataDictionary;
30 
31  namespace simple {
32 
48  : public ImageReaderBase
49  {
50  public:
52 
53  virtual ~ImageFileReader();
54 
56 
58  virtual std::string ToString() const;
59 
61  virtual std::string GetName() const { return std::string("ImageFileReader"); }
62 
63  SITK_RETURN_SELF_TYPE_HEADER SetFileName ( const std::string &fn );
64  std::string GetFileName() const;
65 
66  Image Execute();
67 
68  // Interface methods to access image file's meta-data and image
69  // information after calling Execute or after calling
70  // MetaDataRead, which does not load the bulk pixel data.
71 
80  void ReadImageInformation(void);
81 
96  PixelIDValueEnum GetPixelID( void ) const;
97  PixelIDValueType GetPixelIDValue( void ) const;
98  unsigned int GetDimension( void ) const;
99  unsigned int GetNumberOfComponents( void ) const;
100  const std::vector<double> &GetOrigin( void ) const;
101  const std::vector<double> &GetSpacing( void ) const;
102  const std::vector<double> &GetDirection() const;
103  const std::vector<uint64_t> &GetSize( void ) const;
104  /* @} */
105 
115  std::vector<std::string> GetMetaDataKeys( void ) const;
116 
119  bool HasMetaDataKey( const std::string &key ) const;
120 
129  std::string GetMetaData( const std::string &key ) const;
130 
131  protected:
132 
133  template <class TImageType> Image ExecuteInternal ( itk::ImageIOBase * );
134 
138  void UpdateImageInformationFromImageIO( const itk::ImageIOBase* iobase );
139 
140  private:
141 
142  // function pointer type
143  typedef Image (Self::*MemberFunctionType)( itk::ImageIOBase * );
144 
145  // friend to get access to executeInternal member
146  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
147  nsstd::auto_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
148 
149 
150  nsstd::function<std::vector<std::string>()> m_pfGetMetaDataKeys;
151  nsstd::function<bool(const std::string &)> m_pfHasMetaDataKey;
152  nsstd::function<std::string(const std::string &)> m_pfGetMetaData;
153 
154  std::string m_FileName;
155 
156  nsstd::auto_ptr<MetaDataDictionary> m_MetaDataDictionary;
157 
159  unsigned int m_Dimension;
160  unsigned int m_NumberOfComponents;
161  std::vector<double> m_Direction;
162  std::vector<double> m_Origin;
163  std::vector<double> m_Spacing;
164 
165  std::vector<uint64_t> m_Size;
166  };
167 
177  SITKIO_EXPORT Image ReadImage ( const std::string &filename, PixelIDValueEnum outputPixelType = sitkUnknown );
178  }
179 }
180 
181 #endif
itk::simple::Image
The main Image class for SimpleITK.
Definition: sitkImage.h:54
itk::ImageIOBase
itk::simple::PixelIDValueType
int PixelIDValueType
Definition: sitkPixelIDValues.h:32
itk::simple::ImageFileReader::m_Size
std::vector< uint64_t > m_Size
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:165
itk::simple::ImageFileReader::m_Dimension
unsigned int m_Dimension
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:159
itk::simple::detail::MemberFunctionAddressor
Definition: sitkDetail.h:32
itk::simple::ImageFileReader::m_pfGetMetaDataKeys
nsstd::function< std::vector< std::string >)> m_pfGetMetaDataKeys
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:150
SITKIO_EXPORT
#define SITKIO_EXPORT
Definition: sitkIO.h:33
itk::simple::ImageFileReader::m_MemberFactory
nsstd::auto_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:147
sitkImage.h
itk::simple::ImageFileReader
Read an image file and return a SimpleITK Image.
Definition: sitkImageFileReader.h:47
itk::simple::PixelIDValueEnum
PixelIDValueEnum
Enumerated values of pixelIDs.
Definition: sitkPixelIDValues.h:82
sitkMemberFunctionFactory.h
itk::simple::ImageFileReader::GetName
virtual std::string GetName() const
Definition: sitkImageFileReader.h:61
itk::simple::ImageFileReader::m_Origin
std::vector< double > m_Origin
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:162
itk::simple::ReadImage
SITKIO_EXPORT Image ReadImage(const std::string &filename, PixelIDValueEnum outputPixelType=sitkUnknown)
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
itk::simple::ImageFileReader::m_FileName
std::string m_FileName
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:154
sitkMacro.h
itk::simple::ImageFileReader::m_NumberOfComponents
unsigned int m_NumberOfComponents
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:160
sitkImageReaderBase.h
itk::simple::ImageFileReader::Self
ImageFileReader Self
Definition: sitkImageFileReader.h:51
itk::simple::ImageFileReader::m_Direction
std::vector< double > m_Direction
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:161
itk::simple::ImageFileReader::m_pfGetMetaData
nsstd::function< std::string(const std::string &)> m_pfGetMetaData
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:152
itk::simple::ImageFileReader::m_Spacing
std::vector< double > m_Spacing
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:163
itk::simple::ImageReaderBase
An abract base class for image readers.
Definition: sitkImageReaderBase.h:39
itk
itk::simple::ImageFileReader::m_PixelType
PixelIDValueEnum m_PixelType
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:158
itk::simple::ProcessObject
Base class for SimpleITK classes based on ProcessObject.
Definition: sitkProcessObject.h:50
itk::simple::sitkUnknown
@ sitkUnknown
Definition: sitkPixelIDValues.h:83
itk::simple::ImageFileReader::m_MetaDataDictionary
nsstd::auto_ptr< MetaDataDictionary > m_MetaDataDictionary
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:156
itk::simple::ImageFileReader::m_pfHasMetaDataKey
nsstd::function< bool(const std::string &)> m_pfHasMetaDataKey
Image information methods updated via ReadImageInformation.
Definition: sitkImageFileReader.h:151