contrib/brl/bseg/sdet/sdet_region_edge.h
Go to the documentation of this file.
00001 #ifndef sdet_region_edge_h_
00002 #define sdet_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 sdet_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 sdet_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.h>
00045 #include <vtol/vtol_edge_2d_sptr.h>
00046 #include <vbl/vbl_ref_count.h>
00047 #include <vcl_stlfwd.h> // for vcl_vector
00048 #include "sdet_region_edge_sptr.h"
00049 
00050 class sdet_region_edge : public vbl_ref_count
00051 {
00052  public:
00053   //Constructors/Destructors
00054   sdet_region_edge(vtol_edge_2d_sptr e);
00055   sdet_region_edge(sdet_region_edge const& e)
00056     : vbl_ref_count(), edge_(e.edge_), labels_(e.labels_) {}
00057   ~sdet_region_edge();
00058   //Accessors
00059 
00060   void Prop(sdet_region_edge_sptr const& re,
00061             unsigned int label, unsigned int max_label);
00062 
00063   vtol_edge_2d_sptr get_edge() const {return edge_;}
00064 
00065   bool is_vertex() const;
00066   unsigned int NumLabels(unsigned int max_label) const;
00067   unsigned int GetLabel(unsigned int i, unsigned int max_label) const
00068   { return i<NumLabels(max_label) ? labels_[i] : 0; }
00069 
00070   // Utilities (especially for testing)
00071  protected:
00072   //Utilities
00073   bool SetNewLabel(unsigned int label);
00074   //members
00075   vtol_edge_2d_sptr edge_;
00076   vcl_vector<unsigned int> labels_;
00077 };
00078 
00079 #endif // sdet_region_edge_h_