Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkWatershedSegmentTreeGenerator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkWatershedSegmentTreeGenerator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/02/24 20:47:26 $
00007   Version:   $Revision: 1.12 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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:
00080 
00082   typedef SegmentTreeGenerator Self;
00083   typedef ProcessObject Superclass;
00084   typedef SmartPointer<Self> Pointer;
00085   typedef SmartPointer<const Self> ConstPointer;
00086   itkNewMacro(Self);
00087   itkTypeMacro(SegmentTreeGenerator, ProcessObject);
00089 
00091   typedef TScalarType ScalarType;
00092   typedef SegmentTable<ScalarType> SegmentTableType;
00093   typedef SegmentTree<ScalarType>  SegmentTreeType;
00094   typedef EquivalencyTable         EquivalencyTableType;
00095   typedef OneWayEquivalencyTable   OneWayEquivalencyTableType;
00096   typedef DataObject::Pointer      DataObjectPointer;
00097 
00099   typedef typename SegmentTableType::Pointer SegmentTableTypePointer;
00100   typedef typename OneWayEquivalencyTableType::Pointer
00101           OneWayEquivalencyTableTypePointer;
00102   typedef typename SegmentTreeType::Pointer SegmentTreeTypePointer;
00103 
00104 
00106   SegmentTableType* GetInputSegmentTable()
00107     {
00108       return static_cast<SegmentTableType *>(this->ProcessObject::GetInput(0));
00109     }
00110   void SetInputSegmentTable(SegmentTableType *st)
00111     {
00112       // Reset the highest calculated flood level if we are given a
00113       // different input image.
00114       if (st != this->GetInput(0))
00115         {
00116         m_HighestCalculatedFloodLevel = 0.0;
00117         }
00118       this->ProcessObject::SetNthInput(0, st);
00119     }
00121 
00125   void SetInputEquivalencyTable(EquivalencyTableType *eq)
00126     {
00127       this->ProcessObject::SetNthInput(1, eq);
00128     }
00129   EquivalencyTableType* GetInputEquivalencyTable()
00130     {
00131       return
00132         static_cast<EquivalencyTableType *>(this->ProcessObject::GetInput(1));
00133     }
00135 
00137   SegmentTreeType * GetOutputSegmentTree()
00138   { return static_cast<SegmentTreeType *>
00139       (this->ProcessObject::GetOutput(0)); }
00140 
00142   void GenerateData();
00143 
00148   itkSetMacro(Merge, bool);
00149   itkGetMacro(Merge, bool);
00151 
00157   void SetFloodLevel(double);
00158   itkGetMacro(FloodLevel, double);
00160 
00164   itkSetMacro(HighestCalculatedFloodLevel, double);
00165   itkGetMacro(HighestCalculatedFloodLevel, double);
00167 
00173   itkSetMacro(ConsumeInput, bool);
00174   itkGetMacro(ConsumeInput, bool);
00176 
00179   static void MergeSegments(SegmentTableTypePointer,
00180                             OneWayEquivalencyTableTypePointer,
00181                             const unsigned long,
00182                             const unsigned long);
00183 
00186   static void PruneMergeSegments(SegmentTableTypePointer,
00187                                  OneWayEquivalencyTableTypePointer,
00188                                  const unsigned long,
00189                                  const unsigned long,
00190                                  ScalarType);
00191 
00193   virtual DataObjectPointer MakeOutput(unsigned int idx);
00194 
00195 protected:
00196   SegmentTreeGenerator();
00197   virtual ~SegmentTreeGenerator() {}
00198   SegmentTreeGenerator(const Self&) {}
00199   void operator=(const Self&) {}
00200   void PrintSelf(std::ostream& os, Indent indent) const;
00201   
00204   void CompileMergeList(SegmentTableTypePointer, SegmentTreeTypePointer);
00205 
00208   void ExtractMergeHierarchy(SegmentTableTypePointer, SegmentTreeTypePointer);
00209 
00210   void MergeEquivalencies();
00211 
00213   void GenerateOutputRequestedRegion(DataObject *output);
00214   void GenerateInputRequestedRegion();
00216 
00217 private:
00218   bool m_Merge;
00219   double m_FloodLevel;
00220   bool m_ConsumeInput;
00221   OneWayEquivalencyTableType::Pointer m_MergedSegmentsTable;
00222   
00227   double m_HighestCalculatedFloodLevel;
00228 };
00229 
00230 }// end namespace watershed
00231 }// end namespace itk
00232 
00233 #ifndef ITK_MANUAL_INSTANTIATION
00234 #include "itkWatershedSegmentTreeGenerator.txx"
00235 #endif
00236 
00237 #endif
00238 
00239 

Generated at Sun Sep 23 14:45:46 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000