00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkWatershedSegmentTreeGenerator_h
00018
#define __itkWatershedSegmentTreeGenerator_h
00019
00020
#include "itkWatershedSegmentTable.h"
00021
#include "itkWatershedSegmentTree.h"
00022
#include "itkEquivalencyTable.h"
00023
#include "itkOneWayEquivalencyTable.h"
00024
00025
#include <algorithm>
00026
#include <utility>
00027
00028
namespace itk
00029 {
00030
namespace watershed
00031 {
00032
00076
template <
class TScalarType>
00077 class ITK_EXPORT SegmentTreeGenerator :
public ProcessObject
00078 {
00079
public:
00081
typedef SegmentTreeGenerator
Self;
00082 typedef ProcessObject Superclass;
00083 typedef SmartPointer<Self> Pointer;
00084 typedef SmartPointer<const Self> ConstPointer;
00085 itkNewMacro(
Self);
00086
itkTypeMacro(SegmentTreeGenerator,
ProcessObject);
00087
00089
typedef TScalarType
ScalarType;
00090
typedef SegmentTable<ScalarType> SegmentTableType;
00091 typedef SegmentTree<ScalarType> SegmentTreeType;
00092 typedef EquivalencyTable EquivalencyTableType;
00093 typedef OneWayEquivalencyTable OneWayEquivalencyTableType;
00094 typedef DataObject::Pointer DataObjectPointer;
00095
00097
typedef typename SegmentTableType::Pointer
SegmentTableTypePointer;
00098
typedef typename OneWayEquivalencyTableType::Pointer
00099 OneWayEquivalencyTableTypePointer;
00100
typedef typename SegmentTreeType::Pointer
SegmentTreeTypePointer;
00101
00102
00104
SegmentTableType * GetInputSegmentTable()
00105 {
return static_cast<SegmentTableType *>
00106 (this->ProcessObject::GetInput(0)); }
00107 EquivalencyTableType * GetInputEquivalencyTable()
00108 {
return static_cast<EquivalencyTableType *>
00109 (this->ProcessObject::GetInput(1)); }
00110
00114
void SetInputEquivalencyTable(EquivalencyTableType *eq)
00115 { this->ProcessObject::SetNthInput(1, eq); }
00116
void SetInputSegmentTable(SegmentTableType *st)
00117 { this->ProcessObject::SetNthInput(0, st); }
00118
00120 SegmentTreeType * GetOutputSegmentTree()
00121 {
return static_cast<SegmentTreeType *>
00122 (this->ProcessObject::GetOutput(0)); }
00123
00125
void GenerateData();
00126
00131
itkSetMacro(Merge,
bool);
00132
itkGetMacro(Merge,
bool);
00133
00139
void SetFloodLevel(
double);
00140
itkGetMacro(FloodLevel,
double);
00141
00145
itkSetMacro(HighestCalculatedFloodLevel,
double);
00146
itkGetMacro(HighestCalculatedFloodLevel,
double);
00147
00152
itkSetMacro(ConsumeInput,
bool);
00153
itkGetMacro(ConsumeInput,
bool);
00154
00157
static void MergeSegments(SegmentTableTypePointer,
00158 OneWayEquivalencyTableTypePointer,
00159
const unsigned long,
00160
const unsigned long);
00161
00164
static void PruneMergeSegments(SegmentTableTypePointer,
00165 OneWayEquivalencyTableTypePointer,
00166
const unsigned long,
00167
const unsigned long,
00168 ScalarType);
00169
00171
virtual DataObjectPointer MakeOutput(
unsigned int idx);
00172
00173
protected:
00174 SegmentTreeGenerator();
00175
virtual ~SegmentTreeGenerator() {}
00176 SegmentTreeGenerator(
const Self&) {}
00177
void operator=(
const Self&) {}
00178
void PrintSelf(std::ostream& os, Indent indent)
const;
00179
00182
void CompileMergeList(SegmentTableTypePointer, SegmentTreeTypePointer);
00183
00186
void ExtractMergeHierarchy(
SegmentTableTypePointer,
SegmentTreeTypePointer);
00187
00188
void MergeEquivalencies();
00189
00191
void GenerateOutputRequestedRegion(
DataObject *output);
00192
void GenerateInputRequestedRegion();
00193
00194
private:
00195
bool m_Merge;
00196
double m_FloodLevel;
00197
bool m_ConsumeInput;
00198 OneWayEquivalencyTableType::Pointer m_MergedSegmentsTable;
00199
00203
double m_HighestCalculatedFloodLevel;
00204 };
00205
00206 }
00207 }
00208
00209
#ifndef ITK_MANUAL_INSTANTIATION
00210
#include "itkWatershedSegmentTreeGenerator.txx"
00211
#endif
00212
00213
#endif
00214