Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef mitkMorphologicalOperations_h
18 #define mitkMorphologicalOperations_h
19 
21 #include <mitkImage.h>
22 
23 namespace mitk
24 {
28  {
29  public:
31  {
32  Ball = 7,
33  Ball_Axial = 1,
34  Ball_Sagital = 2,
35  Ball_Coronal = 4,
36 
37  Cross = 56,
38  Cross_Axial = 8,
39  Cross_Sagital = 16,
40  Cross_Coronal = 32
41 
42  };
43 
45 
47  static void Closing(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement);
48  static void Erode(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement);
49  static void Dilate(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement);
50  static void Opening(mitk::Image::Pointer &image, int factor, StructuralElementType structuralElement);
51  static void FillHoles(mitk::Image::Pointer &image);
53 
54  private:
56 
57  template <class TStructuringElement>
58  static TStructuringElement CreateStructuringElement(StructuralElementType structuralElementFlag, int factor)
59  {
60  TStructuringElement strElem;
61  typename TStructuringElement::SizeType size;
62  size.Fill(0);
63  switch (structuralElementFlag)
64  {
65  case Ball_Axial:
66  case Cross_Axial:
67  size.SetElement(0, factor);
68  size.SetElement(1, factor);
69  break;
70  case Ball_Coronal:
71  case Cross_Coronal:
72  size.SetElement(0, factor);
73  size.SetElement(2, factor);
74  break;
75  case Ball_Sagital:
76  case Cross_Sagital:
77  size.SetElement(1, factor);
78  size.SetElement(2, factor);
79  break;
80  case Ball:
81  case Cross:
82  size.Fill(factor);
83  break;
84  }
85 
86  strElem.SetRadius(size);
87  strElem.CreateStructuringElement();
88  return strElem;
89  }
90 
92 
94  template <typename TPixel, unsigned int VDimension>
95  void static itkClosing(itk::Image<TPixel, VDimension> *sourceImage,
96  mitk::Image::Pointer &resultImage,
97  int factor,
98  StructuralElementType structuralElement);
99 
100  template <typename TPixel, unsigned int VDimension>
101  void static itkErode(itk::Image<TPixel, VDimension> *sourceImage,
102  mitk::Image::Pointer &resultImage,
103  int factor,
104  StructuralElementType structuralElement);
105 
106  template <typename TPixel, unsigned int VDimension>
107  void static itkDilate(itk::Image<TPixel, VDimension> *sourceImage,
108  mitk::Image::Pointer &resultImage,
109  int factor,
110  StructuralElementType structuralElement);
111 
112  template <typename TPixel, unsigned int VDimension>
113  void static itkOpening(itk::Image<TPixel, VDimension> *sourceImage,
114  mitk::Image::Pointer &resultImage,
115  int factor,
116  StructuralElementType structuralElement);
117 
118  template <typename TPixel, unsigned int VDimension>
119  void static itkFillHoles(itk::Image<TPixel, VDimension> *sourceImage, mitk::Image::Pointer &resultImage);
121  };
122 }
123 
124 #endif
Encapsulates several morphological operations that can be performed on segmentations.
#define MITKSEGMENTATION_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.