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: 2002/07/12 18:57:56 $
00007   Version:   $Revision: 1.4 $
00008 
00009   Copyright (c) 2002 Insight 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 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(SegmentTree, DataObject);
00054   typedef TScalarType ScalarType;
00055 
00059   struct merge_t
00060   {
00061     unsigned long from;
00062     unsigned long to;
00063     ScalarType saliency;
00064   };
00065 
00067   typedef std::deque<merge_t> DequeType;
00068   typedef typename DequeType::iterator Iterator;
00069   typedef typename DequeType::const_iterator ConstIterator;
00070   typedef typename DequeType::value_type ValueType;
00071     
00073   struct merge_comp : public std::binary_function<bool, const merge_t&,
00074                       const merge_t& >
00075   {
00076     bool operator()(const merge_t &a, const merge_t &b)
00077       {
00078         return b.saliency < a.saliency;
00079       }
00080   };
00081   
00083   struct sort_comp : public std::binary_function<bool, const merge_t&,
00084                      const merge_t& >
00085   {
00086     bool operator()(const merge_t &a, const merge_t &b)
00087       {
00088         return a.saliency < s.Saliency;
00089       }
00090   };
00091 
00093   typename DequeType::size_type Size() const
00094     { return m_Deque.size(); }
00095 
00098   bool Empty() const
00099     { return m_Deque.empty();    }
00100 
00103   const merge_t &Front() const
00104     { return m_Deque.front(); }
00105 
00108   const merge_t &Back() const
00109     { return m_Deque.back(); } 
00110 
00112   merge_t &Front()
00113     { return m_Deque.front(); }
00114 
00116   merge_t &Back()
00117     { return m_Deque.back(); }
00118 
00120   void PushFront(const ValueType &t)
00121     { m_Deque.push_front(t); }
00122 
00124   void PushBack( const ValueType &t)
00125     { m_Deque.push_back(t); }
00126 
00128   void PopFront()
00129     { m_Deque.pop_front(); }
00130 
00132   void PopBack()
00133     { m_Deque.pop_back(); }
00134 
00136   Iterator Begin()
00137     { return m_Deque.begin(); }
00138 
00140   ConstIterator Begin() const
00141     { return m_Deque.begin(); }
00142 
00145   Iterator End()
00146     { return m_Deque.end(); }
00147 
00150   ConstIterator End() const
00151     { return m_Deque.end(); }
00152 
00154   void Clear()
00155   { m_Deque.clear(); }
00156   
00158   //  void PrintDeque();
00159 protected:
00160   SegmentTree() {}
00161   virtual ~SegmentTree() {}
00162   SegmentTree(const Self&) {}
00163   void operator=(const Self&) {}
00164   void PrintSelf(std::ostream& os, Indent indent) const;
00165 
00166   DequeType m_Deque;
00167   void UpdateOutputInformation();
00168   bool VerifyRequestedRegion() { return true; }
00169   void SetRequestedRegionToLargestPossibleRegion () {}
00170   bool RequestedRegionIsOutsideOfTheBufferedRegion () { return false; }
00171   void SetRequestedRegion (itk::DataObject *) {}
00172 };
00173 }// end namespace watershed
00174 }// end namespace itk
00175 
00176 #ifndef ITK_MANUAL_INSTANTIATION
00177 #include "itkWatershedSegmentTree.txx"
00178 #endif
00179 
00180 #endif
00181 

Generated at Wed Mar 12 01:13:14 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000