00001 // This is gel/vifa/vifa_int_face_attr.h 00002 #ifndef VIFA_INT_FACE_ATTR_H_ 00003 #define VIFA_INT_FACE_ATTR_H_ 00004 00005 //----------------------------------------------------------------------------- 00006 //: 00007 // \file 00008 // \brief Collects attribute information about an individual intensity face. 00009 // 00010 // \author Roddy Collins, from DDB in TargetJr 00011 // 00012 // \verbatim 00013 // Modifications: 00014 // MPP May 2003, Ported to VXL 00015 // \endverbatim 00016 //----------------------------------------------------------------------------- 00017 00018 #include <vcl_vector.h> 00019 #include <vbl/vbl_smart_ptr.h> 00020 #include <vdgl/vdgl_fit_lines_params.h> 00021 #include <vtol/vtol_intensity_face.h> 00022 #include <vifa/vifa_histogram.h> 00023 #include <vifa/vifa_int_face_attr_common.h> 00024 #include <vifa/vifa_parallel.h> 00025 #include <vifa/vifa_typedefs.h> 00026 00027 00028 class vifa_int_face_attr: public vifa_int_face_attr_common 00029 { 00030 protected: 00031 00032 //: The face whose attributes we store 00033 vtol_intensity_face_sptr face_; 00034 00035 float cached_min_; 00036 float cached_max_; 00037 float cached_mean_; 00038 float cached_var_; 00039 float cached_2_parallel_; 00040 float cached_4_parallel_; 00041 int cached_80_parallel_; 00042 vifa_parallel* npobj_; 00043 00044 public: 00045 00046 vifa_int_face_attr(vdgl_fit_lines_params* fitter_params = NULL, 00047 vifa_group_pgram_params* gpp = NULL, 00048 vifa_group_pgram_params* gpp_w = NULL, 00049 vifa_norm_params* np = NULL 00050 ); 00051 vifa_int_face_attr(vtol_intensity_face_sptr f, 00052 vdgl_fit_lines_params* fitter_params = NULL, 00053 vifa_group_pgram_params* gpp = NULL, 00054 vifa_group_pgram_params* gpp_w = NULL, 00055 vifa_norm_params* np = NULL 00056 ); 00057 virtual ~vifa_int_face_attr(); 00058 00059 // --- 00060 // Public functional methods 00061 // --- 00062 00063 bool ComputeAttributes(); 00064 bool GetAttributes(vcl_vector<float>& attrs); 00065 static void GetAttributeNames(vcl_vector<vcl_string>& names); 00066 bool GetNativeAttributes(vcl_vector<float>& attrs); 00067 00068 // Data access for non-attributes 00069 vtol_intensity_face_sptr GetFace() const { return face_; } 00070 void SetFace(vtol_intensity_face_sptr f); 00071 edge_2d_list& GetEdges(); 00072 00073 //: Centroid X 00074 virtual float Xo() { return face_->Xo(); } 00075 00076 //: Centroid Y 00077 virtual float Yo() { return face_->Yo(); } 00078 00079 //: Centroid Z 00080 virtual float Zo() { return face_->Zo(); } 00081 00082 // --- 00083 // Intensity attribute computations 00084 // --- 00085 00086 //: Min intensity 00087 float IntMin() { return cached_min_; } 00088 00089 //: Max intensity 00090 float IntMax() { return cached_max_; } 00091 00092 //: Mean intensity 00093 float IntMean() { return cached_mean_; } 00094 00095 //: Intensity variance 00096 float IntVar() { return cached_var_; } 00097 00098 // --- 00099 // Geometric attribute computations 00100 // --- 00101 00102 //: Area 00103 virtual float Area() { return (float)(GetFace() ? face_->Npix() : -1); } 00104 00105 //: Ratio of major moments 00106 float AspectRatio(); 00107 00108 //: Length of boundary, in pixels 00109 float PerimeterLength(); 00110 00111 float WeightedPerimeterLength(); 00112 float Complexity(); 00113 00114 //: Edge length^2 / detection area 00115 float WeightedComplexity(); 00116 00117 float TwoPeakParallel(); 00118 float FourPeakParallel(); 00119 float EightyPercentParallel(); 00120 00121 protected: 00122 00123 void ComputeCacheValues(); 00124 void SetNP(); 00125 }; 00126 00127 typedef vbl_smart_ptr<vifa_int_face_attr> vifa_int_face_attr_sptr; 00128 00129 typedef vcl_vector<vifa_int_face_attr_sptr> attr_list; 00130 typedef vcl_vector<vifa_int_face_attr_sptr>::iterator attr_iterator; 00131 00132 00133 #endif // VIFA_INT_FACE_ATTR_H_