Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
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);
64  itkCloneMacro(Self);
65 
67  void GenerateData() override;
68 
71  void SetInput(const InputImageType *input) override
72  {
73  // processObject is not const-correct so a const_cast is needed here
74  this->ProcessObject::SetNthInput(0, const_cast<InputImageType *>(input));
75  m_DilateImageFilter->SetInput(input);
76  }
77 
78  using Superclass::SetInput;
79  void SetInput(unsigned int i, const TInputImage *image) override
80  {
81  if (i != 0)
82  {
83  itkExceptionMacro(<< "Filter has only one input.");
84  }
85  else
86  {
87  this->SetInput(image);
88  }
89  }
90 
91  itkGetMacro(ClosingRadius, float);
92  itkSetMacro(ClosingRadius, float);
93 
94  itkGetMacro(SurfaceRatio, float);
95  itkSetMacro(SurfaceRatio, float);
96 
97  protected:
100  void PrintSelf(std::ostream &os, Indent indent) const override;
101 
102  private:
103  typedef typename InputImageType::PixelType InputPixelType;
104  typedef BinaryBallStructuringElement<InputPixelType, ImageDimension> StructuringElementType;
105  typedef BinaryErodeImageFilter<InputImageType, InputImageType, StructuringElementType> BinaryErodeImageFilterType;
106  typedef BinaryDilateImageFilter<InputImageType, InputImageType, StructuringElementType> BinaryDilateImageFilterType;
107  typedef SubtractImageFilter<InputImageType, InputImageType, InputImageType> SubtractImageFilterType;
108  typedef ConnectedComponentImageFilter<InputImageType, OutputImageType> ConnectedComponentImageFilterType;
109  typedef RelabelComponentImageFilter<OutputImageType, OutputImageType> RelabelComponentImageFilterType;
110  typedef GrayscaleDilateImageFilter<OutputImageType, OutputImageType, StructuringElementType>
111  DilateComponentImageFilterType;
112  typedef ImageRegionIterator<InputImageType> InputIteratorType;
113  typedef ImageRegionConstIterator<InputImageType> ConstInputIteratorType;
114  typedef ImageRegionIterator<OutputImageType> OutputIteratorType;
115 
116  typename BinaryErodeImageFilterType::Pointer m_ErodeImageFilter;
117  typename BinaryDilateImageFilterType::Pointer m_DilateImageFilter;
118  typename SubtractImageFilterType::Pointer m_SubtractImageFilter;
119  typename ConnectedComponentImageFilterType::Pointer m_ConnectedComponentImageFilter;
120  typename RelabelComponentImageFilterType::Pointer m_RelabelComponentImageFilter;
121  typename DilateComponentImageFilterType::Pointer m_BorderDetectionDilateFilter;
122  // typename BinaryDilateImageFilterType::Pointer m_BorderAdjacencyDilateFilter;
123  float m_ClosingRadius;
124  float m_SurfaceRatio;
125  };
126 
127 } // end namespace itk
128 
129 #ifndef ITK_MANUAL_INSTANTIATION
130 #include "itkIntelligentBinaryClosingFilter.txx"
131 
132 #endif
133 
134 #endif // IntelligentBinaryClosingFilter_h
itk::IntelligentBinaryClosingFilter::~IntelligentBinaryClosingFilter
~IntelligentBinaryClosingFilter() override
Definition: itkIntelligentBinaryClosingFilter.h:99
itk::IntelligentBinaryClosingFilter::OutputImageType
TOutputImage OutputImageType
Definition: itkIntelligentBinaryClosingFilter.h:51
itk::IntelligentBinaryClosingFilter::Superclass
ImageToImageFilter< InputImageType, OutputImageType > Superclass
Definition: itkIntelligentBinaryClosingFilter.h:54
itk::SmartPointer< Self >
itk::IntelligentBinaryClosingFilter::Pointer
SmartPointer< Self > Pointer
Definition: itkIntelligentBinaryClosingFilter.h:57
itk::IntelligentBinaryClosingFilter::Self
IntelligentBinaryClosingFilter Self
Definition: itkIntelligentBinaryClosingFilter.h:42
itk::IntelligentBinaryClosingFilter::InputImageType
TInputImage InputImageType
Definition: itkIntelligentBinaryClosingFilter.h:45
itk::IntelligentBinaryClosingFilter
Definition: itkIntelligentBinaryClosingFilter.h:38
itk::IntelligentBinaryClosingFilter::SetInput
void SetInput(unsigned int i, const TInputImage *image) override
Definition: itkIntelligentBinaryClosingFilter.h:79
itk::IntelligentBinaryClosingFilter::SetInput
void SetInput(const InputImageType *input) override
Definition: itkIntelligentBinaryClosingFilter.h:71
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30