contrib/rpl/rgrl/rgrl_matcher_k_nearest_boundary.h
Go to the documentation of this file.
00001 #ifndef rgrl_matcher_k_nearest_boundary_h_
00002 #define rgrl_matcher_k_nearest_boundary_h_
00003 //:
00004 // \file
00005 // \author Charlene Tsai
00006 // \date   Sep 2003
00007 
00008 #include "rgrl_matcher_k_nearest.h"
00009 #include "rgrl_feature_sptr.h"
00010 
00011 #include <vcl_vector.h>
00012 #include <vbl/vbl_array_2d.h>
00013 
00014 //: For each "from" feature, match the boundary points with the k nearest "to" features.
00015 //
00016 // Allows the same operations as for rgrl_matcher_k_nearest. For each
00017 // center-location match, boundary points are extracted and stored as
00018 // 2 matches.
00019 //
00020 // FIXME: only deal with 2D for now.
00021 //
00022 class rgrl_matcher_k_nearest_boundary
00023   : public rgrl_matcher_k_nearest
00024 {
00025  public:
00026   //: Initialize the matcher to select \a k correspondences per "from" feature.
00027   //
00028   rgrl_matcher_k_nearest_boundary( unsigned int k );
00029 
00030   //: Select at most \a k correspondences within the threshold.
00031   //
00032   // The matcher will select \a k correspondences from the list of
00033   // correspondences with Euclidean distance within the threshold
00034   // \a dist_thres.
00035   //
00036   rgrl_matcher_k_nearest_boundary( unsigned int k, double dist_thres );
00037 
00038   rgrl_match_set_sptr
00039   compute_matches( rgrl_feature_set const&       from_features,
00040                    rgrl_feature_set const&       to_features,
00041                    rgrl_view const&              current_view,
00042                    rgrl_transformation const&    current_xform,
00043                    rgrl_scale const&             /* current_scale */,
00044                    rgrl_match_set_sptr const& old_matches = 0 );
00045 
00046   // Defines type-related functions
00047   rgrl_type_macro( rgrl_matcher_k_nearest_boundary, rgrl_matcher_k_nearest);
00048 
00049  private:
00050   typedef vcl_vector<rgrl_feature_sptr >  feature_vector;
00051 
00052 
00053   vbl_array_2d<bool>
00054   match_boundary_pts(feature_vector const&  mapped_bd_pts,
00055                      feature_vector const&  to_boundary_pts) const;
00056 
00057   //: Use dynamic programming to find the assignment matrix that gives the minimum sum of squared residuals for the correct matching
00058   vbl_array_2d<bool>
00059   match_boundary_pts_helper(vbl_array_2d<double> const&  dist_error,
00060                             vbl_array_2d<bool> const&    valid,
00061                             int                          count,
00062                             double&                      obj_value) const;
00063 };
00064 
00065 #endif // rgrl_matcher_k_nearest_boundary_h_