00001 // This is gel/vifa/vifa_group_pgram.h 00002 #ifndef VIFA_GROUP_PGRAM_H 00003 #define VIFA_GROUP_PGRAM_H 00004 00005 //----------------------------------------------------------------------------- 00006 //: 00007 // \file 00008 // \brief Process-type class to find groups of approximately parallel lines. 00009 // 00010 // The vifa_group_pgram class is a grouper which finds relatively parallellogram- 00011 // like shapes. That is, there are groups of parallel line segments having 00012 // projection overlap 00013 // 00014 // \author J.L. Mundy (11/27/1998) 00015 // 00016 // \verbatim 00017 // Modifications: 00018 // MPP Jun 2003, Ported to VXL from TargetJr 00019 // \endverbatim 00020 //----------------------------------------------------------------------------- 00021 00022 #include <vcl_vector.h> 00023 #include <vifa/vifa_bbox.h> 00024 #include <vifa/vifa_group_pgram_params.h> 00025 #include <vifa/vifa_histogram.h> 00026 #include <vifa/vifa_line_cover.h> 00027 #include <vifa/vifa_typedefs.h> 00028 00029 00030 class vifa_group_pgram : public vifa_group_pgram_params 00031 { 00032 int th_dim_; 00033 double angle_range_; 00034 00035 //: Array of dominant theta indices 00036 vcl_vector<int> dominant_dirs_; 00037 00038 vifa_bbox_sptr bb_; 00039 imp_line_table curves_; 00040 double tmp1_; 00041 00042 public: 00043 // Constructors and Destructors 00044 vifa_group_pgram(imp_line_list& lg, 00045 const vifa_group_pgram_params& old_params, 00046 double angle_range = 180.0 00047 ); 00048 ~vifa_group_pgram(); 00049 00050 // Index insertion 00051 void Index(imp_line_sptr il); 00052 void Index(imp_line_list& lg); 00053 void Clear(); 00054 00055 // Data accessors 00056 vifa_histogram_sptr GetCoverageHist(void); 00057 vifa_line_cover_sptr GetLineCover(int angle_bin); 00058 double LineCoverage(int angle_bin); 00059 void CollectAdjacentLines(int angle_bin, 00060 imp_line_list& lg 00061 ); 00062 vifa_bbox_sptr GetBoundingBox(void); 00063 void SetTemp1(const double tmp) { tmp1_ = tmp; } 00064 double GetAdjacentPerimeter(int bin); 00065 double norm_parallel_line_length(void); 00066 00067 protected: 00068 int AngleLoc(imp_line_sptr il); 00069 imp_line_sptr LineAtAngle(int angle_bin); 00070 void CheckUpdateBoundingBox(void); 00071 void ComputeBoundingBox(void); 00072 void ComputeDominantDirs(void); 00073 }; 00074 00075 // Test consistency of bound 00076 inline void vifa_group_pgram:: 00077 CheckUpdateBoundingBox(void) 00078 { 00079 if (!bb_ ) 00080 { 00081 bb_ = new vifa_bbox; 00082 this->ComputeBoundingBox(); 00083 return; 00084 } 00085 00086 if (bb_->older(this)) 00087 this->ComputeBoundingBox(); 00088 } 00089 00090 inline vifa_bbox_sptr vifa_group_pgram:: 00091 GetBoundingBox(void) 00092 { 00093 this->CheckUpdateBoundingBox(); 00094 return bb_; 00095 } 00096 00097 00098 #endif // VIFA_GROUP_PGRAM_H