ITK  5.2.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  * 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 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:
41  {
46  };
47 };
48 // Define how to print enumeration
49 extern std::ostream &
51 
106 
107 template <typename TInputImage, typename TOutputImage>
108 class ITK_TEMPLATE_EXPORT ExtractSliceImageFilter : public ImageSource<TOutputImage>
109 {
110 public:
111  ITK_DISALLOW_COPY_AND_MOVE(ExtractSliceImageFilter);
112 
118 
120  itkNewMacro(Self);
121 
123  itkTypeMacro(ExtractSliceImageFilter, ImageSource);
124 
126  using InputImageType = TInputImage;
127  using OutputImageType = TOutputImage;
128 
132 
134  using OutputImagePixelType = typename TOutputImage::PixelType;
135  using InputImagePixelType = typename TInputImage::PixelType;
136 
142 
148 #if !defined(ITK_LEGACY_REMOVE)
149  // We need to expose the enum values at the class level
150  // for backwards compatibility
151  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOUNKOWN =
152  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOUNKOWN;
153  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOIDENTITY =
154  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOIDENTITY;
155  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOSUBMATRIX =
156  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOSUBMATRIX;
157  static constexpr DIRECTIONCOLLAPSESTRATEGY DIRECTIONCOLLAPSETOGUESS =
158  DIRECTIONCOLLAPSESTRATEGY::DIRECTIONCOLLAPSETOGUESS;
159 #endif
160 
185  void
187  {
188  switch (choosenStrategy)
189  {
190  case TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS:
191  case TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY:
192  case TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX:
193  break;
194  case TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN:
195  default:
196  itkExceptionMacro(<< "Invalid Strategy Chosen for itk::ExtractSliceImageFilter");
197  }
199 
200  this->m_DirectionCollaspeStrategy = choosenStrategy;
201  this->Modified();
202  }
203 
212  DIRECTIONCOLLAPSESTRATEGY
213  GetDirectionCollapseToStrategy() const { return this->m_DirectionCollaspeStrategy; }
214 
216  void
218  {
219  this->SetDirectionCollapseToStrategy(TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOGUESS);
220  }
221 
223  void
225  {
226  this->SetDirectionCollapseToStrategy(TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOIDENTITY);
227  }
228 
230  void
232  {
233  this->SetDirectionCollapseToStrategy(TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOSUBMATRIX);
234  }
235 
236 
238  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
239  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
240 
243 
249  void
250  SetExtractionRegion(InputImageRegionType extractRegion);
251  itkGetConstMacro(ExtractionRegion, InputImageRegionType);
253 
255  using Superclass::SetInput;
256  virtual void
257  SetInput(const TInputImage * input);
258  const TInputImage *
259  GetInput() const;
261 
262 #ifdef ITK_USE_CONCEPT_CHECKING
263  // Begin concept checking
265  // End concept checking
266 #endif
267 
268 protected:
270  ~ExtractSliceImageFilter() override = default;
271  void
272  PrintSelf(std::ostream & os, Indent indent) const override;
273 
282  void
283  GenerateOutputInformation() override;
284 
294  virtual void
295  CallCopyOutputRegionToInputRegion(InputImageRegionType & destRegion, const OutputImageRegionType & srcRegion);
296 
305  void
306  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
307 
309 
311 
312 private:
313  DIRECTIONCOLLAPSESTRATEGY m_DirectionCollaspeStrategy{
314  TestExtractSliceImageFilterCollapseStrategyEnum::DIRECTIONCOLLAPSETOUNKOWN
315  };
316 };
317 } // end namespace Testing
318 } // end namespace itk
319 
320 #ifndef ITK_MANUAL_INSTANTIATION
321 # include "itkTestingExtractSliceImageFilter.hxx"
322 #endif
323 
324 #endif
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::Testing::ExtractSliceImageFilter::InputImageType
TInputImage InputImageType
Definition: itkTestingExtractSliceImageFilter.h:126
itk::Testing::ExtractSliceImageFilter::InputImageSizeType
typename TInputImage::SizeType InputImageSizeType
Definition: itkTestingExtractSliceImageFilter.h:141
itk::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy::DIRECTIONCOLLAPSETOGUESS
itkImageSource.h
itk::Testing::ExtractSliceImageFilter::m_ExtractionRegion
InputImageRegionType m_ExtractionRegion
Definition: itkTestingExtractSliceImageFilter.h:308
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::DIRECTIONCOLLAPSETOIDENTITY
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:135
itk::Testing::ExtractSliceImageFilter::GetDirectionCollapseToStrategy
DIRECTIONCOLLAPSESTRATEGY GetDirectionCollapseToStrategy() const
Definition: itkTestingExtractSliceImageFilter.h:213
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::Testing::ExtractSliceImageFilter::InputImageIndexType
typename TInputImage::IndexType InputImageIndexType
Definition: itkTestingExtractSliceImageFilter.h:139
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::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy
TestExtractSliceImageFilterCollapseStrategy
Definition: itkTestingExtractSliceImageFilter.h:40
itk::Testing::operator<<
std::ostream & operator<<(std::ostream &out, const ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy value)
itk::Testing::ExtractSliceImageFilter::SetDirectionCollapseToSubmatrix
void SetDirectionCollapseToSubmatrix()
Definition: itkTestingExtractSliceImageFilter.h:231
itk::Testing::ExtractSliceImageFilter::SetDirectionCollapseToStrategy
void SetDirectionCollapseToStrategy(const DIRECTIONCOLLAPSESTRATEGY choosenStrategy)
Definition: itkTestingExtractSliceImageFilter.h:186
itk::Testing::ExtractSliceImageFilter::InputImageRegionType
typename TInputImage::RegionType InputImageRegionType
Definition: itkTestingExtractSliceImageFilter.h:131
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy::DIRECTIONCOLLAPSETOSUBMATRIX
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Testing::ExtractSliceImageFilter::SetDirectionCollapseToGuess
void SetDirectionCollapseToGuess()
Definition: itkTestingExtractSliceImageFilter.h:217
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
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itkSmartPointer.h
itk::Testing::ExtractSliceImageFilterEnums::TestExtractSliceImageFilterCollapseStrategy::DIRECTIONCOLLAPSETOUNKOWN
itk::Testing::ExtractSliceImageFilterEnums
Contains all enum classes used by the ExtractSliceImageFilterEnums class.
Definition: itkTestingExtractSliceImageFilter.h:33
itk::Testing::ExtractSliceImageFilter::m_OutputImageRegion
OutputImageRegionType m_OutputImageRegion
Definition: itkTestingExtractSliceImageFilter.h:310
itk::Testing::ExtractSliceImageFilter::SetDirectionCollapseToIdentity
void SetDirectionCollapseToIdentity()
Definition: itkTestingExtractSliceImageFilter.h:224
itk::Testing::ExtractSliceImageFilter::OutputImageSizeType
typename TOutputImage::SizeType OutputImageSizeType
Definition: itkTestingExtractSliceImageFilter.h:140
itk::Testing::ExtractSliceImageFilter::OutputImageIndexType
typename TOutputImage::IndexType OutputImageIndexType
Definition: itkTestingExtractSliceImageFilter.h:138
TestExtractSliceImageFilterCollapseStrategy
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:108