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
22#include "itkSmartPointer.h"
24#include "ITKCommonExport.h"
25
26namespace itk
27{
28
36{
37public:
42 enum class DirectionCollapseStrategy : uint8_t
43 {
44 DIRECTIONCOLLAPSETOUNKOWN = 0,
45 DIRECTIONCOLLAPSETOIDENTITY = 1,
46 DIRECTIONCOLLAPSETOSUBMATRIX = 2,
47 DIRECTIONCOLLAPSETOGUESS = 3
48 };
49};
50
52extern ITKCommon_EXPORT std::ostream &
54
55
118template <typename TInputImage, typename TOutputImage>
119class ITK_TEMPLATE_EXPORT ExtractImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
120{
121public:
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
263 itkGetConstMacro(ExtractionRegion, InputImageRegionType);
266#ifdef ITK_USE_CONCEPT_CHECKING
267 // Begin concept checking
269 // End concept checking
270#endif
271
272protected:
274 ~ExtractImageFilter() override = default;
275 void
276 PrintSelf(std::ostream & os, Indent indent) const override;
277
286 void
288
299 void
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
324private:
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
Decrease the image size by cropping the image to the selected region bounds.
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void GenerateData() override
void CallCopyOutputRegionToInputRegion(InputImageRegionType &destRegion, const OutputImageRegionType &srcRegion) override
void SetDirectionCollapseToStrategy(const DirectionCollapseStrategyEnum choosenStrategy)
void PrintSelf(std::ostream &os, Indent indent) const override
typename TOutputImage::IndexType OutputImageIndexType
typename TInputImage::IndexType InputImageIndexType
typename TOutputImage::PixelType OutputImagePixelType
typename TOutputImage::SizeType OutputImageSizeType
void GenerateOutputInformation() override
typename TInputImage::SizeType InputImageSizeType
typename TOutputImage::RegionType OutputImageRegionType
DirectionCollapseStrategyEnum GetDirectionCollapseToStrategy() const
void SetExtractionRegion(InputImageRegionType extractRegion)
typename TInputImage::PixelType InputImagePixelType
typename TInputImage::RegionType InputImageRegionType
~ExtractImageFilter() override=default
A special variation of ImageRegionCopier for when the output image has fewer dimensions than the inpu...
Base class for filters that take an image as input and overwrite that image as the output.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)