Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
rrel_ran_sam_search Class Reference

Random sampling search for minimization of a robust objective function. More...

#include <rrel_ran_sam_search.h>

Inheritance diagram for rrel_ran_sam_search:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 rrel_ran_sam_search ()
 Constructor using a non-deterministic random-sampling seed.
 rrel_ran_sam_search (int seed)
 Constructor using a given random-sampling seed.
virtual ~rrel_ran_sam_search ()
void set_gen_all_samples ()
 Indicate that all possible minimal subset samples should be tried.
void set_sampling_params (double max_outlier_frac=0.5, double desired_prob_good=0.99, unsigned int max_populations_expected=1, unsigned int min_samples=0)
 Set the parameters for random sampling.
virtual bool estimate (const rrel_estimation_problem *problem, const rrel_objective *obj_fcn)
 Estimation for an "ordinary" estimation problem.
double scale () const
 Get the scale estimate.
const vnl_vector< double > & params () const
 Get the parameter estimate.
const vcl_vector< int > & index () const
 Get the indices of best data sample.
const vcl_vector< double > & residuals () const
 Get the residuals for best sample.
double cost () const
 Get the cost for best sample returned by rrel_objective function.
int samples_tested () const
 Get the number of samples tested in during estimation.
void print_params () const
 Print the sampling parameters. Used for debugging.
void set_trace_level (int level)

Protected Member Functions

virtual void calc_num_samples (const rrel_estimation_problem *problem)
 Calculate number of samples --- non-unique matching estimation problems.
virtual void next_sample (unsigned int taken, unsigned int num_points, vcl_vector< int > &sample, unsigned int points_per_sample)
 Determine the next random sample, filling in the "sample" vector.

Protected Attributes

double max_outlier_frac_
double desired_prob_good_
unsigned int max_populations_expected_
unsigned int min_samples_
bool generate_all_
vnl_randomgenerator_
 Random number generator.
bool own_generator_
vnl_vector< double > params_
double scale_
vcl_vector< int > indices_
vcl_vector< double > residuals_
double min_obj_
unsigned int samples_to_take_
int trace_level_

Private Member Functions

void trace_sample (const vcl_vector< int > &point_indices) const
void trace_residuals (const vcl_vector< double > &residuals) const

Detailed Description

Random sampling search for minimization of a robust objective function.

The code organization follows the design of the rrel library where there is a separation between objective function (M-estimator, LMS, etc), search technique, and estimation problem. See discussion in rrel_estimation_problem.

The algorithm implemented was discovered independently by Fischler and Bolles in the CACM RANSAC paper from 1981 and Rousseeuw in a Journal of the American Statistical Association paper from 1984. The implementation follows Rousseeuw's approach by not allowing the short-circuiting of RANSAC, which can cause incorrect results for a large number of outliers.

The number of samples taken is computed to accommodate the possibility of more than one population in the data, as described in Stewart, PAMI 1995. It is a relatively straightforward generalization of the ordinary method for calculating the number of samples.

Using this class requires calling set_sampling_params (or set_gen_all_samples, which can be quite expensive), and then calling estimate(). Results may be obtained through the functions params() and scale().

Definition at line 40 of file rrel_ran_sam_search.h.


Constructor & Destructor Documentation

rrel_ran_sam_search::rrel_ran_sam_search ( )

Constructor using a non-deterministic random-sampling seed.

Definition at line 20 of file rrel_ran_sam_search.cxx.

rrel_ran_sam_search::rrel_ran_sam_search ( int  seed)

Constructor using a given random-sampling seed.

Definition at line 31 of file rrel_ran_sam_search.cxx.

rrel_ran_sam_search::~rrel_ran_sam_search ( ) [virtual]

Definition at line 43 of file rrel_ran_sam_search.cxx.


Member Function Documentation

void rrel_ran_sam_search::calc_num_samples ( const rrel_estimation_problem problem) [protected, virtual]

Calculate number of samples --- non-unique matching estimation problems.

Definition at line 186 of file rrel_ran_sam_search.cxx.

double rrel_ran_sam_search::cost ( ) const [inline]

Get the cost for best sample returned by rrel_objective function.

Definition at line 90 of file rrel_ran_sam_search.h.

