SimpleITK  
sitkImageFileReader.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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
27namespace itk
28{
29
31
32namespace simple
33{
34
75{
76public:
78
79 ~ImageFileReader() override;
80
82
84 std::string
85 ToString() const override;
86
88 std::string
89 GetName() const override
90 {
91 return std::string("ImageFileReader");
92 }
93
94 SITK_RETURN_SELF_TYPE_HEADER
95 SetFileName(const PathType & fn);
97 GetFileName() const;
98
99 Image
100 Execute() override;
101
102 // Interface methods to access image file's meta-data and image
103 // information after calling Execute or after calling
104 // MetaDataRead, which does not load the bulk pixel data.
105
114 void
116
132 GetPixelID() const;
135 unsigned int
137 unsigned int
139 const std::vector<double> &
140 GetOrigin() const;
141 const std::vector<double> &
142 GetSpacing() const;
143 const std::vector<double> &
145 const std::vector<uint64_t> &
146 GetSize() const;
148
158 std::vector<std::string>
160
163 bool
164 HasMetaDataKey(const std::string & key) const;
165
174 std::string
175 GetMetaData(const std::string & key) const;
176
177
204 SITK_RETURN_SELF_TYPE_HEADER
205 SetExtractSize(const std::vector<unsigned int> & size);
206 const std::vector<unsigned int> &
208
209
216 SITK_RETURN_SELF_TYPE_HEADER
217 SetExtractIndex(const std::vector<int> & index);
218 const std::vector<int> &
220
221protected:
222 template <class TImageType>
223 Image
225
229 void
231
232private:
233 // Internal method used implement extracting a region from the reader
234 template <class TImageType, class TInternalImageType>
235 Image
236 ExecuteExtract(TInternalImageType * itkImage);
237
238 // function pointer type
240
241 // friend to get access to executeInternal member
243 std::unique_ptr<detail::MemberFunctionFactory<MemberFunctionType>> m_MemberFactory;
244
245
246 std::function<std::vector<std::string>()> m_pfGetMetaDataKeys;
247 std::function<bool(const std::string &)> m_pfHasMetaDataKey;
248 std::function<std::string(const std::string &)> m_pfGetMetaData;
249
251
252 std::unique_ptr<MetaDataDictionary> m_MetaDataDictionary;
253
255 unsigned int m_Dimension;
257 std::vector<double> m_Direction;
258 std::vector<double> m_Origin;
259 std::vector<double> m_Spacing;
260
261 std::vector<uint64_t> m_Size;
262
263 std::vector<unsigned int> m_ExtractSize;
264 std::vector<int> m_ExtractIndex;
265};
266
279ReadImage(const PathType & filename, PixelIDValueEnum outputPixelType = sitkUnknown, const std::string & imageIO = "");
280} // namespace simple
281} // namespace itk
282
283#endif
std::function< std::vector< std::string >()> m_pfGetMetaDataKeys
unsigned int GetDimension() const
Image information methods updated via ReadImageInformation.
Self & SetExtractSize(const std::vector< unsigned int > &size)
size of image to extract from file.
std::function< bool(const std::string &)> m_pfHasMetaDataKey
Image(Self::* MemberFunctionType)(itk::ImageIOBase *)
PathType GetFileName() const
const std::vector< double > & GetOrigin() const
Image information methods updated via ReadImageInformation.
std::vector< unsigned int > m_ExtractSize
Image ExecuteExtract(TInternalImageType *itkImage)
const std::vector< double > & GetSpacing() const
Image information methods updated via ReadImageInformation.
const std::vector< double > & GetDirection() const
Image information methods updated via ReadImageInformation.
void ReadImageInformation()
Read only the meta-data and image information in the file.
unsigned int GetNumberOfComponents() const
Image information methods updated via ReadImageInformation.
std::vector< double > m_Direction
std::vector< uint64_t > m_Size
const std::vector< uint64_t > & GetSize() const
Image information methods updated via ReadImageInformation.
std::vector< std::string > GetMetaDataKeys() const
Get the meta-data dictionary keys.
Self & SetExtractIndex(const std::vector< int > &index)
starting index from the image on disk to extract.
std::string ToString() const override
const std::vector< int > & GetExtractIndex() const
std::string GetMetaData(const std::string &key) const
Get the value of a meta-data dictionary entry as a string.
const std::vector< unsigned int > & GetExtractSize() const
PixelIDValueEnum GetPixelID() const
Image information methods updated via ReadImageInformation.
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
std::string GetName() const override
std::function< std::string(const std::string &)> m_pfGetMetaData
Image ExecuteInternal(itk::ImageIOBase *)
void UpdateImageInformationFromImageIO(const itk::ImageIOBase *iobase)
bool HasMetaDataKey(const std::string &key) const
Query a meta-data dictionary for the existence of a key.
std::unique_ptr< MetaDataDictionary > m_MetaDataDictionary
PixelIDValueType GetPixelIDValue() const
Image information methods updated via ReadImageInformation.
Self & SetFileName(const PathType &fn)
The Image class for SimpleITK.
Definition sitkImage.h:77
std::string PathType
SITKIO_EXPORT Image ReadImage(const PathType &filename, PixelIDValueEnum outputPixelType=sitkUnknown, const std::string &imageIO="")
ReadImage is a procedural interface to the ImageFileReader class which is convenient for most image r...
PixelIDValueEnum
Enumerated values of pixelIDs.
#define SITKIO_EXPORT
Definition sitkIO.h:33