ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkConnectedComponentImageFilter.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 itkConnectedComponentImageFilter_h
19 #define itkConnectedComponentImageFilter_h
20 
22 
23 namespace itk
24 {
56 template< typename TInputImage, typename TOutputImage, typename TMaskImage = TInputImage >
57 class ITK_TEMPLATE_EXPORT ConnectedComponentImageFilter:
58  public ImageToImageFilter< TInputImage, TOutputImage >
59  , protected ScanlineFilterCommon< TInputImage, TOutputImage >
60 {
61 public:
62  ITK_DISALLOW_COPY_AND_ASSIGN(ConnectedComponentImageFilter);
63 
69  using Superclass::Register;
70  using Superclass::UnRegister;
71 
75  using InputImagePointer = typename Superclass::InputImagePointer;
76 
81  using OutputPixelType = typename TOutputImage::PixelType;
82  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
83  using InputPixelType = typename TInputImage::PixelType;
84  using InputInternalPixelType = typename TInputImage::InternalPixelType;
85  using MaskPixelType = typename TMaskImage::PixelType;
86  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
87  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
88  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
89 
93  using InputImageType = TInputImage;
94  using MaskImageType = TMaskImage;
96  using SizeType = typename TInputImage::SizeType;
97  using OffsetType = typename TInputImage::OffsetType;
98 
99  using OutputImageType = TOutputImage;
103  using OutputOffsetType = typename TOutputImage::OffsetType;
104  using OutputImagePixelType = typename TOutputImage::PixelType;
105 
106  using ListType = std::list< IndexType >;
107  using MaskImagePointer = typename MaskImageType::Pointer;
108 
114 
119 
123  itkNewMacro(Self);
124 
131  itkSetMacro(FullyConnected, bool);
132  itkGetConstReferenceMacro(FullyConnected, bool);
133  itkBooleanMacro(FullyConnected);
135 
138 
139  // only set after completion
140  itkGetConstReferenceMacro(ObjectCount, LabelType);
141 
142  itkConceptMacro( OutputImagePixelTypeIsInteger, ( Concept::IsInteger< OutputImagePixelType > ) );
143 
144  itkSetInputMacro(MaskImage, MaskImageType);
145  itkGetInputMacro(MaskImage, MaskImageType);
146 
152  itkSetMacro(BackgroundValue, OutputImagePixelType);
153  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
155 
156 protected:
158  ScanlineFilterCommon< TInputImage, TOutputImage >(this),
159  m_BackgroundValue( NumericTraits< OutputPixelType >::NonpositiveMin() )
160  {
161  m_ObjectCount = 0;
162 
163  // implicit
164  // #0 "Primary" required
165 
166  // #1 "MaskImage" optional
167  Self::AddOptionalInputName("MaskImage",1);
168  }
169 
170  ~ConnectedComponentImageFilter() override = default;
171  void PrintSelf(std::ostream & os, Indent indent) const override;
172 
173  void GenerateData() override;
174 
175  void DynamicThreadedGenerateData( const RegionType & ) override;
176 
177  void ThreadedWriteOutput( const RegionType & );
178 
182  void GenerateInputRequestedRegion() override;
183 
188  void EnlargeOutputRequestedRegion( DataObject * itkNotUsed(output) ) override;
189 
191 
204 
205 private:
208 
209  typename TInputImage::ConstPointer m_Input;
210 };
211 } // end namespace itk
212 
213 #ifndef ITK_MANUAL_INSTANTIATION
214 #if !defined( ITK_WRAPPING_PARSER )
215 #include "itkConnectedComponentImageFilter.hxx"
216 #endif
217 #endif
218 
219 #endif
typename TOutputImage::PixelType OutputPixelType
typename ScanlineFunctions::RunLength RunLength
Define numeric traits for std::vector.
typename TOutputImage::IndexType OutputIndexType
typename LineEncodingType::iterator LineEncodingIterator
std::vector< RunLength > LineEncodingType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename TInputImage::InternalPixelType InputInternalPixelType
Helper class for a group of filters which operate on scan-lines.
typename TOutputImage::OffsetType OutputOffsetType
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::Pointer InputImagePointer
typename ScanlineFunctions::WorkUnitData WorkUnitData
typename TOutputImage::InternalPixelType OutputInternalPixelType
typename OffsetVectorType::const_iterator OffsetVectorConstIterator
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
typename MaskImageType::Pointer MaskImagePointer
TOutputImage OutputImageType
typename TInputImage::OffsetType OffsetType
typename TOutputImage::RegionType::SizeType OutSizeType
std::vector< OutputPixelType > ConsecutiveVectorType
std::vector< OffsetValueType > OffsetVectorType
typename TOutputImage::SizeType OutputSizeType
Base class for filters that take an image as input and produce an image as output.
std::vector< LineEncodingType > LineMapType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename TInputImage::SizeType SizeType
typename LineEncodingType::const_iterator LineEncodingConstIterator
#define itkConceptMacro(name, concept)
typename TInputImage::PixelType InputPixelType
typename TInputImage::IndexType IndexType
Base class for all data objects in ITK.
std::vector< InternalLabelType > UnionFindType
Label the objects in a binary image.