ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkWatershedSegmentTreeGenerator.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 itkWatershedSegmentTreeGenerator_h
19 #define itkWatershedSegmentTreeGenerator_h
20 
23 #include "itkEquivalencyTable.h"
24 
25 #include <algorithm>
26 #include <utility>
27 
28 namespace itk
29 {
30 namespace watershed
31 {
77 template< typename TScalar >
79 {
80 public:
81 
87 
89  itkNewMacro(Self);
90  itkTypeMacro(WatershedSegmentTreeGenerator, ProcessObject);
92 
94  typedef TScalar ScalarType;
100 
105 
108  {
109  return static_cast< SegmentTableType * >( this->ProcessObject::GetInput(0) );
110  }
111 
113  {
114  // Reset the highest calculated flood level if we are given a
115  // different input image.
116  if ( st != this->GetInput(0) )
117  {
119  }
120  this->ProcessObject::SetNthInput(0, st);
121  }
122 
127  {
128  this->ProcessObject::SetNthInput(1, eq);
129  }
130 
132  {
133  return
134  static_cast< EquivalencyTableType * >( this->ProcessObject::GetInput(1) );
135  }
136 
139  {
140  return static_cast< SegmentTreeType * >
141  ( this->ProcessObject::GetOutput(0) );
142  }
143 
145  virtual void GenerateData() ITK_OVERRIDE;
146 
151  itkSetMacro(Merge, bool);
152  itkGetConstMacro(Merge, bool);
154 
160  void SetFloodLevel(double);
161 
162  itkGetConstMacro(FloodLevel, double);
163 
167  itkSetMacro(HighestCalculatedFloodLevel, double);
168  itkGetConstMacro(HighestCalculatedFloodLevel, double);
170 
176  itkSetMacro(ConsumeInput, bool);
177  itkGetConstMacro(ConsumeInput, bool);
179 
184  const IdentifierType,
185  const IdentifierType);
186 
189  static void PruneMergeSegments(SegmentTableTypePointer,
190  OneWayEquivalencyTableTypePointer,
191  const IdentifierType,
192  const IdentifierType,
193  ScalarType);
194 
197  using Superclass::MakeOutput;
198  virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
199 
200 protected:
202  virtual ~SegmentTreeGenerator() {}
204  void operator=(const Self &) {}
205  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
206 
210 
214 
215  void MergeEquivalencies();
216 
218  virtual void GenerateOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
219 
220  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
221 
222 private:
223  bool m_Merge;
224  double m_FloodLevel;
226 
227  typedef itksys::hash_map< IdentifierType, bool,
228  itksys::hash< IdentifierType > > HashMapType;
229 
231 
237 };
238 } // end namespace watershed
239 } // end namespace itk
240 
241 #ifndef ITK_MANUAL_INSTANTIATION
242 #include "itkWatershedSegmentTreeGenerator.hxx"
243 #endif
244 
245 #endif
void CompileMergeList(SegmentTableTypePointer, SegmentTreeTypePointer)
virtual void PrintSelf(std::ostream &os, Indent indent) const override
Light weight base class for most itk classes.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
static void PruneMergeSegments(SegmentTableTypePointer, OneWayEquivalencyTableTypePointer, const IdentifierType, const IdentifierType, ScalarType)
void ExtractMergeHierarchy(SegmentTableTypePointer, SegmentTreeTypePointer)
Hash table to manage integral label equivalencies that are order dependent.
itksys::hash_map< IdentifierType, bool, itksys::hash< IdentifierType > > HashMapType
static void MergeSegments(SegmentTableTypePointer, OneWayEquivalencyTableTypePointer, const IdentifierType, const IdentifierType)
SizeValueType IdentifierType
Definition: itkIntTypes.h:147
Hash table to manage integral label equivalencies.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
OneWayEquivalencyTableType::Pointer m_MergedSegmentsTable
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
Make a DataObject of the correct type to used as the specified output.
virtual void GenerateOutputRequestedRegion(DataObject *output) override
void SetInputEquivalencyTable(EquivalencyTableType *eq)
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
virtual void GenerateInputRequestedRegion() override
Base class for all data objects in ITK.
virtual void GenerateData() override
OneWayEquivalencyTableType::Pointer OneWayEquivalencyTableTypePointer
DataObject * GetOutput(const DataObjectIdentifierType &key)