Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkCorrectorAlgorithm.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 mitkCorrectorAlgorithm_h
14 #define mitkCorrectorAlgorithm_h
15 
16 #include <mitkContourModel.h>
17 #include <mitkImageToImageFilter.h>
19 #include <mitkLabel.h>
20 
21 #include <itkImage.h>
22 
23 #define multilabelSegmentationType unsigned short
24 namespace mitk
25 {
39  {
40  public:
42  itkFactorylessNewMacro(Self);
43  itkCloneMacro(Self);
44 
46 
50  void SetContour(ContourModel *contour) { this->m_Contour = contour; }
51  itkSetMacro(FillColor, int);
52  itkGetConstMacro(FillColor, int);
53 
54  itkSetMacro(EraseColor, int);
55  itkGetConstMacro(EraseColor, int);
56 
57  // used by TobiasHeimannCorrectionAlgorithm
58  typedef struct
59  {
60  int lineStart;
61  int lineEnd;
62  bool modified;
63 
64  std::vector<itk::Index<2>> points;
65  } TSegData;
66 
67  protected:
69  ~CorrectorAlgorithm() override;
70 
72  void GenerateData() override;
73 
77  bool ImprovedHeimannCorrectionAlgorithm(itk::Image<DefaultSegmentationDataType, 2>::Pointer pic);
78 
82  bool ModifySegment(const TSegData &segment, itk::Image<DefaultSegmentationDataType, 2>::Pointer pic);
83 
84  Image::Pointer m_WorkingImage;
85  ContourModel::Pointer m_Contour;
86  Image::Pointer m_DifferenceImage;
87 
90 
91  private:
92  template <typename ScalarType>
93  itk::Index<2> ensureIndexInImage(ScalarType i0, ScalarType i1);
94 
95  void ColorSegment(const mitk::CorrectorAlgorithm::TSegData &segment,
96  itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer pic);
97  itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer CloneImage(
98  itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer pic);
99  itk::Index<2> GetFirstPoint(const mitk::CorrectorAlgorithm::TSegData &segment,
100  itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer pic);
101  std::vector<itk::Index<2>> FindSeedPoints(
102  const mitk::CorrectorAlgorithm::TSegData &segment,
103  itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer pic);
104  int FillRegion(const std::vector<itk::Index<2>> &seedPoints,
105  itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer pic);
106  void OverwriteImage(itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer source,
107  itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer target);
108  };
109 }
110 
111 #endif
#define MITKSEGMENTATION_EXPORT
A time-resolved contour representation consisting of linked vertices in 3D space.
Contour-based correction algorithm for 2D binary segmentation images.
mitk::Label::PixelType DefaultSegmentationDataType
mitkClassMacro(CorrectorAlgorithm, ImageToImageFilter)
void GenerateData() override
Perform the actual contour correction processing.
~CorrectorAlgorithm() override
bool ImprovedHeimannCorrectionAlgorithm(itk::Image< DefaultSegmentationDataType, 2 >::Pointer pic)
Apply the improved Heilmann correction algorithm on the given 2D image.
void SetContour(ContourModel *contour)
Set the user-drawn contour that defines the correction region.
ContourModel::Pointer m_Contour
bool ModifySegment(const TSegData &segment, itk::Image< DefaultSegmentationDataType, 2 >::Pointer pic)
Modify a single segment in the image according to the correction contour.
Superclass of all classes having one or more Images as input and generating Images as output.
unsigned short PixelType
Pixel type used for label values (unsigned short).
Definition: mitkLabel.h:106
Find image slices visible on a given plane.
double ScalarType
Scalar type used throughout MITK for geometric computations.
std::vector< itk::Index< 2 > > points