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: 2010-03-02 03:40:36 $
00007   Version:   $Revision: 1.16 $
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(WatershedSegmentTreeGenerator, 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     {
00139     return static_cast<SegmentTreeType *>
00140       (this->ProcessObject::GetOutput(0)); 
00141     }
00142 
00144   void GenerateData();
00145 
00150   itkSetMacro(Merge, bool);
00151   itkGetConstMacro(Merge, bool);
00153 
00159   void SetFloodLevel(double);
00160   itkGetConstMacro(FloodLevel, double);
00162 
00166   itkSetMacro(HighestCalculatedFloodLevel, double);
00167   itkGetConstMacro(HighestCalculatedFloodLevel, double);
00169 
00175   itkSetMacro(ConsumeInput, bool);
00176   itkGetConstMacro(ConsumeInput, bool);
00178 
00181   static void MergeSegments(SegmentTableTypePointer,
00182                             OneWayEquivalencyTableTypePointer,
00183                             const unsigned long,
00184                             const unsigned long);
00185 
00188   static void PruneMergeSegments(SegmentTableTypePointer,
00189                                  OneWayEquivalencyTableTypePointer,
00190                                  const unsigned long,
00191                                  const unsigned long,
00192                                  ScalarType);
00193 
00195   virtual DataObjectPointer MakeOutput(unsigned int idx);
00196 
00197 protected:
00198   SegmentTreeGenerator();
00199   virtual ~SegmentTreeGenerator() {}
00200   SegmentTreeGenerator(const Self&) {}
00201   void operator=(const Self&) {}
00202   void PrintSelf(std::ostream& os, Indent indent) const;
00203   
00206   void CompileMergeList(SegmentTableTypePointer, SegmentTreeTypePointer);
00207 
00210   void ExtractMergeHierarchy(SegmentTableTypePointer, SegmentTreeTypePointer);
00211 
00212   void MergeEquivalencies();
00213 
00215   void GenerateOutputRequestedRegion(DataObject *output);
00216   void GenerateInputRequestedRegion();
00218 
00219 private:
00220   bool   m_Merge;
00221   double m_FloodLevel;
00222   bool   m_ConsumeInput;
00223 
00224   OneWayEquivalencyTableType::Pointer m_MergedSegmentsTable;
00225   
00230   double m_HighestCalculatedFloodLevel;
00231 };
00232 
00233 }// end namespace watershed
00234 }// end namespace itk
00235 
00236 #ifndef ITK_MANUAL_INSTANTIATION
00237 #include "itkWatershedSegmentTreeGenerator.txx"
00238 #endif
00239 
00240 #endif
00241 

Generated at Fri Apr 16 20:03:17 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000