Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkRegionGrowingTool.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 mitkRegionGrowingTool_h
14 #define mitkRegionGrowingTool_h
15 
18 #include <array>
19 
20 namespace us
21 {
22  class ModuleResource;
23 }
24 
25 namespace mitk
26 {
50  {
51  public:
53  itkFactorylessNewMacro(Self);
54  itkCloneMacro(Self);
55 
58 
59  const char *GetName() const override;
60 
63 
64  protected:
65  RegionGrowingTool(); // purposely hidden
66  ~RegionGrowingTool() override;
67 
68  void ConnectActionsAndFunctions() override;
69 
70  void Activated() override;
71  void Deactivated() override;
72 
78  virtual void OnMousePressed(StateMachineAction *, InteractionEvent *interactionEvent);
79 
88  virtual void OnMouseMoved(StateMachineAction *, InteractionEvent *interactionEvent);
89 
93  virtual void OnMouseReleased(StateMachineAction *, InteractionEvent *interactionEvent);
94 
100  template <typename TPixel, unsigned int imageDimension>
101  void GetNeighborhoodAverage(const itk::Image<TPixel, imageDimension> *itkImage,
102  const itk::Index<imageDimension>& index,
103  ScalarType *result,
104  unsigned int neighborhood = 1);
105 
109  template <typename TPixel, unsigned int imageDimension>
110  void StartRegionGrowing(const itk::Image<TPixel, imageDimension> *itkImage,
111  const itk::Index<imageDimension>& seedPoint,
112  const std::array<ScalarType, 2>& thresholds,
113  mitk::Image::Pointer &outputImage);
114 
118  template <typename TPixel, unsigned int imageDimension>
119  void CalculateInitialThresholds(const itk::Image<TPixel, imageDimension>* itkImage);
120 
121  Image::Pointer m_ReferenceSlice;
122  Image::Pointer m_WorkingSlice;
123 
125  itk::Index<3> m_SeedPoint;
126  std::array<ScalarType, 2> m_ThresholdExtrema;
127  std::array<ScalarType, 2> m_Thresholds;
128  std::array<ScalarType, 2> m_InitialThresholds;
132 
133  private:
134  ScalarType m_MouseDistanceScaleFactor;
135  int m_PaintingPixelValue;
136  bool m_FillFeedbackContour;
137  int m_ConnectedComponentValue;
138  };
139 
140 } // namespace
141 
142 #endif
#define MITKSEGMENTATION_EXPORT
Base class for tools that use a contour for feedback.
Base class for all interaction events in MITK.
AlgorithmType
Enumeration describing how a label was created or refined.
Definition: mitkLabel.h:283
A slice based region growing tool.
mitk::Label::AlgorithmType GetAlgorithmType() const override
Intensity region-growing from a seed determines the affected pixels, so SEMIAUTOMATIC.
virtual void OnMouseMoved(StateMachineAction *, InteractionEvent *interactionEvent)
Called when the user moves the mouse with the left button pressed. Adjusts thresholds.
mitkClassMacro(RegionGrowingTool, FeedbackContourTool)
us::ModuleResource GetCursorIconResource() const override
Returns the cursor icon of the tool wrapped by a usModuleResource.
std::array< ScalarType, 2 > m_Thresholds
void GetNeighborhoodAverage(const itk::Image< TPixel, imageDimension > *itkImage, const itk::Index< imageDimension > &index, ScalarType *result, unsigned int neighborhood=1)
Calculates average pixel value around index using a square/cube neighborhood.
void Deactivated() override
Called when the tool gets deactivated.
const char * GetName() const override
Returns the name of this tool. Make it short!
void CalculateInitialThresholds(const itk::Image< TPixel, imageDimension > *itkImage)
Calculates the initial thresholds for region growing based on the seed point.
us::ModuleResource GetIconResource() const override
Returns the tool button icon of the tool wrapped by a usModuleResource.
std::array< ScalarType, 2 > m_InitialThresholds
void Activated() override
Called when the tool gets activated.
virtual void OnMouseReleased(StateMachineAction *, InteractionEvent *interactionEvent)
Called when the mouse button is released. Converts the feedback contour to a segmentation.
virtual void OnMousePressed(StateMachineAction *, InteractionEvent *interactionEvent)
Called when the user clicks. Initiates region growing.
void StartRegionGrowing(const itk::Image< TPixel, imageDimension > *itkImage, const itk::Index< imageDimension > &seedPoint, const std::array< ScalarType, 2 > &thresholds, mitk::Image::Pointer &outputImage)
Calls an ITK filter to perform the region growing.
void ConnectActionsAndFunctions() override
std::array< ScalarType, 2 > m_ThresholdExtrema
~RegionGrowingTool() override
Represents an action that is executed after a certain event in the state machine mechanism.
Represents a resource (text file, image, etc.) embedded in a CppMicroServices module.
Find image slices visible on a given plane.
double ScalarType
Scalar type used throughout MITK for geometric computations.