Medical Imaging Interaction Toolkit  2026.06.00
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:
57  typedef itk::ImageRegion<3> RegionType;
58 
60 
61  itkFactorylessNewMacro(Self);
62 
63  itkCloneMacro(Self);
64 
69  itkGetConstMacro(BackgroundValue, float);
70 
75  itkSetMacro(BackgroundValue, float);
76 
81  itkGetConstMacro(MarginFactor, float);
82 
91  itkSetMacro(MarginFactor, float);
92 
97  itkGetMacro(CroppingRegion, RegionType);
98 
107  void SetCroppingRegion(RegionType overrideRegion);
108 
113  virtual const PixelType GetOutputPixelType();
114 
115  protected:
116  // default constructor
118 
119  // default destructor
121 
122  // This method calculates the actual smallest box
124 
125  // Crops the image using the itk::RegionOfInterestImageFilter and creates the new output image
126  template <typename TPixel, unsigned int VImageDimension>
127  void ITKCrop3DImage(itk::Image<TPixel, VImageDimension> *inputItkImage, unsigned int timestep);
128 
129  // Here, the output image is initialized by the input and the newly calculated region
130  void GenerateOutputInformation() override;
131 
132  // Purposely not implemented
134 
135  // Crops the image on all time steps
136  void GenerateData() override;
137 
139 
141 
143 
144  typedef itk::Image<float, 3> ImageType;
145  typedef ImageType::Pointer ImagePointer;
146 
147  RegionType::SizeType m_RegionSize;
148  RegionType::IndexType m_RegionIndex;
149 
150  mitk::ImageTimeSelector::Pointer m_TimeSelector;
151 
154 
156  };
157 
158 } // namespace mitk
159 
160 #endif
#define MITKALGORITHMSEXT_EXPORT
Shrink the image borders to a minimum considering a background color.
itk::ImageRegion< 3 > RegionType
3D image region type used for cropping bounds.
void SetCroppingRegion(RegionType overrideRegion)
Manually set the cropping region, overriding automatic computation.
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()
Returns the pixel type of the output image.
void GenerateOutputInformation() override
Describes the data type of image pixels.
Definition: mitkPixelType.h:75
itk::ImageRegion< RegionDimension > RegionType
Base class of all classes providing access to parts of an image.
Find image slices visible on a given plane.