Go to the documentation of this file.00001 #ifndef gevd_contour_h_
00002 #define gevd_contour_h_
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 #include <vcl_vector.h>
00073 #include <vbl/vbl_array_2d.h>
00074 #include <vtol/vtol_vertex_2d_sptr.h>
00075 #include <vtol/vtol_edge_2d_sptr.h>
00076 #include <gevd/gevd_bufferxy.h>
00077 
00078 class gevd_contour
00079 {
00080  public:
00081   gevd_contour(float min_strength, int min_length, 
00082                float min_jump,         
00083                float max_gap=2.236068f); 
00084   ~gevd_contour();
00085 
00086   bool FindNetwork(gevd_bufferxy& edgels, 
00087                    const int njunction, 
00088                    const int* junctionx, const int* junctiony,
00089                    vcl_vector<vtol_edge_2d_sptr>*& edges,
00090                    vcl_vector<vtol_vertex_2d_sptr >*& vertices);
00091   void SubPixelAccuracy(vcl_vector<vtol_edge_2d_sptr>& edges, 
00092                         vcl_vector<vtol_vertex_2d_sptr >& vertices, 
00093                         const gevd_bufferxy& locationx, 
00094                         const gevd_bufferxy& locationy); 
00095   void InsertBorder(vcl_vector<vtol_edge_2d_sptr>& edges, 
00096                     vcl_vector<vtol_vertex_2d_sptr >& vertices); 
00097 
00098   static void EqualizeSpacing(vcl_vector<vtol_edge_2d_sptr>& chains); 
00099   static void Translate(vcl_vector<vtol_edge_2d_sptr>& edges, 
00100                         vcl_vector<vtol_vertex_2d_sptr >& vertices, 
00101                         const float tx=0.5, const float ty = 0.5);
00102   static void ClearNetwork(vcl_vector<vtol_edge_2d_sptr>*& edges, 
00103                            vcl_vector<vtol_vertex_2d_sptr >*& vertices); 
00104   int CheckInvariants(vcl_vector<vtol_edge_2d_sptr>& edges, 
00105                       vcl_vector<vtol_vertex_2d_sptr >& vertices);
00106 
00107   static void MaskEdgels(const gevd_bufferxy& mask, 
00108                          gevd_bufferxy& edgels, 
00109                          int& njunction, 
00110                          int* junctionx, int* junctiony);
00111   static void SetEdgelData(gevd_bufferxy& grad_mag, gevd_bufferxy& angle,
00112                            vcl_vector<vtol_edge_2d_sptr>& edges);
00113 
00114 #if 0 // commented out
00115   static int ClosedRegions(vcl_vector<vtol_edge_2d*>& edges, 
00116                            vcl_vector<vtol_vertex_2d*>& vertices); 
00117   static void SetRayOrigin(const float x, const float y);
00118   static int ClockWiseOrder(vtol_edge_2d* const& dc1, vtol_edge_2d* const& dc2);
00119 #endif
00120 
00121   static int LengthCmp(vtol_edge_2d_sptr const& dc1, vtol_edge_2d_sptr const& dc2); 
00122   static vcl_vector<vtol_edge_2d_sptr>* CreateLookupTable(vcl_vector<vtol_edge_2d_sptr>&);
00123   static void LookupTableInsert(vcl_vector<vtol_edge_2d_sptr>& set, vtol_edge_2d_sptr elmt);
00124   static void LookupTableReplace(vcl_vector<vtol_edge_2d_sptr>& set,
00125                                  vtol_edge_2d_sptr deleted, vtol_edge_2d_sptr inserted);
00126   static void LookupTableRemove(vcl_vector<vtol_edge_2d_sptr>& set, vtol_edge_2d_sptr elmt);
00127   static void LookupTableCompress(vcl_vector<vtol_edge_2d_sptr>& set);
00128 
00129   static vcl_vector<vtol_vertex_2d_sptr >* CreateLookupTable(vcl_vector<vtol_vertex_2d_sptr >&);
00130   static void LookupTableInsert(vcl_vector<vtol_vertex_2d_sptr >& set, vtol_vertex_2d_sptr  elmt);
00131   static void LookupTableReplace(vcl_vector<vtol_vertex_2d_sptr >& set,
00132                                  vtol_vertex_2d_sptr  deleted, vtol_vertex_2d_sptr  inserted);
00133   static void LookupTableRemove(vcl_vector<vtol_vertex_2d_sptr >& set, vtol_vertex_2d_sptr  elmt);
00134   static void LookupTableCompress(vcl_vector<vtol_vertex_2d_sptr >& set);
00135 
00136   static void BeSilent() {talkative = false;}
00137   static void BeTalkative() {talkative = true;}
00138  protected:
00139   float minStrength;  
00140   int minLength;      
00141   float minJump;      
00142   int maxSpiral;      
00143   vbl_array_2d<vtol_edge_2d_sptr> *edgeMap;
00144   vbl_array_2d<vtol_vertex_2d_sptr> *vertexMap; 
00145 
00146  protected:
00147   int FindChains(gevd_bufferxy& edgels, 
00148                  const int njunction, 
00149                  const int* junctionx, const int* junctiony,
00150                  vcl_vector<vtol_edge_2d_sptr>& edges);
00151   int FindJunctions(gevd_bufferxy& edgels, 
00152                     vcl_vector<vtol_edge_2d_sptr>& edges, 
00153                     vcl_vector<vtol_vertex_2d_sptr >& vertices);
00154 
00155   static bool talkative; 
00156 };
00157 
00158 #endif // gevd_contour_h_