ITK  5.2.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  * 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 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:
43  {
48  };
49 };
51 extern ITKCommon_EXPORT std::ostream &
52  operator<<(std::ostream & out, const ExtractImageFilterEnums::DirectionCollapseStrategy value);
53 
54 
117 template <typename TInputImage, typename TOutputImage>
118 class ITK_TEMPLATE_EXPORT ExtractImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
119 {
120 public:
121  ITK_DISALLOW_COPY_AND_ASSIGN(ExtractImageFilter);
122 
128 
130  itkNewMacro(Self);
131 
133  itkTypeMacro(ExtractImageFilter, InPlaceImageFilter);
134 
136  using InputImageType = TInputImage;
137  using OutputImageType = TOutputImage;
138 
142 
144  using OutputImagePixelType = typename TOutputImage::PixelType;
145  using InputImagePixelType = typename TInputImage::PixelType;
146 
152 
155 #if !defined(ITK_LEGACY_REMOVE)
156  using DIRECTIONCOLLAPSESTRATEGY = DirectionCollapseStrategyEnum;
157  // We need to expose the enum values at the class level
158  // for backwards compatibility
159  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOUNKOWN =
160  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOUNKOWN;
161  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOIDENTITY =
162  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOIDENTITY;
163  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOSUBMATRIX =
164  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOSUBMATRIX;
165  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOGUESS =
166  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOGUESS;
167 #endif
168 
193  void
195  {
196  switch (choosenStrategy)
197  {
198  case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS:
199  case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY:
200  case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX:
201  break;
202  case DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN:
203  default:
204  itkExceptionMacro(<< "Invalid Strategy Chosen for itk::ExtractImageFilter");
205  }
207 
208  this->m_DirectionCollapseStrategy = choosenStrategy;
209  this->Modified();
210  }
211 
220  DirectionCollapseStrategyEnum
222  {
223  return this->m_DirectionCollapseStrategy;
224  }
225 
227  void
229  {
230  this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS);
231  }
232 
234  void
236  {
237  this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY);
238  }
239 
241  void
243  {
244  this->SetDirectionCollapseToStrategy(DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX);
245  }
246 
247 
249  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
250  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
251 
254 
260  void
261  SetExtractionRegion(InputImageRegionType extractRegion);
262  itkGetConstMacro(ExtractionRegion, InputImageRegionType);
264 
265 #ifdef ITK_USE_CONCEPT_CHECKING
266  // Begin concept checking
268  // End concept checking
269 #endif
270 
271 protected:
273  ~ExtractImageFilter() override = default;
274  void
275  PrintSelf(std::ostream & os, Indent indent) const override;
276 
285  void
286  GenerateOutputInformation() override;
287 
298  void
299  CallCopyOutputRegionToInputRegion(InputImageRegionType & destRegion,
300  const OutputImageRegionType & srcRegion) override;
301 
311  void
312  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
313 
316  void
317  GenerateData() override;
318 
320 
322 
323 private:
324  DirectionCollapseStrategyEnum m_DirectionCollapseStrategy{ DirectionCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN };
325 };
326 
327 } // end namespace itk
328 
329 #ifndef ITK_MANUAL_INSTANTIATION
330 # include "itkExtractImageFilter.hxx"
331 #endif
332 
333 #endif
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::ExtractImageFilter::InputImageType
TInputImage InputImageType
Definition: itkExtractImageFilter.h:136
itk::ExtractImageFilter::SetDirectionCollapseToIdentity
void SetDirectionCollapseToIdentity()
Definition: itkExtractImageFilter.h:235
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:213
itk::ExtractImageFilter::OutputImageSizeType
typename TOutputImage::SizeType OutputImageSizeType
Definition: itkExtractImageFilter.h:150
itk::ExtractImageFilterEnums::DirectionCollapseStrategy
DirectionCollapseStrategy
Definition: itkExtractImageFilter.h:42
itk::ExtractImageFilter::InputImagePixelType
typename TInputImage::PixelType InputImagePixelType
Definition: itkExtractImageFilter.h:145
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itk::ExtractImageFilter::m_ExtractionRegion
InputImageRegionType m_ExtractionRegion
Definition: itkExtractImageFilter.h:319
itk::ExtractImageFilter::m_OutputImageRegion
OutputImageRegionType m_OutputImageRegion
Definition: itkExtractImageFilter.h:321
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::ExtractImageFilterEnums::DirectionCollapseStrategy::DIRECTIONCOLLAPSETOUNKOWN
itk::ExtractImageFilterEnums::DirectionCollapseStrategy::DIRECTIONCOLLAPSETOGUESS
itk::ExtractImageFilter::InputImageIndexType
typename TInputImage::IndexType InputImageIndexType
Definition: itkExtractImageFilter.h:149
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ExtractImageFilter::GetDirectionCollapseToStrategy
DirectionCollapseStrategyEnum GetDirectionCollapseToStrategy() const
Definition: itkExtractImageFilter.h:221
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ExtractImageFilterEnums::DirectionCollapseStrategy::DIRECTIONCOLLAPSETOIDENTITY
itk::ExtractImageFilterEnums
Definition: itkExtractImageFilter.h:35
itk::ExtractImageFilter::InputImageRegionType
typename TInputImage::RegionType InputImageRegionType
Definition: itkExtractImageFilter.h:141
itk::ExtractImageFilter::SetDirectionCollapseToStrategy
void SetDirectionCollapseToStrategy(const DirectionCollapseStrategyEnum choosenStrategy)
Definition: itkExtractImageFilter.h:194
itkExtractImageFilterRegionCopier.h
itk::ImageToImageFilterDetail::ExtractImageFilterRegionCopier
A special variation of ImageRegionCopier for when the output image has fewer dimensions than the inpu...
Definition: itkExtractImageFilterRegionCopier.h:142
itk::ExtractImageFilter::OutputImagePixelType
typename TOutputImage::PixelType OutputImagePixelType
Definition: itkExtractImageFilter.h:144
itk::ExtractImageFilter::SetDirectionCollapseToSubmatrix
void SetDirectionCollapseToSubmatrix()
Definition: itkExtractImageFilter.h:242
itk::ExtractImageFilter::OutputImageRegionType
typename TOutputImage::RegionType OutputImageRegionType
Definition: itkExtractImageFilter.h:140
itk::ExtractImageFilter::SetDirectionCollapseToGuess
void SetDirectionCollapseToGuess()
Definition: itkExtractImageFilter.h:228
DirectionCollapseStrategy
itk::ExtractImageFilter::OutputImageIndexType
typename TOutputImage::IndexType OutputImageIndexType
Definition: itkExtractImageFilter.h:148
itk::ExtractImageFilter::InputImageSizeType
typename TInputImage::SizeType InputImageSizeType
Definition: itkExtractImageFilter.h:151
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkInPlaceImageFilter.h
itk::ExtractImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: itkExtractImageFilter.h:137
itk::ExtractImageFilterEnums::DirectionCollapseStrategy::DIRECTIONCOLLAPSETOSUBMATRIX
itk::Concept::Convertible
Definition: itkConceptChecking.h:214
itk::ExtractImageFilter
Decrease the image size by cropping the image to the selected region bounds.
Definition: itkExtractImageFilter.h:118
itkSmartPointer.h