ITK  5.2.0
Insight Toolkit
itkImageFileReader.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 itkImageFileReader_h
19 #define itkImageFileReader_h
21 
22 #include "ITKIOImageBaseExport.h"
23 
24 #include "itkImageIOBase.h"
25 #include "itkImageSource.h"
26 #include "itkMacro.h"
27 #include "itkImageRegion.h"
30 
31 namespace itk
32 {
33 
73 template <typename TOutputImage,
74  typename ConvertPixelTraits = DefaultConvertPixelTraits<typename TOutputImage::IOPixelType>>
75 class ITK_TEMPLATE_EXPORT ImageFileReader : public ImageSource<TOutputImage>
76 {
77 public:
78  ITK_DISALLOW_COPY_AND_ASSIGN(ImageFileReader);
79 
84 
86  itkNewMacro(Self);
87 
89  itkTypeMacro(ImageFileReader, ImageSource);
90 
92  using SizeType = typename TOutputImage::SizeType;
93 
96 
99 
101  using OutputImagePixelType = typename TOutputImage::InternalPixelType;
102 
104  itkSetGetDecoratedInputMacro(FileName, std::string);
105 
112  void
113  SetImageIO(ImageIOBase * imageIO);
114  itkGetModifiableObjectMacro(ImageIO, ImageIOBase);
116 
118  itkSetMacro(UseStreaming, bool);
119  itkGetConstReferenceMacro(UseStreaming, bool);
120  itkBooleanMacro(UseStreaming);
122 
123 protected:
124  ImageFileReader();
125  ~ImageFileReader() override = default;
126  void
127  PrintSelf(std::ostream & os, Indent indent) const override;
128 
130  void
131  DoConvertBuffer(void * buffer, size_t numberOfPixels);
132 
138  void
139  TestFileExistanceAndReadability();
140 
143  void
144  GenerateOutputInformation() override;
145 
151  void
152  EnlargeOutputRequestedRegion(DataObject * output) override;
153 
155  void
156  GenerateData() override;
157 
159 
160  bool m_UserSpecifiedImageIO; // keep track whether the
161  // ImageIO is user specified
162 
164 
165 private:
166  std::string m_ExceptionMessage;
167 
168  // The region that the ImageIO class will return when we ask to
169  // produce the requested region.
171 };
172 } // namespace itk
173 
174 #ifndef ITK_MANUAL_INSTANTIATION
175 # include "itkImageFileReader.hxx"
176 #endif
177 
178 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER
179 # include "itkImageIOFactoryRegisterManager.h"
180 #endif
181 
182 #endif // itkImageFileReader_h
itk::ImageIOBase
Abstract superclass defines image IO interface.
Definition: itkImageIOBase.h:75
itkImageSource.h
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ImageIORegion
An ImageIORegion represents a structured region of data.
Definition: itkImageIORegion.h:52
itkImageFileReaderException.h
itk::ImageFileReader::SizeType
typename TOutputImage::SizeType SizeType
Definition: itkImageFileReader.h:92
itkImageRegion.h
itk::ImageFileReader
Data source that reads image data from a single file.
Definition: itkImageFileReader.h:75
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itkDefaultConvertPixelTraits.h
itk::ImageFileReader::m_ExceptionMessage
std::string m_ExceptionMessage
Definition: itkImageFileReader.h:166
itk::ImageFileReader::IndexType
typename TOutputImage::IndexType IndexType
Definition: itkImageFileReader.h:95
itkMacro.h
itk::ImageFileReader::m_ActualIORegion
ImageIORegion m_ActualIORegion
Definition: itkImageFileReader.h:170
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itkImageIOBase.h
itk::ImageFileReader::m_UserSpecifiedImageIO
bool m_UserSpecifiedImageIO
Definition: itkImageFileReader.h:160
itk::ImageFileReader::ImageRegionType
typename TOutputImage::RegionType ImageRegionType
Definition: itkImageFileReader.h:98
itk::ImageFileReader::m_UseStreaming
bool m_UseStreaming
Definition: itkImageFileReader.h:163
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itkSimpleDataObjectDecorator.h
itk::ImageFileReader::m_ImageIO
ImageIOBase::Pointer m_ImageIO
Definition: itkImageFileReader.h:158
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293