Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitkAutoCropImageFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkAutoCropImageFilter_h
14 #define mitkAutoCropImageFilter_h
15 
17 #include "mitkCommon.h"
18 #include "mitkImageTimeSelector.h"
19 #include "mitkSubImageSelector.h"
20 
21 #include <itkImage.h>
22 #include <itkImageRegion.h>
23 
24 namespace mitk
25 {
54  {
55  public:
56  typedef itk::ImageRegion<3> RegionType;
57 
59 
60  itkFactorylessNewMacro(Self);
61 
62  itkCloneMacro(Self);
63 
64  itkGetConstMacro(BackgroundValue, float);
65  itkSetMacro(BackgroundValue, float);
66 
67  itkGetConstMacro(MarginFactor, float);
68  itkSetMacro(MarginFactor, float);
69 
70  itkGetMacro(CroppingRegion, RegionType);
71 
72  // Use this method to manually set a region
73  void SetCroppingRegion(RegionType overrideRegion);
74 
75  virtual const PixelType GetOutputPixelType();
76 
77  protected:
78  // default constructor
80 
81  // default destructor
83 
84  // This method calculates the actual smallest box
86 
87  // Crops the image using the itk::RegionOfInterestImageFilter and creates the new output image
88  template <typename TPixel, unsigned int VImageDimension>
89  void ITKCrop3DImage(itk::Image<TPixel, VImageDimension> *inputItkImage, unsigned int timestep);
90 
91  // Here, the output image is initialized by the input and the newly calculated region
92  void GenerateOutputInformation() override;
93 
94  // Purposely not implemented
96 
97  // Crops the image on all time steps
98  void GenerateData() override;
99 
101 
103 
105 
106  typedef itk::Image<float, 3> ImageType;
107  typedef ImageType::Pointer ImagePointer;
108 
109  RegionType::SizeType m_RegionSize;
110  RegionType::IndexType m_RegionIndex;
111 
113 
116 
118  };
119 
120 } // namespace mitk
121 
122 #endif
#define MITKALGORITHMSEXT_EXPORT
Shrink the image borders to a minimum considering a background color.
itk::ImageRegion< 3 > RegionType
void SetCroppingRegion(RegionType overrideRegion)
mitk::ImageTimeSelector::Pointer m_TimeSelector
mitkClassMacro(AutoCropImageFilter, SubImageSelector)
void ITKCrop3DImage(itk::Image< TPixel, VImageDimension > *inputItkImage, unsigned int timestep)
mitk::SlicedData::RegionType m_InputRequestedRegion
itk::Image< float, 3 > ImageType
RegionType::IndexType m_RegionIndex
void GenerateData() override
void GenerateInputRequestedRegion() override
virtual const PixelType GetOutputPixelType()
void GenerateOutputInformation() override
Superclass of all classes generating Images (instances of class Image) as output.
Class for defining the data type of pixels.
Definition: mitkPixelType.h:52
itk::ImageRegion< RegionDimension > RegionType
Base class of all classes providing access to parts of an image.
Find image slices visible on a given plane.