Go to the documentation of this file.00001 #ifndef rgrl_initializer_ran_sam_h_
00002 #define rgrl_initializer_ran_sam_h_
00003
00004
00005
00006
00007
00008
00009 #include "rgrl_initializer.h"
00010 #include "rgrl_match_set_sptr.h"
00011 #include "rgrl_scale_sptr.h"
00012 #include "rgrl_estimator_sptr.h"
00013 #include "rgrl_scale_estimator_sptr.h"
00014 #include "rgrl_mask.h"
00015
00016 #include <vcl_vector.h>
00017
00018 class vnl_random;
00019
00020
00021
00022
00023
00024
00025 class rgrl_initializer_ran_sam
00026 : public rgrl_initializer
00027 {
00028 public:
00029
00030 rgrl_initializer_ran_sam( );
00031
00032
00033 rgrl_initializer_ran_sam( int seed );
00034
00035 virtual
00036 ~rgrl_initializer_ran_sam();
00037
00038
00039
00040
00041
00042
00043 void set_gen_all_samples();
00044
00045
00046 void set_sampling_params( double max_outlier_frac = 0.5,
00047 double desired_prob_good = 0.99,
00048 unsigned int max_populations_expected = 1,
00049 unsigned int min_samples = 0 );
00050
00051
00052
00053
00054
00055
00056
00057 void set_data(rgrl_match_set_sptr init_match_set,
00058 rgrl_scale_estimator_unwgted_sptr scale_est,
00059 rgrl_view_sptr prior_view,
00060 bool should_estimate_global_region = true);
00061
00062
00063 void set_data(rgrl_match_set_sptr init_match_set,
00064 rgrl_scale_estimator_unwgted_sptr scale_est,
00065 rgrl_mask_sptr const& from_image_roi,
00066 rgrl_mask_sptr const& to_image_roi,
00067 rgrl_mask_box const& initial_from_image_roi,
00068 rgrl_estimator_sptr xform_estimator,
00069 unsigned initial_resolution = 0,
00070 bool should_estimate_global_region = true);
00071
00072
00073 void set_data(rgrl_match_set_sptr init_match_set,
00074 rgrl_scale_estimator_unwgted_sptr scale_est,
00075 rgrl_mask_sptr const& from_image_roi,
00076 rgrl_mask_sptr const& to_image_roi,
00077 rgrl_estimator_sptr xform_estimator,
00078 unsigned initial_resolution = 0);
00079
00080
00081
00082 void set_data(rgrl_match_set_sptr init_match_set,
00083 rgrl_scale_estimator_unwgted_sptr scale_est,
00084 rgrl_mask_sptr const& from_image_roi,
00085 rgrl_estimator_sptr xform_estimator,
00086 unsigned initial_resolution = 0);
00087
00088
00089
00090 bool next_initial( rgrl_view_sptr & view,
00091 rgrl_scale_sptr & prior_scale);
00092
00093
00094 rgrl_scale_sptr scale() const { return scale_; }
00095
00096
00097 rgrl_transformation_sptr transformation() const { return xform_; }
00098
00099
00100 int samples_tested() const { return samples_to_take_; }
00101
00102
00103 rgrl_type_macro( rgrl_initializer_ran_sam, rgrl_initializer );
00104
00105 private:
00106
00107 bool estimate();
00108
00109
00110
00111 void calc_num_samples( unsigned int num_matches );
00112
00113
00114 void next_sample( unsigned int taken, unsigned int num_points,
00115 vcl_vector<int>& sample,
00116 unsigned int points_per_sample );
00117
00118
00119 rgrl_match_set_sptr get_matches(const vcl_vector<int>& point_indices, unsigned int total_num_matches);
00120
00121
00122 void trace_sample( const vcl_vector<int>& point_indices ) const;
00123
00124
00125
00126 virtual int size() const
00127 { return -1;}
00128
00129 protected:
00130 rgrl_match_set_sptr match_set_;
00131 rgrl_estimator_sptr transform_estiamtor_;
00132 rgrl_scale_estimator_unwgted_sptr scale_estimator_;
00133 rgrl_view_sptr init_view_;
00134 bool called_before_;
00135 bool data_set_;
00136
00137
00138 private:
00139
00140
00141 double max_outlier_frac_;
00142 double desired_prob_good_;
00143 unsigned int max_populations_expected_;
00144 unsigned int min_samples_;
00145 bool generate_all_;
00146 bool should_estimate_global_region_;
00147
00148
00149
00150
00151 vnl_random* generator_;
00152 bool own_generator_;
00153
00154
00155
00156 rgrl_transformation_sptr xform_;
00157 rgrl_scale_sptr scale_;
00158
00159
00160
00161 unsigned int samples_to_take_;
00162 };
00163
00164 #endif