Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vifa_int_faces_attr.h

Go to the documentation of this file.
00001 // This is gel/vifa/vifa_int_faces_attr.h
00002 #ifndef VIFA_INT_FACES_ATTR_H
00003 #define VIFA_INT_FACES_ATTR_H
00004 
00005 //-----------------------------------------------------------------------------
00006 //:
00007 // \file
00008 // \brief Collect statistics about a group of regions.
00009 //
00010 // Collects statistics about a group of regions.  (For region groups
00011 // formed around a seed region, see IntFacesAdjAttr.)
00012 //
00013 // \author Roddy Collins, from DDB in TargetJr
00014 //
00015 // \verbatim
00016 //  Modifications:
00017 //   MPP May 2003, Ported to VXL
00018 // \endverbatim
00019 //-----------------------------------------------------------------------------
00020 
00021 #include <vcl_vector.h>
00022 #include <vbl/vbl_smart_ptr.h>
00023 #include <vdgl/vdgl_fit_lines_params.h>
00024 #include <vtol/vtol_intensity_face_sptr.h>
00025 #include <vifa/vifa_histogram.h>
00026 #include <vifa/vifa_int_face_attr_common.h>
00027 #include <vifa/vifa_int_face_attr.h>
00028 #include <vifa/vifa_int_face_attr_factory.h>
00029 #include <vifa/vifa_parallel.h>
00030 #include <vifa/vifa_typedefs.h>
00031 
00032 
00033 // Create the index for histogrammed attributes.  Must indicate the
00034 // position in attr_get_funcs[].
00035 #define NUM_HIST_ATTRIBUTES 15
00036 
00037 // type needed for attr_get_funcs.
00038 typedef float (vifa_int_face_attr::*AttrFuncPtr)();
00039 
00040 
00041 class vifa_int_faces_attr : public vifa_int_face_attr_common
00042 {
00043  protected:
00044   iface_list     faces_;
00045 
00046   // should be a map, but until operator<() is const in smart_ptr.h...
00047   //  map<vifa_intensity_face_sptr, vifa_int_face_attr_sptr, less<vifa_intensity_face_sptr> > attr_map_;
00048   attr_list      attr_map_;
00049 
00050   vcl_vector<float>  centroid_;      // cache for region group center-of-mass
00051   float          perimeter_;
00052   float          weighted_perimeter_;
00053 
00054   // Vector of vifa_int_face_attr methods to get an attribute val for one
00055   // face.  Defines the histogrammed attribute vector.  Length must be
00056   // NUM_HIST_ATTRIBUTES.
00057   static AttrFuncPtr attr_get_funcs[];
00058   static const char* const attr_names[];
00059   static float attr_min_vals[];
00060 
00061   // attribute slots
00062 
00063   // Histogrammed attributes are grouped together into parallel
00064   // vectors.  Histograms compute mean and standard deviation.
00065   // Attributes defined by attr_get_funcs.
00066   //vcl_vector<vifa_histogram_sptr> attr_hists_;
00067   incr_var_list  attr_vec_;
00068 
00069   float cached_2_parallel_;
00070   float cached_4_parallel_;
00071   float cached_80_parallel_;
00072   vifa_parallel* npobj_;
00073   vifa_int_face_attr_factory* factory_;
00074  public:
00075   vifa_int_faces_attr(vdgl_fit_lines_params*       fitter_params = NULL,
00076                       vifa_group_pgram_params*     gpp_s = NULL,
00077                       vifa_group_pgram_params*     gpp_w = NULL,
00078                       vifa_coll_lines_params*      cpp = NULL,
00079                       vifa_norm_params*            np = NULL,
00080                       vifa_int_face_attr_factory*  factory = NULL
00081                      );
00082   vifa_int_faces_attr(iface_list&                  v,
00083                       vdgl_fit_lines_params*       fitter_params = NULL,
00084                       vifa_group_pgram_params*     gpp_s = NULL,
00085                       vifa_group_pgram_params*     gpp_w = NULL,
00086                       vifa_coll_lines_params*      cpp = NULL,
00087                       vifa_norm_params*            np = NULL,
00088                       vifa_int_face_attr_factory*  factory = NULL
00089                      );
00090 
00091   virtual ~vifa_int_faces_attr();
00092 
00093   // ---
00094   // Public functional methods
00095   // ---
00096 
00097   virtual bool  ComputeAttributes();
00098   virtual bool  GetAttributes(vcl_vector<float>& attrs);
00099   static void    GetAttributeNames(vcl_vector<vcl_string>& names);
00100   virtual bool  GetNativeAttributes(vcl_vector<float>& attrs);
00101 
00102   // Data access for non-attributes
00103   virtual iface_list&  GetFaces()
00104     { return faces_; };
00105   virtual void    SetFaces(iface_list& v);
00106   edge_2d_list&    GetEdges();
00107 
00108   // hmm, need to think about this
00109 
00110   vifa_int_face_attr_sptr factory_new_attr(vtol_intensity_face_sptr face);
00111 
00112   //: centroid X
00113   float Xo();
00114   //: centroid Y
00115   float Yo();
00116 
00117   // ---
00118   // Attribute computation
00119   // ---
00120 
00121   // Histogrammed attributes.  See attr_get_funcs in .C file for
00122   // attribute index.  These are not weighted by area size.
00123   float GetMeanAttr(int attr_index); // mean of indexed histogrammed attribute
00124   float GetSDAttr(int attr_index); // sd of indexed histogrammed attribute
00125   float GetMinAttr(int attr_index); // min of indexed histogrammed attribute
00126   float GetMaxAttr(int attr_index); // max of indexed histogrammed attribute
00127   int NumHistAttributes()
00128     { return NUM_HIST_ATTRIBUTES; }
00129 
00130   // non-histogrammed attributes (one value per vifa_int_faces_attr).
00131   float Area();                 // area of all faces
00132   float AspectRatio();          // ratio of major moments
00133   float PerimeterLength();      // length of boundary, in pixels
00134   float Complexity();           // edge length^2 / detection area
00135   float WeightedComplexity();
00136   float WeightedPerimeterLength();
00137 
00138   float TwoPeakParallel();
00139   float FourPeakParallel();
00140   float EightyPercentParallel();
00141 
00142   // a hack for weird linking problems on Windows with attr_get_funcs[]
00143   static float  CallAttrFunction(vifa_int_face_attr* seed, int i);
00144 
00145   static const char*  GetBaseAttrName(int i);
00146 
00147  protected:
00148   virtual void  init();
00149   void          SetNP();
00150   void          ComputeCentroid();
00151   virtual bool  ComputeSingleFaceAttributes(bool forceP=false);
00152 
00153   // Caller must delete returned edge_list when done
00154   edge_list*    GetPerimeterEdges();
00155   vifa_histogram_sptr  MakeAttrHist(vcl_vector<float>& attr_vals);
00156 };
00157 
00158 typedef vbl_smart_ptr<vifa_int_faces_attr>  vifa_int_faces_attr_sptr;
00159 
00160 
00161 #endif  // VIFA_INT_FACES_ATTR_H

Generated on Thu Jan 10 14:47:31 2008 for contrib/gel/vifa by  doxygen 1.4.4