Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkMorphologicalOperations.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 mitkMorphologicalOperations_h
14 #define mitkMorphologicalOperations_h
15 
17 #include <mitkImage.h>
18 
19 namespace mitk
20 {
34  {
35  public:
42  {
43  Ball = 7,
44  Ball_Axial = 1,
45  Ball_Sagittal = 2,
46  Ball_Coronal = 4,
48  Cross = 56,
49  Cross_Axial = 8,
50  Cross_Sagittal = 16,
51  Cross_Coronal = 32
52  };
53 
55 
61  static void Closing(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement);
62 
69  static void Erode(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement);
70 
77  static void Dilate(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement);
78 
85  static void Opening(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement);
86 
91  static void FillHoles(mitk::Image::Pointer &image);
93 
94  private:
96 
97  template <class TStructuringElement>
98  static TStructuringElement CreateStructuringElement(StructuralElementType structuralElementFlag, int factor);
99 
101 
103  template <typename TPixel, unsigned int VDimension>
104  static void itkClosing(itk::Image<TPixel, VDimension> *sourceImage,
105  mitk::Image::Pointer &resultImage,
106  int factor,
107  StructuralElementType structuralElement);
108 
109  template <typename TPixel, unsigned int VDimension>
110  static void itkErode(itk::Image<TPixel, VDimension> *sourceImage,
111  mitk::Image::Pointer &resultImage,
112  int factor,
113  StructuralElementType structuralElement);
114 
115  template <typename TPixel, unsigned int VDimension>
116  static void itkDilate(itk::Image<TPixel, VDimension> *sourceImage,
117  mitk::Image::Pointer &resultImage,
118  int factor,
119  StructuralElementType structuralElement);
120 
121  template <typename TPixel, unsigned int VDimension>
122  static void itkOpening(itk::Image<TPixel, VDimension> *sourceImage,
123  mitk::Image::Pointer &resultImage,
124  int factor,
125  StructuralElementType structuralElement);
126 
127  template <typename TPixel, unsigned int VDimension>
128  static void itkFillHoles(itk::Image<TPixel, VDimension> *sourceImage, mitk::Image::Pointer &resultImage);
130  };
131 }
132 
133 #endif
#define MITKSEGMENTATION_EXPORT
Provides morphological operations for binary segmentation images.
static void Closing(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement)
Performs a morphological closing on a 2D, 3D, or 3D+t segmentation image.
static void Dilate(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement)
Performs a morphological dilation on a 2D, 3D, or 3D+t segmentation image.
static void Opening(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement)
Performs a morphological opening on a 2D, 3D, or 3D+t segmentation image.
static void Erode(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement)
Performs a morphological erosion on a 2D, 3D, or 3D+t segmentation image.
static void FillHoles(mitk::Image::Pointer &image)
Fills holes in a binary 2D, 3D, or 3D+t segmentation image.
StructuralElementType
Defines the type and orientation of the structuring element.
Find image slices visible on a given plane.