contrib/gel/gevd/gevd_region_edge.h
Go to the documentation of this file.
00001 #ifndef gevd_region_edge_h_
00002 #define gevd_region_edge_h_
00003 //:
00004 // \file
00005 // \brief An edge with extract information to support constructing regions from an edgel segmentation.
00006 //
00007 //  This class supports tracing of region boundaries in conjunction with
00008 //  the class EdgelIntensity. The gevd_region_edge maintains a list of region
00009 //  labels which the edge is adjacent to. Ideally, the edge is adjacent to
00010 //  only two regions, left and right, as shown below.
00011 // \verbatim
00012 //                    left_region_
00013 //           V1------------------------V2
00014 //                    right_region_
00015 // \endverbatim
00016 //  In practice, this restriction is too limiting.  It is possible for
00017 //  an edge to be adjacent to more than two regions. For example:
00018 // \verbatim
00019 //    c c c
00020 //   o----\ c
00021 //  E  b b  \ c
00022 //   o------+ \ c
00023 //    c c c | a \ c
00024 //        c +----+ c
00025 //          c c c c
00026 // \endverbatim
00027 //   Note that edge E is adjacent to both regions a and b even though
00028 //   there is no intervening vertex at the transition between a and b.
00029 //   In order to preserve a separation between regions b and c, it is
00030 //   necessary to allow more than two labels (a,b) for a given edge.
00031 //
00032 // \author J. L. Mundy - January 24, 1999
00033 // \verbatim
00034 //  Modifications
00035 //   Feb 10, 1999  - JLM Extended the concept of a gevd_region_edge
00036 //                       to represent a vertex, where the edge is NULL.
00037 //                       This extension permits the propagation of region labels
00038 //                       across junctions.
00039 //   March 7, 1999 - JLM Allowed more than two regions per edge.
00040 //   Sept 10, 2004 - PVr Added copy ctor with explicit vbl_ref_count init
00041 // \endverbatim
00042 //-----------------------------------------------------------------------------
00043 
00044 #include <vtol/vtol_edge_2d_sptr.h>
00045 #include <vbl/vbl_ref_count.h>
00046 #include <vcl_stlfwd.h> // for vcl_vector
00047 
00048 class gevd_region_edge : public vbl_ref_count
00049 {
00050  public:
00051   //Constructors/Destructors
00052   gevd_region_edge(vtol_edge_2d_sptr e);
00053   gevd_region_edge(gevd_region_edge const& e)
00054     : vbl_ref_count(), edge_(e.edge_), labels_(e.labels_) {}
00055   ~gevd_region_edge();
00056   void Prop(gevd_region_edge const* re, unsigned int label);
00057   vtol_edge_2d_sptr get_edge() const {return edge_;}
00058   bool is_vertex() const;
00059   unsigned int NumLabels() const {return labels_.size();}
00060   unsigned int GetLabel(unsigned int i) const {return i<NumLabels() ? labels_[i] : 0;}
00061 
00062  protected:
00063   //Utilities (especially for testing)
00064   bool SetNewLabel(unsigned int label);
00065   //members
00066   vtol_edge_2d_sptr edge_;
00067   vcl_vector<unsigned int> labels_;
00068 };
00069 
00070 #endif // gevd_region_edge_h_