ITK  6.0.0
Insight Toolkit
itkExtractImageFilter.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 itkExtractImageFilter_h
19 #define itkExtractImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
22 #include "itkSmartPointer.h"
24 #include "ITKCommonExport.h"
25 
26 namespace itk
27 {
28 
36 {
37 public:
42  enum class DirectionCollapseStrategy : uint8_t
43  {
48  };
49 };
50 
52 extern ITKCommon_EXPORT std::ostream &
53  operator<<(std::ostream & out, const ExtractImageFilterEnums::DirectionCollapseStrategy value);
54 
55 
118 template <typename TInputImage, typename TOutputImage>
119 class ITK_TEMPLATE_EXPORT ExtractImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
120 {
121 public:
122  ITK_DISALLOW_COPY_AND_MOVE(ExtractImageFilter);
123 
129 
131  itkNewMacro(Self);
132 
134  itkOverrideGetNameOfClassMacro(ExtractImageFilter);
135 
137  using InputImageType = TInputImage;
138  using OutputImageType = TOutputImage;
139 
143 
145  using OutputImagePixelType = typename TOutputImage::PixelType;
146  using InputImagePixelType = typename TInputImage::PixelType;
147 
153 
156 #if !defined(ITK_LEGACY_REMOVE)
157  using DIRECTIONCOLLAPSESTRATEGY = DirectionCollapseStrategyEnum;
158  // We need to expose the enum values at the class level
159  // for backwards compatibility
160  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOUNKOWN =
161  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOUNKOWN;
162  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOIDENTITY =
163  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOIDENTITY;
164  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOSUBMATRIX =
165  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOSUBMATRIX;
166  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOGUESS =
167  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOGUESS;
168 #endif
169 
194  void
196  {
197  switch (choosenStrategy)
198  {
199  case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS:
200  case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY:
201  case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX:
202  break;
203  case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN:
204  default:
205  itkExceptionMacro("Invalid Strategy Chosen for itk::ExtractImageFilter");
206  }
209  this->m_DirectionCollapseStrategy = choosenStrategy;
210  this->Modified();
211  }
212 
221  DirectionCollapseStrategyEnum
223  {
224  return this->m_DirectionCollapseStrategy;
225  }
226 
228  void
230  {
231  this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS);
232  }
233 
235  void
237  {
238  this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY);
239  }
240 
242  void
244  {
245  this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX);
246  }
247 
248 
250  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
251  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
252 
255 
261  void
262  SetExtractionRegion(InputImageRegionType extractRegion);
263  itkGetConstMacro(ExtractionRegion, InputImageRegionType);
266 #ifdef ITK_USE_CONCEPT_CHECKING
267  // Begin concept checking
269  // End concept checking
270 #endif
271 
272 protected:
274  ~ExtractImageFilter() override = default;
275  void
276  PrintSelf(std::ostream & os, Indent indent) const override;
277 
286  void
287  GenerateOutputInformation() override;
288 
299  void
300  CallCopyOutputRegionToInputRegion(InputImageRegionType & destRegion,
301  const OutputImageRegionType & srcRegion) override;
302 
312  void
313  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
314 
317  void
318  GenerateData() override;
319 
320  InputImageRegionType m_ExtractionRegion{};
321 
322  OutputImageRegionType m_OutputImageRegion{};
323 
324 private:
325  DirectionCollapseStrategyEnum m_DirectionCollapseStrategy{ DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN };
326 };
327 
328 } // end namespace itk
329 
330 #ifndef ITK_MANUAL_INSTANTIATION
331 # include "itkExtractImageFilter.hxx"
332 #endif
333 
334 #endif
itk::ExtractImageFilter::InputImageType
TInputImage InputImageType
Definition: itkExtractImageFilter.h:137
itk::ExtractImageFilter::SetDirectionCollapseToIdentity
void SetDirectionCollapseToIdentity()
Definition: itkExtractImageFilter.h:236
itk::ExtractImageFilter::OutputImageSizeType
typename TOutputImage::SizeType OutputImageSizeType
Definition: itkExtractImageFilter.h:151
itk::ExtractImageFilter::InputImagePixelType
typename TInputImage::PixelType InputImagePixelType
Definition: itkExtractImageFilter.h:146
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itk::ExtractImageFilterEnums::DirectionCollapseStrategy::DIRECTIONCOLLAPSETOIDENTITY
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::ExtractImageFilterEnums::DirectionCollapseStrategy
DirectionCollapseStrategy
Definition: itkExtractImageFilter.h:42
itk::operator<<
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ExtractImageFilterEnums::DirectionCollapseStrategy::DIRECTIONCOLLAPSETOGUESS
itk::ExtractImageFilterEnums::DirectionCollapseStrategy::DIRECTIONCOLLAPSETOUNKOWN
itk::ExtractImageFilter::InputImageIndexType
typename TInputImage::IndexType InputImageIndexType
Definition: itkExtractImageFilter.h:150
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ExtractImageFilter::GetDirectionCollapseToStrategy
DirectionCollapseStrategyEnum GetDirectionCollapseToStrategy() const
Definition: itkExtractImageFilter.h:222
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ExtractImageFilterEnums
Definition: itkExtractImageFilter.h:35
itk::ExtractImageFilter::InputImageRegionType
typename TInputImage::RegionType InputImageRegionType
Definition: itkExtractImageFilter.h:142
itk::ExtractImageFilter::SetDirectionCollapseToStrategy
void SetDirectionCollapseToStrategy(const DirectionCollapseStrategyEnum choosenStrategy)
Definition: itkExtractImageFilter.h:195
itkExtractImageFilterRegionCopier.h
itk::ImageToImageFilterDetail::ExtractImageFilterRegionCopier
A special variation of ImageRegionCopier for when the output image has fewer dimensions than the inpu...
Definition: itkExtractImageFilterRegionCopier.h:140
itk::ExtractImageFilter::OutputImagePixelType
typename TOutputImage::PixelType OutputImagePixelType
Definition: itkExtractImageFilter.h:145
itk::ExtractImageFilter::SetDirectionCollapseToSubmatrix
void SetDirectionCollapseToSubmatrix()
Definition: itkExtractImageFilter.h:243
itk::ExtractImageFilter::OutputImageRegionType
typename TOutputImage::RegionType OutputImageRegionType
Definition: itkExtractImageFilter.h:141
itk::ExtractImageFilter::SetDirectionCollapseToGuess
void SetDirectionCollapseToGuess()
Definition: itkExtractImageFilter.h:229
itk::ExtractImageFilter::OutputImageIndexType
typename TOutputImage::IndexType OutputImageIndexType
Definition: itkExtractImageFilter.h:149
itk::ExtractImageFilter::InputImageSizeType
typename TInputImage::SizeType InputImageSizeType
Definition: itkExtractImageFilter.h:152
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkInPlaceImageFilter.h
itk::ExtractImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: itkExtractImageFilter.h:138
itk::Concept::Convertible
Definition: itkConceptChecking.h:217
itk::ExtractImageFilter
Decrease the image size by cropping the image to the selected region bounds.
Definition: itkExtractImageFilter.h:119
itkSmartPointer.h
itk::ExtractImageFilterEnums::DirectionCollapseStrategy::DIRECTIONCOLLAPSETOSUBMATRIX