00001 #ifndef rgrl_matcher_k_nearest_random_h_ 00002 #define rgrl_matcher_k_nearest_random_h_ 00003 //: 00004 // \file 00005 // \author Gehua Yang 00006 // \date March 2005 00007 00008 #include <rgrl/rgrl_matcher_k_nearest.h> 00009 #include <vnl/vnl_random.h> 00010 #include <vcl_stlfwd.h> 00011 00012 //: For each "from" feature, match the k nearest "to" features. 00013 // 00014 // This is the randomized version of k-nearest. The main point 00015 // is with enough samples, we can sample some of them. Still getting 00016 // good alignment wo/ performance penalty. 00017 // 00018 class rgrl_matcher_k_nearest_random 00019 : public rgrl_matcher_k_nearest 00020 { 00021 public: 00022 //: Initialize the matcher to select \a k correspondences per "from" feature. 00023 // 00024 rgrl_matcher_k_nearest_random( unsigned int k, unsigned int max_num ); 00025 00026 //: Select at most \a k correspondences within the threshold. 00027 // 00028 // The matcher will select \a k correspondences from the list of 00029 // correspondences with Euclidean distance within the threshold 00030 // \a dist_thres. 00031 // 00032 rgrl_matcher_k_nearest_random( unsigned int k, unsigned int max_num, double dist_thres ); 00033 00034 rgrl_match_set_sptr 00035 compute_matches( rgrl_feature_set const& from_features, 00036 rgrl_feature_set const& to_features, 00037 rgrl_view const& current_view, 00038 rgrl_transformation const& current_xform, 00039 rgrl_scale const& /* current_scale */, 00040 rgrl_match_set_sptr const& old_matches = 0 ); 00041 00042 // Defines type-related functions 00043 rgrl_type_macro( rgrl_matcher_k_nearest_random, rgrl_matcher); 00044 00045 protected: 00046 00047 void generate_random_indices( vcl_vector<bool>& to_use ) const; 00048 00049 protected: 00050 unsigned int max_num_; 00051 mutable vnl_random random_; 00052 }; 00053 00054 #endif // rgrl_matcher_k_nearest_random_h_