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

itkWatershedSegmentTable.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkWatershedSegmentTable.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/03/05 18:13:39 $
00007   Version:   $Revision: 1.11 $
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 __itkWatershedSegmentTable_h
00018 #define __itkWatershedSegmentTable_h
00019 
00020 #if defined(_MSC_VER)
00021 #pragma warning ( disable : 4786 )
00022 #endif
00023 
00024 #include "itkObjectFactory.h"
00025 #include "itkDataObject.h"
00026 #include "itkProcessObject.h"
00027 #include "itk_hash_map.h"
00028 #include <list>
00029 #include "itkOneWayEquivalencyTable.h"
00030 
00031 namespace itk
00032 {
00033 namespace watershed
00034 {
00049 template <class TScalarType> 
00050 class ITK_EXPORT SegmentTable : public DataObject
00051 {
00052 public:
00054   typedef SegmentTable Self;
00055   typedef DataObject Superclass;
00056   typedef SmartPointer<Self> Pointer;
00057   typedef SmartPointer<const Self> ConstPointer;
00058   typedef TScalarType ScalarType;
00059   itkNewMacro(Self);
00060   itkTypeMacro(SegmentTable, DataObject);
00062 
00065   struct edge_pair_t
00066   {
00067     edge_pair_t() {}
00068     edge_pair_t(unsigned long l, ScalarType s)
00069       : label(l), height(s) {}
00070     unsigned long label;
00071     ScalarType height;
00073 
00075     bool operator<( const edge_pair_t & o) const
00076     {
00077       if ( this->height < o.height ) 
00078         {
00079         return true;
00080         }
00081       else 
00082         {
00083         return false;
00084         }
00085     }
00087 
00088   };
00089   
00092   typedef std::list<edge_pair_t>  edge_list_t;
00093 
00095   struct segment_t
00096   {
00097     ScalarType    min;
00098     edge_list_t   edge_list;
00099   };
00100 
00102   typedef itk::hash_map<unsigned long, segment_t, itk::hash<unsigned long> >
00103   HashMapType;
00104   typedef typename HashMapType::iterator Iterator;
00105   typedef typename HashMapType::const_iterator ConstIterator;
00106   typedef typename HashMapType::value_type ValueType;
00107   typedef typename HashMapType::data_type  DataType;
00108 
00110   bool Add(unsigned long a, const segment_t &t);
00111 
00116   void PruneEdgeLists(ScalarType maximum_saliency);
00117 
00120   segment_t *Lookup(const unsigned long a)
00121   {
00122     Iterator result = m_HashMap.find(a);
00123     if ( result == m_HashMap.end() ) return 0;
00124     else return &((*result).second);
00125   }
00127 
00130   const segment_t *Lookup(const unsigned long a) const
00131   {
00132     ConstIterator result = m_HashMap.find(a);
00133     if ( result == m_HashMap.end() ) return 0;
00134     else return &((*result).second);
00135   }
00137 
00140   bool IsEntry(const unsigned long a) const
00141   {
00142     if ( m_HashMap.find(a) == m_HashMap.end() ) return false;
00143     else return true;
00144   }
00146 
00148   void Erase(const unsigned long a)
00149   {  m_HashMap.erase(a); }
00150 
00152   void Clear()
00153   {      m_HashMap.clear();    }
00154 
00157   bool Empty() const
00158   {      return m_HashMap.empty();    }
00159 
00162   void SortEdgeLists();
00163 
00165   typename HashMapType::size_type  Size() const 
00166   {      return m_HashMap.size();     }
00167 
00169   //  void Merge(const unsigned long from, const unsigned long to);
00170 
00173   Iterator Begin() { return m_HashMap.begin(); }
00174 
00177   Iterator End()   { return m_HashMap.end();   }
00178 
00181   ConstIterator Begin() const { return m_HashMap.begin(); }
00182 
00185   ConstIterator End()   const { return m_HashMap.end();   }
00186 
00188   unsigned int GetSegmentMemorySize() const
00189   {
00190     return sizeof(segment_t);
00191   }
00192   //  void PrintHashTable() const;
00194 
00197   void SetMaximumDepth(ScalarType s)
00198   {
00199     m_MaximumDepth = s;
00200     this->Modified();
00201   }
00202   ScalarType GetMaximumDepth() const
00203   { return m_MaximumDepth; }
00205 
00209   void Copy(const Self& o)
00210   {
00211     m_HashMap = o.m_HashMap;
00212     m_MaximumDepth = o.m_MaximumDepth;
00213   }
00214 
00215 protected:
00216   SegmentTable() {}
00217   virtual ~SegmentTable() {}
00218   void PrintSelf(std::ostream& os, Indent indent) const;
00219 
00220   HashMapType m_HashMap;
00221   ScalarType m_MaximumDepth;
00222   
00223 private:
00224   void operator=(const Self&) {}
00225   
00226 };
00227 
00228 }// end namespace watershed
00229 }// end namespace itk
00230 
00231 #ifndef ITK_MANUAL_INSTANTIATION
00232 #include "itkWatershedSegmentTable.txx"
00233 #endif
00234 
00235 #endif
00236 
00237 

Generated at Tue Jul 29 23:59:04 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000