ITK  6.0.0
Insight Toolkit
itkBinaryMorphologyImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkBinaryMorphologyImageFilter_h
19 #define itkBinaryMorphologyImageFilter_h
20 
21 #include <vector>
22 #include <queue>
23 #include "itkKernelImageFilter.h"
26 #include "itkImageRegionIterator.h"
27 #include "itkConceptChecking.h"
28 
29 namespace itk
30 {
102 template <typename TInputImage, typename TOutputImage, typename TKernel>
103 class ITK_TEMPLATE_EXPORT BinaryMorphologyImageFilter : public KernelImageFilter<TInputImage, TOutputImage, TKernel>
104 {
105 public:
106  ITK_DISALLOW_COPY_AND_MOVE(BinaryMorphologyImageFilter);
110  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
111  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
112 
114  static constexpr unsigned int KernelDimension = TKernel::NeighborhoodDimension;
115 
117  using InputImageType = TInputImage;
118  using OutputImageType = TOutputImage;
119 
125 
127  itkNewMacro(Self);
128 
130  itkOverrideGetNameOfClassMacro(BinaryMorphologyImageFilter);
131 
133  using KernelType = TKernel;
134 
136  using KernelIteratorType = typename KernelType::ConstIterator;
137 
139  using InputPixelType = typename InputImageType::PixelType;
140  using OutputPixelType = typename OutputImageType::PixelType;
142  using OffsetType = typename InputImageType::OffsetType;
145 
150 
153 
157  itkSetMacro(ForegroundValue, InputPixelType);
158 
161  itkGetConstMacro(ForegroundValue, InputPixelType);
162 
167  itkSetMacro(BackgroundValue, OutputPixelType);
168 
173  itkGetConstMacro(BackgroundValue, OutputPixelType);
174 
177  itkSetMacro(BoundaryToForeground, bool);
178  itkGetConstReferenceMacro(BoundaryToForeground, bool);
179  itkBooleanMacro(BoundaryToForeground);
183  void
184  SetKernel(const KernelType & kernel) override;
185 
186 protected:
188  ~BinaryMorphologyImageFilter() override = default;
189  void
190  PrintSelf(std::ostream & os, Indent indent) const override;
191 
194  void
195  AnalyzeKernel();
196 
198  using NeighborIndexContainer = std::vector<OffsetType>;
199 
201  using NeighborIndexContainerContainer = std::vector<NeighborIndexContainer>;
202 
204  using ComponentVectorType = std::vector<OffsetType>;
205 
207  using ComponentVectorConstIterator = typename ComponentVectorType::const_iterator;
208 
212  GetDifferenceSet(unsigned int code)
213  {
214  return m_KernelDifferenceSets[code];
215  }
216 
219  ComponentVectorConstIterator
221  {
222  return m_KernelCCVector.begin();
223  }
224 
227  ComponentVectorConstIterator
229  {
230  return m_KernelCCVector.end();
231  }
232 
233  bool m_BoundaryToForeground{};
234 
235 private:
237  InputPixelType m_ForegroundValue{};
238 
240  OutputPixelType m_BackgroundValue{};
241 
243  NeighborIndexContainerContainer m_KernelDifferenceSets{};
244 
248  std::vector<OffsetType> m_KernelCCVector{};
249 };
250 } // end namespace itk
251 
252 #ifndef ITK_MANUAL_INSTANTIATION
253 # include "itkBinaryMorphologyImageFilter.hxx"
254 #endif
255 
256 #endif
itk::BinaryMorphologyImageFilter::KernelIteratorType
typename KernelType::ConstIterator KernelIteratorType
Definition: itkBinaryMorphologyImageFilter.h:136
itk::BoxImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkBoxImageFilter.h:67
itkNeighborhoodIterator.h
itk::BinaryMorphologyImageFilter::KernelCCVectorBegin
ComponentVectorConstIterator KernelCCVectorBegin()
Definition: itkBinaryMorphologyImageFilter.h:220
itk::BinaryMorphologyImageFilter::ComponentVectorType
std::vector< OffsetType > ComponentVectorType
Definition: itkBinaryMorphologyImageFilter.h:204
itkConceptChecking.h
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itkImageRegionIterator.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::BoxImageFilter::OffsetType
typename TInputImage::OffsetType OffsetType
Definition: itkBoxImageFilter.h:62
itk::IndexValueType
long IndexValueType
Definition: itkIntTypes.h:93
itk::Concept::SameDimension
Definition: itkConceptChecking.h:697
itkImageBoundaryCondition.h
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itkKernelImageFilter.h
itk::BoxImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkBoxImageFilter.h:64
itk::BoxImageFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkBoxImageFilter.h:61
itk::BinaryMorphologyImageFilter::InputSizeType
typename InputImageType::SizeType InputSizeType
Definition: itkBinaryMorphologyImageFilter.h:148
itk::BinaryMorphologyImageFilter::IndexValueType
typename InputImageType::IndexValueType IndexValueType
Definition: itkBinaryMorphologyImageFilter.h:144
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::BinaryMorphologyImageFilter::ComponentVectorConstIterator
typename ComponentVectorType::const_iterator ComponentVectorConstIterator
Definition: itkBinaryMorphologyImageFilter.h:207
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::BinaryMorphologyImageFilter::InputSizeValueType
typename InputImageType::SizeValueType InputSizeValueType
Definition: itkBinaryMorphologyImageFilter.h:149
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::BinaryMorphologyImageFilter::GetDifferenceSet
NeighborIndexContainer & GetDifferenceSet(unsigned int code)
Definition: itkBinaryMorphologyImageFilter.h:212
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::BinaryMorphologyImageFilter::NeighborIndexContainer
std::vector< OffsetType > NeighborIndexContainer
Definition: itkBinaryMorphologyImageFilter.h:198
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::KernelImageFilter::KernelType
TKernel KernelType
Definition: itkKernelImageFilter.h:71
itk::BinaryMorphologyImageFilter::KernelCCVectorEnd
ComponentVectorConstIterator KernelCCVectorEnd()
Definition: itkBinaryMorphologyImageFilter.h:228
itk::KernelImageFilter
A base class for all the filters working on an arbitrary shaped neighborhood.
Definition: itkKernelImageFilter.h:41
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::BinaryMorphologyImageFilter
Base class for fast binary dilation and erosion.
Definition: itkBinaryMorphologyImageFilter.h:103
itk::BinaryMorphologyImageFilter::InputRealType
typename NumericTraits< InputPixelType >::RealType InputRealType
Definition: itkBinaryMorphologyImageFilter.h:141
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::BinaryMorphologyImageFilter::NeighborIndexContainerContainer
std::vector< NeighborIndexContainer > NeighborIndexContainerContainer
Definition: itkBinaryMorphologyImageFilter.h:201