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

itkWatershedSegmentTree.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkWatershedSegmentTree.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-01-27 19:30:19 $
00007   Version:   $Revision: 1.13 $
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 __itkWatershedSegmentTree_h
00018 #define __itkWatershedSegmentTree_h
00019 
00020 #include "itkObjectFactory.h"
00021 #include "itkDataObject.h"
00022 #include "itkProcessObject.h"
00023 #include <deque>
00024 #include <functional>
00025 
00026 namespace itk
00027 {
00028 namespace watershed
00029 {
00030 /* \class SegmentTree
00031  * A data structure for storing segment merge information used in filters of  
00032  * the watershed segmentation algorithm.  See itk::WatershedImageFilter for an
00033  * overview.
00034  *
00035  * \par
00036  * This class is the implemenation of the ``merge tree'' referred to in the
00037  * documentation for itk::WatershedImageFilter and other watershed segmentation 
00038  * component classes.  It holds a list of merges among image segments at
00039  * various saliency levels. The list is actually a representation of a binary
00040  * tree, whose nodes are segments and edges are saliencies.
00041  * \ingroup WatershedSegmentation
00042  * \sa itk::WatershedImageFilter */
00043 template <class TScalarType>
00044 class ITK_EXPORT SegmentTree : public DataObject
00045 {
00046 public:
00048   typedef SegmentTree              Self;
00049   typedef DataObject               Superclass;
00050   typedef SmartPointer<Self>       Pointer;
00051   typedef SmartPointer<const Self> ConstPointer;
00052   itkNewMacro(Self);
00053   itkTypeMacro(WatershedSegmentTree, DataObject);
00054   typedef TScalarType ScalarType;
00056 
00060   struct merge_t
00061     {
00062     unsigned long from;
00063     unsigned long to;
00064     ScalarType saliency;
00065     };
00067 
00069   typedef std::deque<merge_t>                DequeType;
00070   typedef typename DequeType::iterator       Iterator;
00071   typedef typename DequeType::const_iterator ConstIterator;
00072   typedef typename DequeType::value_type     ValueType;
00073 
00075   struct merge_comp : public std::binary_function<bool, const merge_t&,
00076                       const merge_t& >
00077     {
00078     bool operator()(const merge_t &a, const merge_t &b)
00079       {
00080       return b.saliency < a.saliency;
00081       }
00082     };
00083 
00085   struct sort_comp : public std::binary_function<bool, const merge_t&,
00086                      const merge_t& >
00087     {
00088     bool operator()(const merge_t &a, const merge_t &b)
00089       {
00090       return a.saliency < b.Saliency;
00091       }
00092     };
00093 
00095   typename DequeType::size_type Size() const
00096     { return m_Deque.size(); }
00097 
00100   bool Empty() const
00101     { return m_Deque.empty();    }
00102 
00105   const merge_t &Front() const
00106     { return m_Deque.front(); }
00107 
00110   const merge_t &Back() const
00111     { return m_Deque.back(); } 
00112 
00114   merge_t &Front()
00115     { return m_Deque.front(); }
00116 
00118   merge_t &Back()
00119     { return m_Deque.back(); }
00120 
00122   void PushFront(const ValueType &t)
00123     { m_Deque.push_front(t); }
00124 
00126   void PushBack( const ValueType &t)
00127     { m_Deque.push_back(t); }
00128 
00130   void PopFront()
00131     { m_Deque.pop_front(); }
00132 
00134   void PopBack()
00135     { m_Deque.pop_back(); }
00136 
00138   Iterator Begin()
00139     { return m_Deque.begin(); }
00140 
00142   ConstIterator Begin() const
00143     { return m_Deque.begin(); }
00144 
00147   Iterator End()
00148     { return m_Deque.end(); }
00149 
00152   ConstIterator End() const
00153     { return m_Deque.end(); }
00154 
00156   void Clear()
00157     { m_Deque.clear(); }
00158 
00161   void Initialize();
00162 
00163 protected:
00164   SegmentTree() {}
00165   virtual ~SegmentTree() {}
00166   SegmentTree(const Self&) {}
00167   void operator=(const Self&) {}
00168   void PrintSelf(std::ostream& os, Indent indent) const;
00169 
00170   DequeType m_Deque;
00171 };
00172 }// end namespace watershed
00173 }// end namespace itk
00174 
00175 #ifndef ITK_MANUAL_INSTANTIATION
00176 #include "itkWatershedSegmentTree.txx"
00177 #endif
00178 
00179 #endif
00180 

Generated at Sat Feb 28 13:53:51 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000