bool rrel_ran_sam_search::estimate ( const rrel_estimation_problem problem,
const rrel_objective obj_fcn 
) [virtual]

Estimation for an "ordinary" estimation problem.

Reimplemented in rrel_wgted_ran_sam_search.

Definition at line 75 of file rrel_ran_sam_search.cxx.

const vcl_vector<int>& rrel_ran_sam_search::index ( ) const [inline]

Get the indices of best data sample.

Definition at line 84 of file rrel_ran_sam_search.h.

void rrel_ran_sam_search::next_sample ( unsigned int  taken,
unsigned int  num_points,
vcl_vector< int > &  sample,
unsigned int  points_per_sample 
) [protected, virtual]

Determine the next random sample, filling in the "sample" vector.

Reimplemented in rrel_wgted_ran_sam_search.

Definition at line 220 of file rrel_ran_sam_search.cxx.

const vnl_vector<double>& rrel_ran_sam_search::params ( ) const [inline]

Get the parameter estimate.

Definition at line 81 of file rrel_ran_sam_search.h.

void rrel_ran_sam_search::print_params ( ) const

Print the sampling parameters. Used for debugging.

Definition at line 282 of file rrel_ran_sam_search.cxx.

const vcl_vector<double>& rrel_ran_sam_search::residuals ( ) const [inline]

Get the residuals for best sample.

Definition at line 87 of file rrel_ran_sam_search.h.

int rrel_ran_sam_search::samples_tested ( ) const [inline]

Get the number of samples tested in during estimation.

Definition at line 93 of file rrel_ran_sam_search.h.

double rrel_ran_sam_search::scale ( ) const [inline]

Get the scale estimate.

Definition at line 78 of file rrel_ran_sam_search.h.

void rrel_ran_sam_search::set_gen_all_samples ( )

Indicate that all possible minimal subset samples should be tried.

Definition at line 52 of file rrel_ran_sam_search.cxx.

void rrel_ran_sam_search::set_sampling_params ( double  max_outlier_frac = 0.5,
double  desired_prob_good = 0.99,
unsigned int  max_populations_expected = 1,
unsigned int  min_samples = 0 
)

Set the parameters for random sampling.

Definition at line 60 of file rrel_ran_sam_search.cxx.

void rrel_ran_sam_search::set_trace_level ( int  level) [inline]

Definition at line 98 of file rrel_ran_sam_search.h.

void rrel_ran_sam_search::trace_residuals ( const vcl_vector< double > &  residuals) const [private]

Definition at line 304 of file rrel_ran_sam_search.cxx.

void rrel_ran_sam_search::trace_sample ( const vcl_vector< int > &  point_indices) const [private]

Definition at line 294 of file rrel_ran_sam_search.cxx.


Member Data Documentation

Definition at line 125 of file rrel_ran_sam_search.h.

Definition at line 128 of file rrel_ran_sam_search.h.

Random number generator.

Normally, this will point to the "global" generator, but a could point to a local one if the user wants to specify a seed.

Definition at line 133 of file rrel_ran_sam_search.h.

vcl_vector<int> rrel_ran_sam_search::indices_ [protected]

Definition at line 141 of file rrel_ran_sam_search.h.

Definition at line 124 of file rrel_ran_sam_search.h.

Definition at line 126 of file rrel_ran_sam_search.h.

double rrel_ran_sam_search::min_obj_ [protected]

Definition at line 144 of file rrel_ran_sam_search.h.

unsigned int rrel_ran_sam_search::min_samples_ [protected]

Definition at line 127 of file rrel_ran_sam_search.h.

Definition at line 134 of file rrel_ran_sam_search.h.

Definition at line 139 of file rrel_ran_sam_search.h.

vcl_vector<double> rrel_ran_sam_search::residuals_ [protected]

Definition at line 142 of file rrel_ran_sam_search.h.

unsigned int rrel_ran_sam_search::samples_to_take_ [protected]

Definition at line 148 of file rrel_ran_sam_search.h.

double rrel_ran_sam_search::scale_ [protected]

Definition at line 140 of file rrel_ran_sam_search.h.

Definition at line 150 of file rrel_ran_sam_search.h.


The documentation for this class was generated from the following files: