Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkIntelligentBinaryClosingFilter.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 #ifndef __itkIntelligentBinaryClosingFilter_h
17 #define __itkIntelligentBinaryClosingFilter_h
18 
19 #if defined(_MSC_VER)
20 #pragma warning(disable : 4786)
21 #endif
22 
23 #include <itkBinaryBallStructuringElement.h>
24 #include <itkBinaryDilateImageFilter.h>
25 #include <itkBinaryErodeImageFilter.h>
26 #include <itkConnectedComponentImageFilter.h>
27 #include <itkConnectedComponentImageFilter.h>
28 #include <itkGrayscaleDilateImageFilter.h>
29 #include <itkImageRegionIterator.h>
30 #include <itkImageToImageFilter.h>
31 #include <itkRelabelComponentImageFilter.h>
32 #include <itkSubtractImageFilter.h>
33 
34 namespace itk
35 {
41  template <class TInputImage, class TOutputImage>
42  class ITK_EXPORT IntelligentBinaryClosingFilter : public ImageToImageFilter<TInputImage, TOutputImage>
43  {
44  public:
47 
49  typedef TInputImage InputImageType;
50 
52  itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
53 
55  typedef TOutputImage OutputImageType;
56 
58  typedef ImageToImageFilter<InputImageType, OutputImageType> Superclass;
59 
62 
64  itkTypeMacro(IntelligentBinaryClosingFilter, ImageToImageFilter);
65 
67  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
68 
70  void GenerateData();
71 
74  void SetInput(const InputImageType *input)
75  {
76  // processObject is not const-correct so a const_cast is needed here
77  this->ProcessObject::SetNthInput(0, const_cast<InputImageType *>(input));
78  m_DilateImageFilter->SetInput(const_cast<InputImageType *>(input));
79  }
80 
81  using Superclass::SetInput;
82  virtual void SetInput(unsigned int i, const TInputImage *image)
83  {
84  if (i != 0)
85  {
86  itkExceptionMacro(<< "Filter has only one input.");
87  }
88  else
89  {
90  this->SetInput(image);
91  }
92  }
93 
94  itkGetMacro(ClosingRadius, float);
95  itkSetMacro(ClosingRadius, float);
96 
97  itkGetMacro(SurfaceRatio, float);
98  itkSetMacro(SurfaceRatio, float);
99 
100  protected:
104  void operator=(const Self &) {}
105  void PrintSelf(std::ostream &os, Indent indent) const;
106 
107  private:
108  typedef typename InputImageType::PixelType InputPixelType;
109  typedef BinaryBallStructuringElement<InputPixelType, ImageDimension> StructuringElementType;
110  typedef BinaryErodeImageFilter<InputImageType, InputImageType, StructuringElementType> BinaryErodeImageFilterType;
111  typedef BinaryDilateImageFilter<InputImageType, InputImageType, StructuringElementType> BinaryDilateImageFilterType;
112  typedef SubtractImageFilter<InputImageType, InputImageType, InputImageType> SubtractImageFilterType;
113  typedef ConnectedComponentImageFilter<InputImageType, OutputImageType> ConnectedComponentImageFilterType;
114  typedef RelabelComponentImageFilter<OutputImageType, OutputImageType> RelabelComponentImageFilterType;
115  typedef GrayscaleDilateImageFilter<OutputImageType, OutputImageType, StructuringElementType>
116  DilateComponentImageFilterType;
117  typedef ImageRegionIterator<InputImageType> InputIteratorType;
118  typedef ImageRegionConstIterator<InputImageType> ConstInputIteratorType;
119  typedef ImageRegionIterator<OutputImageType> OutputIteratorType;
120 
121  typename BinaryErodeImageFilterType::Pointer m_ErodeImageFilter;
122  typename BinaryDilateImageFilterType::Pointer m_DilateImageFilter;
123  typename SubtractImageFilterType::Pointer m_SubtractImageFilter;
124  typename ConnectedComponentImageFilterType::Pointer m_ConnectedComponentImageFilter;
125  typename RelabelComponentImageFilterType::Pointer m_RelabelComponentImageFilter;
126  typename DilateComponentImageFilterType::Pointer m_BorderDetectionDilateFilter;
127  // typename BinaryDilateImageFilterType::Pointer m_BorderAdjacencyDilateFilter;
128  float m_ClosingRadius;
129  float m_SurfaceRatio;
130  };
131 
132 } // end namespace itk
133 
134 #ifndef ITK_MANUAL_INSTANTIATION
136 
137 #endif
138 
139 #endif // IntelligentBinaryClosingFilter_h
itk::SmartPointer< Self > Pointer
virtual void SetInput(unsigned int i, const TInputImage *image)
ImageToImageFilter< InputImageType, OutputImageType > Superclass
unsigned short PixelType
double InputPixelType