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:
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     {
00106       return static_cast<SegmentTableType *>(this->ProcessObject::GetInput(0));
00107     }
00108   void SetInputSegmentTable(SegmentTableType *st)
00109     {
00110       // Reset the highest calculated flood level if we are given a
00111       // different input image.
00112       if (st != this->GetInput(0))
00113         {
00114         m_HighestCalculatedFloodLevel = 0.0;
00115         }
00116       this->ProcessObject::SetNthInput(0, st);
00117     }
00118 
00122   void SetInputEquivalencyTable(EquivalencyTableType *eq)
00123     {
00124       this->ProcessObject::SetNthInput(1, eq);
00125     }
00126   EquivalencyTableType* GetInputEquivalencyTable()
00127     {
00128       return
00129         static_cast<EquivalencyTableType *>(this->ProcessObject::GetInput(1));
00130     }
00131 
00133   SegmentTreeType * GetOutputSegmentTree()
00134   { return static_cast<SegmentTreeType *>
00135       (this->ProcessObject::GetOutput(0)); }
00136 
00138   void GenerateData();
00139 
00144   itkSetMacro(Merge, bool);
00145   itkGetMacro(Merge, bool);
00146 
00152   void SetFloodLevel(double);
00153   itkGetMacro(FloodLevel, double);
00154 
00158   itkSetMacro(HighestCalculatedFloodLevel, double);
00159   itkGetMacro(HighestCalculatedFloodLevel, double);
00160 
00166   itkSetMacro(ConsumeInput, bool);
00167   itkGetMacro(ConsumeInput, bool);
00168 
00171   static void MergeSegments(SegmentTableTypePointer,
00172                             OneWayEquivalencyTableTypePointer,
00173                             const unsigned long,
00174                             const unsigned long);
00175 
00178   static void PruneMergeSegments(SegmentTableTypePointer,
00179                                  OneWayEquivalencyTableTypePointer,
00180                                  const unsigned long,
00181                                  const unsigned long,
00182                                  ScalarType);
00183 
00185   virtual DataObjectPointer MakeOutput(unsigned int idx);
00186   
00187 protected:
00188   SegmentTreeGenerator();
00189   virtual ~SegmentTreeGenerator() {}
00190   SegmentTreeGenerator(const Self&) {}
00191   void operator=(const Self&) {}
00192   void PrintSelf(std::ostream& os, Indent indent) const;
00193   
00196   void CompileMergeList(SegmentTableTypePointer, SegmentTreeTypePointer);
00197 
00200   void ExtractMergeHierarchy(SegmentTableTypePointer, SegmentTreeTypePointer);
00201 
00202   void MergeEquivalencies();
00203 
00205   void GenerateOutputRequestedRegion(DataObject *output);
00206   void GenerateInputRequestedRegion();
00207   
00208 private:
00209   bool m_Merge;
00210   double m_FloodLevel;
00211   bool m_ConsumeInput;
00212   OneWayEquivalencyTableType::Pointer m_MergedSegmentsTable;
00213   
00218   double m_HighestCalculatedFloodLevel;
00219 };
00220   
00221 }// end namespace watershed
00222 }// end namespace itk
00223 
00224 #ifndef ITK_MANUAL_INSTANTIATION
00225 #include "itkWatershedSegmentTreeGenerator.txx"
00226 #endif
00227 
00228 #endif
00229 

Generated at Thu May 25 00:18:16 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000