ITK  6.0.0
Insight Toolkit
itkBinaryImageToLabelMapFilter.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 itkBinaryImageToLabelMapFilter_h
19 #define itkBinaryImageToLabelMapFilter_h
20 
22 #include "itkLabelMap.h"
23 #include "itkLabelObject.h"
24 
25 namespace itk
26 {
53 template <typename TInputImage,
54  typename TOutputImage = LabelMap<LabelObject<SizeValueType, TInputImage::ImageDimension>>>
55 class ITK_TEMPLATE_EXPORT BinaryImageToLabelMapFilter
56  : public ImageToImageFilter<TInputImage, TOutputImage>
57  , protected ScanlineFilterCommon<TInputImage, TOutputImage>
58 {
59 public:
60  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLabelMapFilter);
61 
69  using Superclass::Register;
70  using Superclass::UnRegister;
71 
75  itkNewMacro(Self);
76 
80  itkOverrideGetNameOfClassMacro(BinaryImageToLabelMapFilter);
81 
85  using typename Superclass::InputImagePointer;
86 
91  using OutputPixelType = typename TOutputImage::PixelType;
92  using InputPixelType = typename TInputImage::PixelType;
95  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
96  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
97  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
98 
102  using InputImageType = TInputImage;
104  using SizeType = typename TInputImage::SizeType;
105  using OffsetType = typename TInputImage::OffsetType;
106 
107  using OutputImageType = TOutputImage;
111  using OutputOffsetType = typename TOutputImage::OffsetType;
112  using OutputImagePixelType = typename TOutputImage::PixelType;
113 
120  itkSetMacro(FullyConnected, bool);
121  itkGetConstReferenceMacro(FullyConnected, bool);
122  itkBooleanMacro(FullyConnected);
125  // only set after completion
126  itkGetConstReferenceMacro(NumberOfObjects, SizeValueType);
127 
132  itkSetMacro(OutputBackgroundValue, OutputPixelType);
133  itkGetConstMacro(OutputBackgroundValue, OutputPixelType);
140  itkSetMacro(InputForegroundValue, InputPixelType);
141  itkGetConstMacro(InputForegroundValue, InputPixelType);
144 protected:
146  ~BinaryImageToLabelMapFilter() override = default;
147  void
148  PrintSelf(std::ostream & os, Indent indent) const override;
149 
150  void
151  DynamicThreadedGenerateData(const RegionType & outputRegionForThread) override;
152 
153  void
154  GenerateData() override;
155 
159  void
160  GenerateInputRequestedRegion() override;
161 
166  void
167  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
168 
170 
183 
184 private:
185  OutputPixelType m_OutputBackgroundValue{};
186  InputPixelType m_InputForegroundValue{};
187  SizeValueType m_NumberOfObjects{};
188 };
189 } // end namespace itk
190 
191 #ifndef ITK_MANUAL_INSTANTIATION
192 # if !defined(ITK_WRAPPING_PARSER)
193 # include "itkBinaryImageToLabelMapFilter.hxx"
194 # endif
195 #endif
196 
197 #endif
itk::ScanlineFilterCommon::LineEncodingIterator
typename LineEncodingType::iterator LineEncodingIterator
Definition: itkScanlineFilterCommon.h:128
itk::BinaryImageToLabelMapFilter::RunLength
typename ScanlineFunctions::RunLength RunLength
Definition: itkBinaryImageToLabelMapFilter.h:173
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::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkScanlineFilterCommon.h
itk::BinaryImageToLabelMapFilter
Label the connected components in a binary image and produce a collection of label objects.
Definition: itkBinaryImageToLabelMapFilter.h:55
itk::ScanlineFilterCommon::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkScanlineFilterCommon.h:77
itk::ScanlineFilterCommon::UnionFindType
std::vector< InternalLabelType > UnionFindType
Definition: itkScanlineFilterCommon.h:136
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
itkLabelMap.h
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::BinaryImageToLabelMapFilter::SizeValueType
typename TInputImage::SizeValueType SizeValueType
Definition: itkBinaryImageToLabelMapFilter.h:93
itk::ScanlineFilterCommon::InternalLabelType
SizeValueType InternalLabelType
Definition: itkScanlineFilterCommon.h:111
itk::ScanlineFilterCommon::WorkUnitData
Definition: itkScanlineFilterCommon.h:451
itk::ScanlineFilterCommon::OutSizeType
typename TOutputImage::RegionType::SizeType OutSizeType
Definition: itkScanlineFilterCommon.h:112
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::OffsetValueType
long OffsetValueType
Definition: itkIntTypes.h:97
itk::ScanlineFilterCommon::ConsecutiveVectorType
std::vector< OutputPixelType > ConsecutiveVectorType
Definition: itkScanlineFilterCommon.h:137
itk::ScanlineFilterCommon::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkScanlineFilterCommon.h:78
itkLabelObject.h
itk::ScanlineFilterCommon::OutputIndexType
typename TOutputImage::IndexType OutputIndexType
Definition: itkScanlineFilterCommon.h:92
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: itkAnatomicalOrientation.h:29
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::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::BinaryImageToLabelMapFilter::OffsetValueType
typename TInputImage::OffsetValueType OffsetValueType
Definition: itkBinaryImageToLabelMapFilter.h:94
itk::BinaryImageToLabelMapFilter::WorkUnitData
typename ScanlineFunctions::WorkUnitData WorkUnitData
Definition: itkBinaryImageToLabelMapFilter.h:182
itk::ScanlineFilterCommon::IndexType
typename TInputImage::IndexType IndexType
Definition: itkScanlineFilterCommon.h:85
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
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::ScanlineFilterCommon::SizeType
typename TInputImage::SizeType SizeType
Definition: itkScanlineFilterCommon.h:86