Medical Imaging Interaction Toolkit  2024.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:
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
82  ~AutoCropImageFilter() override;
83 
84  // This method calculates the actual smallest box
85  void ComputeNewImageBounds();
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
95  void GenerateInputRequestedRegion() override;
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
mitk::AutoCropImageFilter
Shrink the image borders to a minimum considering a background color.
Definition: mitkAutoCropImageFilter.h:53
mitk::SubImageSelector
Base class of all classes providing access to parts of an image.
Definition: mitkSubImageSelector.h:31
mitk::AutoCropImageFilter::m_InputRequestedRegion
mitk::SlicedData::RegionType m_InputRequestedRegion
Definition: mitkAutoCropImageFilter.h:114
mitkImageTimeSelector.h
mitk::AutoCropImageFilter::ImagePointer
ImageType::Pointer ImagePointer
Definition: mitkAutoCropImageFilter.h:107
itk::SmartPointer< Self >
MitkAlgorithmsExtExports.h
mitk::SlicedData::RegionType
itk::ImageRegion< RegionDimension > RegionType
Definition: mitkSlicedData.h:45
mitk::AutoCropImageFilter::RegionType
itk::ImageRegion< 3 > RegionType
Definition: mitkAutoCropImageFilter.h:56
MITKALGORITHMSEXT_EXPORT
#define MITKALGORITHMSEXT_EXPORT
Definition: MitkAlgorithmsExtExports.h:15
mitk::AutoCropImageFilter::m_RegionIndex
RegionType::IndexType m_RegionIndex
Definition: mitkAutoCropImageFilter.h:110
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::BaseDataSource
Superclass of all classes generating some kind of mitk::BaseData.
Definition: mitkBaseDataSource.h:71
mitk::AutoCropImageFilter::m_RegionSize
RegionType::SizeType m_RegionSize
Definition: mitkAutoCropImageFilter.h:109
mitkSubImageSelector.h
mitk::AutoCropImageFilter::m_BackgroundValue
float m_BackgroundValue
Definition: mitkAutoCropImageFilter.h:100
mitk::PixelType
Class for defining the data type of pixels.
Definition: mitkPixelType.h:51
mitkCommon.h
mitk::AutoCropImageFilter::ImageType
itk::Image< float, 3 > ImageType
Definition: mitkAutoCropImageFilter.h:106
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::AutoCropImageFilter::m_TimeOfHeaderInitialization
itk::TimeStamp m_TimeOfHeaderInitialization
Definition: mitkAutoCropImageFilter.h:115
mitk::AutoCropImageFilter::m_CroppingRegion
RegionType m_CroppingRegion
Definition: mitkAutoCropImageFilter.h:102
mitk::AutoCropImageFilter::m_TimeSelector
mitk::ImageTimeSelector::Pointer m_TimeSelector
Definition: mitkAutoCropImageFilter.h:112
mitk::AutoCropImageFilter::m_OverrideCroppingRegion
bool m_OverrideCroppingRegion
Definition: mitkAutoCropImageFilter.h:117
mitk::AutoCropImageFilter::m_MarginFactor
float m_MarginFactor
Definition: mitkAutoCropImageFilter.h:104