ITK  5.4.0
Insight Toolkit
itkWatershedSegmentTreeGenerator.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 itkWatershedSegmentTreeGenerator_h
19#define itkWatershedSegmentTreeGenerator_h
20
23#include "itkEquivalencyTable.h"
24
25#include <algorithm>
26#include <utility>
27
28namespace itk
29{
30namespace watershed
31{
77template <typename TScalar>
78class ITK_TEMPLATE_EXPORT SegmentTreeGenerator : public ProcessObject
79{
80public:
81 ITK_DISALLOW_COPY_AND_MOVE(SegmentTreeGenerator);
82
88
90 itkNewMacro(Self);
91 itkOverrideGetNameOfClassMacro(SegmentTreeGenerator);
95 using ScalarType = TScalar;
101
106
110 {
111 return static_cast<SegmentTableType *>(this->ProcessObject::GetInput(0));
112 }
113
114 void
116 {
117 // Reset the highest calculated flood level if we are given a
118 // different input image.
119 if (st != this->GetInput(0))
120 {
121 m_HighestCalculatedFloodLevel = 0.0;
122 }
123 this->ProcessObject::SetNthInput(0, st);
124 }
125
129 void
131 {
132 this->ProcessObject::SetNthInput(1, eq);
133 }
134
135 EquivalencyTableType *
137 {
138 return static_cast<EquivalencyTableType *>(this->ProcessObject::GetInput(1));
139 }
140
142 SegmentTreeType *
144 {
145 return static_cast<SegmentTreeType *>(this->ProcessObject::GetOutput(0));
146 }
147
149 void
150 GenerateData() override;
151
156 itkSetMacro(Merge, bool);
157 itkGetConstMacro(Merge, bool);
165 void
167
168 itkGetConstMacro(FloodLevel, double);
169
173 itkSetMacro(HighestCalculatedFloodLevel, double);
174 itkGetConstMacro(HighestCalculatedFloodLevel, double);
182 itkSetMacro(ConsumeInput, bool);
183 itkGetConstMacro(ConsumeInput, bool);
188 static void
190
193 static void
196 const IdentifierType,
197 const IdentifierType,
198 ScalarType);
199
202 using Superclass::MakeOutput;
205
206protected:
208 ~SegmentTreeGenerator() override = default;
209
210 void
211 PrintSelf(std::ostream & os, Indent indent) const override;
212
216
220
221 void
223
225 void
227
228 void
230
231private:
232 bool m_Merge{ false };
233 double m_FloodLevel{ 0.0 };
234 bool m_ConsumeInput{ false };
235
236 using HashMapType = std::unordered_map<IdentifierType, bool>;
237
238 OneWayEquivalencyTableType::Pointer m_MergedSegmentsTable{};
239
244 double m_HighestCalculatedFloodLevel{ 0.0 };
245};
246} // end namespace watershed
247} // end namespace itk
248
249#ifndef ITK_MANUAL_INSTANTIATION
250# include "itkWatershedSegmentTreeGenerator.hxx"
251#endif
252
253#endif
Base class for all data objects in ITK.
SmartPointer< Self > Pointer
Hash table to manage integral label equivalencies.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Hash table to manage integral label equivalencies that are order dependent.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
DataObject * GetOutput(const DataObjectIdentifierType &key)
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
static void MergeSegments(SegmentTableTypePointer, OneWayEquivalencyTableTypePointer, const IdentifierType, const IdentifierType)
void PrintSelf(std::ostream &os, Indent indent) const override
void ExtractMergeHierarchy(SegmentTableTypePointer, SegmentTreeTypePointer)
void GenerateOutputRequestedRegion(DataObject *output) override
~SegmentTreeGenerator() override=default
void GenerateInputRequestedRegion() override
typename SegmentTableType::Pointer SegmentTableTypePointer
void SetInputEquivalencyTable(EquivalencyTableType *eq)
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
Make a DataObject of the correct type to used as the specified output.
std::unordered_map< IdentifierType, bool > HashMapType
typename OneWayEquivalencyTableType::Pointer OneWayEquivalencyTableTypePointer
static void PruneMergeSegments(SegmentTableTypePointer, OneWayEquivalencyTableTypePointer, const IdentifierType, const IdentifierType, ScalarType)
void CompileMergeList(SegmentTableTypePointer, SegmentTreeTypePointer)
typename SegmentTreeType::Pointer SegmentTreeTypePointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
class ITK_FORWARD_EXPORT ProcessObject
Definition: itkDataObject.h:41
SizeValueType IdentifierType
Definition: itkIntTypes.h:87