Medical Imaging Interaction Toolkit  2025.12.02
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 
56  const char **GetXPM() const override;
59 
60  const char *GetName() const override;
61 
62  protected:
63  RegionGrowingTool(); // purposely hidden
64  ~RegionGrowingTool() override;
65 
66  void ConnectActionsAndFunctions() override;
67 
68  void Activated() override;
69  void Deactivated() override;
70 
75  virtual void OnMousePressed(StateMachineAction *, InteractionEvent *interactionEvent);
76 
85  virtual void OnMouseMoved(StateMachineAction *, InteractionEvent *interactionEvent);
86 
90  virtual void OnMouseReleased(StateMachineAction *, InteractionEvent *interactionEvent);
91 
96  template <typename TPixel, unsigned int imageDimension>
97  void GetNeighborhoodAverage(const itk::Image<TPixel, imageDimension> *itkImage,
98  const itk::Index<imageDimension>& index,
99  ScalarType *result,
100  unsigned int neighborhood = 1);
101 
105  template <typename TPixel, unsigned int imageDimension>
106  void StartRegionGrowing(const itk::Image<TPixel, imageDimension> *itkImage,
107  const itk::Index<imageDimension>& seedPoint,
108  const std::array<ScalarType, 2>& thresholds,
109  mitk::Image::Pointer &outputImage);
110 
114  template <typename TPixel, unsigned int imageDimension>
115  void CalculateInitialThresholds(const itk::Image<TPixel, imageDimension>* itkImage);
116 
119 
121  itk::Index<3> m_SeedPoint;
122  std::array<ScalarType, 2> m_ThresholdExtrema;
123  std::array<ScalarType, 2> m_Thresholds;
124  std::array<ScalarType, 2> m_InitialThresholds;
128 
129  private:
130  ScalarType m_MouseDistanceScaleFactor;
131  int m_PaintingPixelValue;
132  bool m_FillFeedbackContour;
133  int m_ConnectedComponentValue;
134  };
135 
136 } // namespace
137 
138 #endif
#define MITKSEGMENTATION_EXPORT
Base class for tools that use a contour for feedback.
A slice based region growing tool.
const char ** GetXPM() const override
Returns an icon in the XPM format.
virtual void OnMouseMoved(StateMachineAction *, InteractionEvent *interactionEvent)
OnMouseMoved is called when the user moves the mouse with the left mouse button pressed....
mitkClassMacro(RegionGrowingTool, FeedbackContourTool)
us::ModuleResource GetCursorIconResource() const override
Returns the path of a cursor icon.
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)
Template to calculate average pixel value around index using a square/cube with radius 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)
Template to calculate the initial thresholds for region growing.
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)
OnMouseReleased converts the feedback contour to a segmentation.
virtual void OnMousePressed(StateMachineAction *, InteractionEvent *interactionEvent)
OnMousePressed is called when the user clicks. Grows a region by calling 'GetNeighborhoodAverage' and...
void StartRegionGrowing(const itk::Image< TPixel, imageDimension > *itkImage, const itk::Index< imageDimension > &seedPoint, const std::array< ScalarType, 2 > &thresholds, mitk::Image::Pointer &outputImage)
Template that calls an ITK filter to do 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 statemachine-mechanism) TODO: implem...
Find image slices visible on a given plane.
double ScalarType