contrib/brl/bseg/sdet/sdet_region.h
Go to the documentation of this file.
00001 // This is brl/bseg/sdet/sdet_region.h
00002 #ifndef sdet_region_h_
00003 #define sdet_region_h_
00004 //-----------------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \author J.L. Mundy
00008 // \brief A region class for the watershed algorithm.
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   Initial version July 11, 2004
00013 // \endverbatim
00014 //
00015 //-----------------------------------------------------------------------------
00016 #include <vcl_iosfwd.h>
00017 #include "sdet_region_sptr.h"
00018 #include <vsol/vsol_polygon_2d_sptr.h>
00019 #include <vdgl/vdgl_digital_region.h>
00020 
00021 class sdet_region : public vdgl_digital_region
00022 {
00023  public:
00024   sdet_region();
00025   sdet_region(int npts, const float* xp, const float* yp,
00026               const unsigned short *pix);
00027   sdet_region(vdgl_digital_region const& reg);
00028   ~sdet_region() {}
00029   //:accessors
00030   void set_label(const unsigned int label){region_label_ = label;}
00031   unsigned int label() const {return region_label_;}
00032 
00033   void set_boundary(vsol_polygon_2d_sptr const& boundary){boundary_ = boundary;}
00034   vsol_polygon_2d_sptr boundary();
00035 
00036   vdgl_digital_region* cast_to_digital_region(){return (vdgl_digital_region*) this;}
00037 
00038   //:utilities
00039   bool compute_boundary();
00040   // must implement comparison since containers need this
00041   struct compare
00042   {
00043     bool operator()(sdet_region_sptr const & l,
00044                     sdet_region_sptr const & r) const
00045     {
00046       if (!l||!r)
00047         return false;
00048       return l->Npix() < r->Npix();//Large areas are favored
00049     }
00050   };
00051  protected:
00052   unsigned int region_label_;
00053   bool boundary_valid_;
00054   vsol_polygon_2d_sptr boundary_;
00055 };
00056 
00057 vcl_ostream& operator<<(vcl_ostream& s, sdet_region const& sd);
00058 
00059 #endif // sdet_region_h_