ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkBinaryMorphologyImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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:
104  public KernelImageFilter< TInputImage, TOutputImage, TKernel >
105 {
106 public:
107  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryMorphologyImageFilter);
109 
111  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
112  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
113 
115  static constexpr unsigned int KernelDimension = TKernel::NeighborhoodDimension;
116 
118  using InputImageType = TInputImage;
119  using OutputImageType = TOutputImage;
120 
126 
128  itkNewMacro(Self);
129 
132 
134  using KernelType = TKernel;
135 
137  using KernelIteratorType = typename KernelType::ConstIterator;
138 
140  using InputPixelType = typename InputImageType::PixelType;
141  using OutputPixelType = typename OutputImageType::PixelType;
143  using OffsetType = typename InputImageType::OffsetType;
146 
151 
153  itkConceptMacro( ImageDimensionCheck,
154  ( Concept::SameDimension< Self::InputImageDimension,
155  Self::OutputImageDimension > ) );
156 
160  itkSetMacro(ForegroundValue, InputPixelType);
161 
164  itkGetConstMacro(ForegroundValue, InputPixelType);
165 
170  itkSetMacro(BackgroundValue, OutputPixelType);
171 
176  itkGetConstMacro(BackgroundValue, OutputPixelType);
177 
180  itkSetMacro(BoundaryToForeground, bool);
181  itkGetConstReferenceMacro(BoundaryToForeground, bool);
182  itkBooleanMacro(BoundaryToForeground);
184 
186  void SetKernel(const KernelType & kernel) override;
187 
188 protected:
190  ~BinaryMorphologyImageFilter() override = default;
191  void PrintSelf(std::ostream & os, Indent indent) const override;
192 
195  void 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  { return m_KernelDifferenceSets[code]; }
213 
217  { return m_KernelCCVector.begin(); }
218 
222  { return m_KernelCCVector.end(); }
223 
225 
226 private:
229 
232 
235 
239  std::vector< OffsetType > m_KernelCCVector;
240 };
241 } // end namespace itk
242 
243 #ifndef ITK_MANUAL_INSTANTIATION
244 #include "itkBinaryMorphologyImageFilter.hxx"
245 #endif
246 
247 #endif
typename KernelType::ConstIterator KernelIteratorType
ComponentVectorConstIterator KernelCCVectorEnd()
Define numeric traits for std::vector.
typename NumericTraits< InputPixelType >::RealType InputRealType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename TInputImage::IndexType IndexType
typename TOutputImage::PixelType OutputPixelType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
NeighborIndexContainerContainer m_KernelDifferenceSets
Base class for all process objects that output image data.
NeighborIndexContainer & GetDifferenceSet(unsigned int code)
typename InputImageType::SizeValueType InputSizeValueType
typename TInputImage::OffsetType OffsetType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename TInputImage::PixelType InputPixelType
A base class for all the filters working on an arbitrary shaped neighborhood.
signed long IndexValueType
Definition: itkIntTypes.h:90
typename ComponentVectorType::const_iterator ComponentVectorConstIterator
typename InputImageType::RegionType InputImageRegionType
std::vector< NeighborIndexContainer > NeighborIndexContainerContainer
Base class for filters that take an image as input and produce an image as output.
Base class for fast binary dilation and erosion.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename InputImageType::IndexValueType IndexValueType
ComponentVectorConstIterator KernelCCVectorBegin()
typename InputImageType::SizeType InputSizeType
#define itkConceptMacro(name, concept)