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