ITK  5.4.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};
51extern ITKCommon_EXPORT std::ostream &
53
54
117template <typename TInputImage, typename TOutputImage>
118class ITK_TEMPLATE_EXPORT ExtractImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
119{
120public:
121 ITK_DISALLOW_COPY_AND_MOVE(ExtractImageFilter);
122
128
130 itkNewMacro(Self);
131
133 itkOverrideGetNameOfClassMacro(ExtractImageFilter);
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 }
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
262 itkGetConstMacro(ExtractionRegion, InputImageRegionType);
265#ifdef ITK_USE_CONCEPT_CHECKING
266 // Begin concept checking
268 // End concept checking
269#endif
270
271protected:
273 ~ExtractImageFilter() override = default;
274 void
275 PrintSelf(std::ostream & os, Indent indent) const override;
276
285 void
287
298 void
300 const OutputImageRegionType & srcRegion) override;
301
311 void
312 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
313
316 void
317 GenerateData() override;
318
319 InputImageRegionType m_ExtractionRegion{};
320
321 OutputImageRegionType m_OutputImageRegion{};
322
323private:
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
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....
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:216