ITK  6.0.0
Insight Toolkit
itkTestingExtractSliceImageFilter.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 itkTestingExtractSliceImageFilter_h
19 #define itkTestingExtractSliceImageFilter_h
20 
21 #include "itkSmartPointer.h"
22 #include "itkImageSource.h"
24 
25 namespace itk
26 {
27 namespace Testing
28 {
34 {
35 public:
40  {
45  };
46 };
47 // Define how to print enumeration
48 extern std::ostream &
50 
106 template <typename TInputImage, typename TOutputImage>
107 class ITK_TEMPLATE_EXPORT ExtractSliceImageFilter : public ImageSource<TOutputImage>
108 {
109 public:
110  ITK_DISALLOW_COPY_AND_MOVE(ExtractSliceImageFilter);
111 
117 
119  itkNewMacro(Self);
120 
122  itkOverrideGetNameOfClassMacro(ExtractSliceImageFilter);
123 
125  using InputImageType = TInputImage;
126  using OutputImageType = TOutputImage;
127 
131 
133  using OutputImagePixelType = typename TOutputImage::PixelType;
134  using InputImagePixelType = typename TInputImage::PixelType;
135 
141 
147 #if !defined(ITK_LEGACY_REMOVE)
148  // We need to expose the enum values at the class level
149  // for backwards compatibility
150  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOUNKOWN =
151  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOUNKOWN;
152  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOIDENTITY =
153  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOIDENTITY;
154  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOSUBMATRIX =
155  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOSUBMATRIX;
156  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOGUESS =
157  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOGUESS;
158 #endif
159 
184  void
186  {
187  switch (choosenStrategy)
188  {
189  case TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS:
190  case TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY:
191  case TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX:
192  break;
193  case TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN:
194  default:
195  itkExceptionMacro("Invalid Strategy Chosen for itk::ExtractSliceImageFilter");
196  }
199  this->m_DirectionCollaspeStrategy = choosenStrategy;
200  this->Modified();
201  }
202 
211  DIRECTIONCOLLAPSESTRATEGY
212  GetDirectionCollapseToStrategy() const { return this->m_DirectionCollaspeStrategy; }
213 
215  void
217  {
218  this->SetDirectionCollapseToStrategy(TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS);
219  }
220 
222  void
224  {
225  this->SetDirectionCollapseToStrategy(TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY);
226  }
227 
229  void
231  {
232  this->SetDirectionCollapseToStrategy(TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX);
233  }
234 
235 
237  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
238  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
239 
242 
248  void
249  SetExtractionRegion(InputImageRegionType extractRegion);
250  itkGetConstMacro(ExtractionRegion, InputImageRegionType);
254  using Superclass::SetInput;
255  virtual void
256  SetInput(const TInputImage * input);
257  const TInputImage *
258  GetInput() const;
261 #ifdef ITK_USE_CONCEPT_CHECKING
262  // Begin concept checking
264  // End concept checking
265 #endif
266 
267 protected:
269  ~ExtractSliceImageFilter() override = default;
270  void
271  PrintSelf(std::ostream & os, Indent indent) const override;
272 
281  void
282  GenerateOutputInformation() override;
283 
293  virtual void
294  CallCopyOutputRegionToInputRegion(InputImageRegionType & destRegion, const OutputImageRegionType & srcRegion);
295 
304  void
305  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
306 
307  InputImageRegionType m_ExtractionRegion{};
308 
309  OutputImageRegionType m_OutputImageRegion{};
310 
311 private:
312  DIRECTIONCOLLAPSESTRATEGY m_DirectionCollaspeStrategy{
313  TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN
314  };
315 };
316 } // end namespace Testing
317 } // end namespace itk
318 
319 #ifndef ITK_MANUAL_INSTANTIATION
320 # include "itkTestingExtractSliceImageFilter.hxx"
321 #endif
322 
323 #endif
itk::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy::DIRECTIONCOLLAPSETOSUBMATRIX
itk::Testing::ExtractSliceImageFilter::InputImageType
TInputImage InputImageType
Definition: itkTestingExtractSliceImageFilter.h:125
itk::Testing::ExtractSliceImageFilter::InputImageSizeType
typename TInputImage::SizeType InputImageSizeType
Definition: itkTestingExtractSliceImageFilter.h:140
itkImageSource.h
itk::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy::DIRECTIONCOLLAPSETOIDENTITY
itk::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy::DIRECTIONCOLLAPSETOUNKOWN
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::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy
TestExtractSliceImageFilterCollapseStrategy
Definition: itkTestingExtractSliceImageFilter.h:39
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
itk::Testing::ExtractSliceImageFilter::InputImagePixelType
typename TInputImage::PixelType InputImagePixelType
Definition: itkTestingExtractSliceImageFilter.h:134
itk::Testing::ExtractSliceImageFilter::GetDirectionCollapseToStrategy
DIRECTIONCOLLAPSESTRATEGY GetDirectionCollapseToStrategy() const
Definition: itkTestingExtractSliceImageFilter.h:212
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::Testing::ExtractSliceImageFilter::InputImageIndexType
typename TInputImage::IndexType InputImageIndexType
Definition: itkTestingExtractSliceImageFilter.h:138
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::Testing::operator<<
std::ostream & operator<<(std::ostream &out, const ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy value)
itk::Testing::ExtractSliceImageFilter::SetDirectionCollapseToSubmatrix
void SetDirectionCollapseToSubmatrix()
Definition: itkTestingExtractSliceImageFilter.h:230
itk::Testing::ExtractSliceImageFilter::SetDirectionCollapseToStrategy
void SetDirectionCollapseToStrategy(const DIRECTIONCOLLAPSESTRATEGY choosenStrategy)
Definition: itkTestingExtractSliceImageFilter.h:185
itk::Testing::ExtractSliceImageFilter::InputImageRegionType
typename TInputImage::RegionType InputImageRegionType
Definition: itkTestingExtractSliceImageFilter.h:130
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
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
itk::Testing::ExtractSliceImageFilter::SetDirectionCollapseToGuess
void SetDirectionCollapseToGuess()
Definition: itkTestingExtractSliceImageFilter.h:216
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::Concept::Convertible
Definition: itkConceptChecking.h:217
itk::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy::DIRECTIONCOLLAPSETOGUESS
itkSmartPointer.h
itk::Testing::ExtractSliceImageFilterEnums
Contains all enum classes used by the ExtractSliceImageFilterEnums class.
Definition: itkTestingExtractSliceImageFilter.h:33
itk::Testing::ExtractSliceImageFilter::SetDirectionCollapseToIdentity
void SetDirectionCollapseToIdentity()
Definition: itkTestingExtractSliceImageFilter.h:223
itk::Testing::ExtractSliceImageFilter::OutputImageSizeType
typename TOutputImage::SizeType OutputImageSizeType
Definition: itkTestingExtractSliceImageFilter.h:139
itk::Testing::ExtractSliceImageFilter::OutputImageIndexType
typename TOutputImage::IndexType OutputImageIndexType
Definition: itkTestingExtractSliceImageFilter.h:137
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::Testing::ExtractSliceImageFilter
Decrease the image size by cropping the image to the selected region bounds.
Definition: itkTestingExtractSliceImageFilter.h:107