ITK  5.4.0
Insight Toolkit
itkConnectedComponentImageFilter.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 itkConnectedComponentImageFilter_h
19 #define itkConnectedComponentImageFilter_h
20 
22 
23 namespace itk
24 {
58 template <typename TInputImage, typename TOutputImage, typename TMaskImage = TInputImage>
59 class ITK_TEMPLATE_EXPORT ConnectedComponentImageFilter
60  : public ImageToImageFilter<TInputImage, TOutputImage>
61  , protected ScanlineFilterCommon<TInputImage, TOutputImage>
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_MOVE(ConnectedComponentImageFilter);
65 
71  using Superclass::Register;
72  using Superclass::UnRegister;
73 
77  using typename Superclass::InputImagePointer;
78 
83  using OutputPixelType = typename TOutputImage::PixelType;
84  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
85  using InputPixelType = typename TInputImage::PixelType;
86  using InputInternalPixelType = typename TInputImage::InternalPixelType;
87  using MaskPixelType = typename TMaskImage::PixelType;
88  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
89  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
90  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
91 
95  using InputImageType = TInputImage;
96  using MaskImageType = TMaskImage;
98  using SizeType = typename TInputImage::SizeType;
99  using OffsetType = typename TInputImage::OffsetType;
100 
101  using OutputImageType = TOutputImage;
105  using OutputOffsetType = typename TOutputImage::OffsetType;
106  using OutputImagePixelType = typename TOutputImage::PixelType;
107 
108  using ListType = std::list<IndexType>;
110 
116 
121 
125  itkNewMacro(Self);
126 
133  itkSetMacro(FullyConnected, bool);
134  itkGetConstReferenceMacro(FullyConnected, bool);
135  itkBooleanMacro(FullyConnected);
140 
141  // only set after completion
142  itkGetConstReferenceMacro(ObjectCount, LabelType);
143 
144  itkConceptMacro(OutputImagePixelTypeIsInteger, (Concept::IsInteger<OutputImagePixelType>));
145 
146  itkSetInputMacro(MaskImage, MaskImageType);
147  itkGetInputMacro(MaskImage, MaskImageType);
148 
154  itkSetMacro(BackgroundValue, OutputImagePixelType);
155  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
158 protected:
160 
161  ~ConnectedComponentImageFilter() override = default;
162  void
163  PrintSelf(std::ostream & os, Indent indent) const override;
164 
165  void
166  GenerateData() override;
167 
168  void
169  DynamicThreadedGenerateData(const RegionType &) override;
170 
171  void
172  ThreadedWriteOutput(const RegionType &);
173 
177  void
178  GenerateInputRequestedRegion() override;
179 
184  void
185  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
186 
188 
201 
202 private:
204  LabelType m_ObjectCount = 0;
205 
207 };
208 } // end namespace itk
209 
210 #ifndef ITK_MANUAL_INSTANTIATION
211 # if !defined(ITK_WRAPPING_PARSER)
212 # include "itkConnectedComponentImageFilter.hxx"
213 # endif
214 #endif
215 
216 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:92
itk::ScanlineFilterCommon::LineEncodingIterator
typename LineEncodingType::iterator LineEncodingIterator
Definition: itkScanlineFilterCommon.h:128
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:93
itk::ConnectedComponentImageFilter::MaskImageType
TMaskImage MaskImageType
Definition: itkConnectedComponentImageFilter.h:96
itk::ScanlineFilterCommon::LineMapType
std::vector< LineEncodingType > LineMapType
Definition: itkScanlineFilterCommon.h:134
itk::ScanlineFilterCommon::LineEncodingType
std::vector< RunLength > LineEncodingType
Definition: itkScanlineFilterCommon.h:127
itk::ScanlineFilterCommon::RunLength
Definition: itkScanlineFilterCommon.h:114
itk::ScanlineFilterCommon::OffsetVectorType
std::vector< OffsetValueType > OffsetVectorType
Definition: itkScanlineFilterCommon.h:131
itk::ScanlineFilterCommon::OffsetType
typename TInputImage::OffsetType OffsetType
Definition: itkScanlineFilterCommon.h:87
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::ConnectedComponentImageFilter::LabelType
IdentifierType LabelType
Definition: itkConnectedComponentImageFilter.h:139
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ConnectedComponentImageFilter::m_Input
TInputImage::ConstPointer m_Input
Definition: itkConnectedComponentImageFilter.h:206
itkScanlineFilterCommon.h
itk::Concept::IsInteger
Definition: itkConceptChecking.h:875
itk::ScanlineFilterCommon::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkScanlineFilterCommon.h:77
itk::ScanlineFilterCommon::UnionFindType
std::vector< InternalLabelType > UnionFindType
Definition: itkScanlineFilterCommon.h:136
itk::ConnectedComponentImageFilter::InputInternalPixelType
typename TInputImage::InternalPixelType InputInternalPixelType
Definition: itkConnectedComponentImageFilter.h:86
itk::ConnectedComponentImageFilter::WorkUnitData
typename ScanlineFunctions::WorkUnitData WorkUnitData
Definition: itkConnectedComponentImageFilter.h:200
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::ScanlineFilterCommon::InternalLabelType
SizeValueType InternalLabelType
Definition: itkScanlineFilterCommon.h:111
itk::ScanlineFilterCommon::WorkUnitData
Definition: itkScanlineFilterCommon.h:452
itk::ScanlineFilterCommon::OutSizeType
typename TOutputImage::RegionType::SizeType OutSizeType
Definition: itkScanlineFilterCommon.h:112
itk::ConnectedComponentImageFilter::OutputInternalPixelType
typename TOutputImage::InternalPixelType OutputInternalPixelType
Definition: itkConnectedComponentImageFilter.h:84
itk::ScanlineFilterCommon::OffsetVectorConstIterator
typename OffsetVectorType::const_iterator OffsetVectorConstIterator
Definition: itkScanlineFilterCommon.h:132
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::ScanlineFilterCommon::ConsecutiveVectorType
std::vector< OutputPixelType > ConsecutiveVectorType
Definition: itkScanlineFilterCommon.h:137
itk::ScanlineFilterCommon::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkScanlineFilterCommon.h:78
itk::ScanlineFilterCommon::OutputIndexType
typename TOutputImage::IndexType OutputIndexType
Definition: itkScanlineFilterCommon.h:92
itk::ConnectedComponentImageFilter::RunLength
typename ScanlineFunctions::RunLength RunLength
Definition: itkConnectedComponentImageFilter.h:191
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:148
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk::ScanlineFilterCommon::OutputOffsetType
typename TOutputImage::OffsetType OutputOffsetType
Definition: itkScanlineFilterCommon.h:94
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ScanlineFilterCommon
Helper class for a group of filters which operate on scan-lines.
Definition: itkScanlineFilterCommon.h:41
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::ConnectedComponentImageFilter::MaskImagePointer
typename MaskImageType::Pointer MaskImagePointer
Definition: itkConnectedComponentImageFilter.h:109
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::ScanlineFilterCommon::OutputSizeType
typename TOutputImage::SizeType OutputSizeType
Definition: itkScanlineFilterCommon.h:93
itk::ScanlineFilterCommon::LineEncodingConstIterator
typename LineEncodingType::const_iterator LineEncodingConstIterator
Definition: itkScanlineFilterCommon.h:129
itk::ConnectedComponentImageFilter::ListType
std::list< IndexType > ListType
Definition: itkConnectedComponentImageFilter.h:108
itk::ConnectedComponentImageFilter
Label the objects in a binary image.
Definition: itkConnectedComponentImageFilter.h:59
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
itk::ScanlineFilterCommon::IndexType
typename TInputImage::IndexType IndexType
Definition: itkScanlineFilterCommon.h:85
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itk::ScanlineFilterCommon::RegionType
OutputRegionType RegionType
Definition: itkScanlineFilterCommon.h:91
itk::ConnectedComponentImageFilter::MaskPixelType
typename TMaskImage::PixelType MaskPixelType
Definition: itkConnectedComponentImageFilter.h:87
itk::ScanlineFilterCommon::SizeType
typename TInputImage::SizeType SizeType
Definition: itkScanlineFilterCommon.h:86