ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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 * https://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"
31
32namespace itk
33{
34
74template <typename TOutputImage,
76class ITK_TEMPLATE_EXPORT ImageFileReader : public ImageSource<TOutputImage>
77{
78public:
79 ITK_DISALLOW_COPY_AND_MOVE(ImageFileReader);
80
85
87 itkNewMacro(Self);
88
90 itkOverrideGetNameOfClassMacro(ImageFileReader);
91
93 using SizeType = typename TOutputImage::SizeType;
94
96 using IndexType = typename TOutputImage::IndexType;
97
99 using ImageRegionType = typename TOutputImage::RegionType;
100
102 using OutputImagePixelType = typename TOutputImage::InternalPixelType;
103
105 itkSetGetDecoratedInputMacro(FileName, std::string);
106
114 void
116 itkGetModifiableObjectMacro(ImageIO, ImageIOBase);
118
121 itkSetMacro(UseStreaming, bool);
122 itkGetConstReferenceMacro(UseStreaming, bool);
123 itkBooleanMacro(UseStreaming);
125
127
132 void
134
140
141 void
143 {
144 this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY);
145 }
146
147 void
149 {
150 this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX);
151 }
152
153 void
155 {
156 this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS);
157 }
158
159
160protected:
162 ~ImageFileReader() override = default;
163 void
164 PrintSelf(std::ostream & os, Indent indent) const override;
165
167 void
168 DoConvertBuffer(const void * inputData, size_t numberOfPixels);
169
175 void
177
180 void
182
188 void
190
192 void
193 GenerateData() override;
194
196
197 bool m_UserSpecifiedImageIO{}; // keep track whether the
198 // ImageIO is user specified
199
201
202private:
204 DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY
205 };
206
207 std::string m_ExceptionMessage{};
208
209 // The region that the ImageIO class will return when we ask to
210 // produce the requested region.
212};
213
214
224template <typename TOutputImage,
225 typename ConvertPixelTraits = DefaultConvertPixelTraits<typename TOutputImage::IOPixelType>>
226typename TOutputImage::Pointer
227ReadImage(const std::string & filename)
228{
230 reader->SetFileName(filename);
231 reader->Update();
232 return reader->GetOutput();
233}
234
235} // namespace itk
236
237#ifndef ITK_MANUAL_INSTANTIATION
238# include "itkImageFileReader.hxx"
239#endif
240
241#if defined ITK_IMAGEIO_FACTORY_REGISTER_MANAGER || defined ITK_IO_FACTORY_REGISTER_MANAGER
242# include "itkImageIOFactoryRegisterManager.h"
243#endif
244
245#endif // itkImageFileReader_h
Base class for all data objects in ITK.
Traits class used to by ConvertPixels to convert blocks of pixels.
void SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum strategy)
void EnlargeOutputRequestedRegion(DataObject *output) override
void SetImageIO(ImageIOBase *imageIO)
void GenerateOutputInformation() override
void DoConvertBuffer(const void *inputData, vcl_size_t numberOfPixels)
typename TOutputImage::RegionType ImageRegionType
void GenerateData() override
typename TOutputImage::IndexType IndexType
void TestFileExistanceAndReadability()
typename TOutputImage::InternalPixelType OutputImagePixelType
DirectionCollapseStrategyEnum GetDirectionCollapseToStrategy() const
typename TOutputImage::SizeType SizeType
ImageSource< TOutputImage > Superclass
DirectionCollapseStrategyEnum m_DirectionCollapseStrategy
static Pointer New()
ExtractImageFilterEnums::DirectionCollapseStrategy DirectionCollapseStrategyEnum
SmartPointer< Self > Pointer
~ImageFileReader() override=default
ImageIOBase::Pointer m_ImageIO
void PrintSelf(std::ostream &os, Indent indent) const override
Abstract superclass defines image IO interface.
SmartPointer< Self > Pointer
An ImageIORegion represents a structured region of data.
Control indentation during Print() invocation.
Definition itkIndent.h:53
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
TOutputImage::Pointer ReadImage(const std::string &filename)