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>
27#include "itkConceptChecking.h"
28
29namespace itk
30{
102template <typename TInputImage, typename TOutputImage, typename TKernel>
103class ITK_TEMPLATE_EXPORT BinaryMorphologyImageFilter : public KernelImageFilter<TInputImage, TOutputImage, TKernel>
104{
105public:
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
186protected:
188 ~BinaryMorphologyImageFilter() override = default;
189 void
190 PrintSelf(std::ostream & os, Indent indent) const override;
191
194 void
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
235private:
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
Base class for fast binary dilation and erosion.
void PrintSelf(std::ostream &os, Indent indent) const override
typename InputImageType::SizeType InputSizeType
typename KernelType::ConstIterator KernelIteratorType
ComponentVectorConstIterator KernelCCVectorEnd()
typename InputImageType::SizeValueType InputSizeValueType
~BinaryMorphologyImageFilter() override=default
ComponentVectorConstIterator KernelCCVectorBegin()
typename ComponentVectorType::const_iterator ComponentVectorConstIterator
std::vector< NeighborIndexContainer > NeighborIndexContainerContainer
typename NumericTraits< InputPixelType >::RealType InputRealType
void SetKernel(const KernelType &kernel) override
typename InputImageType::IndexValueType IndexValueType
NeighborIndexContainer & GetDifferenceSet(unsigned int code)
typename TInputImage::PixelType InputPixelType
typename TInputImage::IndexType IndexType
typename TOutputImage::PixelType OutputPixelType
typename TInputImage::OffsetType OffsetType
Base class for all process objects that output image data.
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename InputImageType::RegionType InputImageRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
A base class for all the filters working on an arbitrary shaped neighborhood.
Define additional traits for native types such as int or float.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
long IndexValueType
Definition: itkIntTypes.h:93
unsigned long SizeValueType
Definition: itkIntTypes.h:86