contrib/gel/vifa/vifa_int_faces_adj_attr.h
Go to the documentation of this file.
00001 // This is gel/vifa/vifa_int_faces_adj_attr.h
00002 #ifndef VIFA_INT_FACES_ADJ_ATTR_H
00003 #define VIFA_INT_FACES_ADJ_ATTR_H
00004 
00005 //-----------------------------------------------------------------------------
00006 //:
00007 // \file
00008 // \brief Collects statistics about a group of faces.
00009 // Collects statistics about a group of faces that have been grown from
00010 // a seed face.  Will either take a seed and grow the regions itself or
00011 // take a collection of faces on faith.
00012 //
00013 // *** WARNING *** Probably does not calculate neighborhoods correctly
00014 // for depths > 1 (probably includes the seed face back into the neighborhood.)
00015 //
00016 // \author Roddy Collins, from DDB in TargetJr
00017 //
00018 // \verbatim
00019 //  Modifications:
00020 //   MPP May 2003, Ported to VXL
00021 // \endverbatim
00022 //-----------------------------------------------------------------------------
00023 
00024 #include <vcl_vector.h>
00025 #include <vdgl/vdgl_fit_lines_params.h>
00026 #include <vtol/vtol_intensity_face_sptr.h>
00027 #include <vifa/vifa_coll_lines_params.h>
00028 #include <vifa/vifa_group_pgram_params.h>
00029 #include <vifa/vifa_int_faces_attr.h>
00030 #include <vifa/vifa_typedefs.h>
00031 
00032 
00033 class vifa_int_faces_adj_attr: public vifa_int_faces_attr
00034 {
00035  protected:
00036   enum
00037   {
00038     BAD_DEPTH = -1
00039   };
00040 
00041   bool            closure_valid_;
00042 
00043   vtol_intensity_face_sptr  seed_;
00044   vifa_int_face_attr_sptr    seed_attr_;
00045   int              depth_;
00046   int              size_filter_;
00047 
00048   float            junk_area_percentage_;
00049   int              junk_count_;
00050   float            junk_percent_;
00051   float            junk_area_ratio_;
00052 
00053   // attribute slots
00054 
00055   // ratios of seed attr to neighborhood mean
00056   vcl_vector<float>      mean_ratios_;
00057   vcl_vector<float>      min_ratios_;
00058 
00059  public:
00060   vifa_int_faces_adj_attr();
00061   vifa_int_faces_adj_attr(vtol_intensity_face_sptr  seed,
00062                           int              depth,
00063                           int              size_filter = -1,
00064                           vdgl_fit_lines_params*    fitter_params = NULL,
00065                           vifa_group_pgram_params*  gpp_s = NULL,
00066                           vifa_group_pgram_params*  gpp_w = NULL,
00067                           vifa_coll_lines_params*    cpp = NULL,
00068                           vifa_norm_params*      np = NULL,
00069                           vifa_int_face_attr_factory*  factory = NULL,
00070                           float          junk_area_percentage = 0.2
00071                          );
00072 
00073   vifa_int_faces_adj_attr(vtol_intensity_face_sptr  seed,
00074                           int                       depth,
00075                           iface_list&               neighborhood,
00076                           int                       size_filter  =  -1,
00077                           vdgl_fit_lines_params*    fitter_params  =  NULL,
00078                           vifa_group_pgram_params*  gpp_s  =  NULL,
00079                           vifa_group_pgram_params*  gpp_w  =  NULL,
00080                           vifa_coll_lines_params*   cpp  =  NULL,
00081                           vifa_norm_params*         np  =  NULL,
00082                           vifa_int_face_attr_factory*    factory  =  NULL,
00083                           float                     junk_area_percentage  =  0.2
00084                          );
00085 
00086   virtual iface_list&    GetFaces();
00087   iface_list*        GetFaceList();
00088 
00089   virtual bool  ComputeAttributes();
00090   virtual bool  GetAttributes(vcl_vector<float>&  attrs);
00091   static  void  GetAttributeNames(vcl_vector<vcl_string>&  names);
00092   virtual bool  GetNativeAttributes(vcl_vector<float>&  attrs);
00093 
00094   vtol_intensity_face_sptr  GetSeed() { return seed_; }
00095   void                      SetSeed(vtol_intensity_face_sptr  seed);
00096 
00097   int    GetDepth() const { return depth_; }
00098   void   SetDepth(int depth) { depth_ = depth; closure_valid_ = false; }
00099 
00100   int    NeighborhoodSize();
00101 
00102   int    GetJunkCount()     const { return junk_count_; }
00103   float  GetJunkPercent()   const { return junk_percent_; }
00104   float  GetJunkAreaRatio() const { return junk_area_ratio_; }
00105 
00106   bool  compute_closure();
00107   float  Collinearity();
00108 
00109   //
00110   // attribute gets here
00111   //
00112 
00113   // Ratio of seed to neighbors
00114   float  GetRatioAttr(int  attr_index);
00115 
00116   // Ratio of seed to min of neighbors
00117   float  GetMinRatioAttr(int  attr_index);
00118 
00119  protected:
00120   virtual void  init();
00121   bool  add_unique_face(iface_list&               facelist,
00122                         vtol_intensity_face_sptr  face,
00123                         int                       size_filter);
00124   void  compute_closure_step(int                       current_depth,
00125                              vtol_intensity_face_sptr  seed);
00126 
00127   // Retrieve the iface adjacent to a given iface at an edge (if available)
00128   vtol_intensity_face_sptr
00129     get_adjacent_face_at_edge(vtol_intensity_face_sptr&  known_face,
00130                               vtol_edge_2d*              e);
00131 
00132   // Retrieve all ifaces adjacent to a given face
00133   iface_list*  get_adjacent_faces(vtol_intensity_face_sptr&  known_face);
00134 };
00135 
00136 
00137 #endif  // VIFA_INT_FACES_ADJ_ATTR_H