00001 #ifndef rrel_mlesac_obj_h_ 00002 #define rrel_mlesac_obj_h_ 00003 //: 00004 // \file 00005 // \author Bess Lee (leey@cs.rpi.edu) 00006 // \date Oct 2001 00007 // 00008 // MLESAC objective function. 00009 // 00010 // \verbatim 00011 // Modifications: 00012 // 25 Oct 2001 Amitha Perera: added comments 00013 // \endverbatim 00014 00015 #include <rrel/rrel_objective.h> 00016 00017 //: MLESAC objective function. 00018 // Implements the MLESAC objective as presented in Torr and 00019 // Zisserman, CVIU 2000. The "cost" is the negative log likelihood of 00020 // the residuals, assuming that each residual is i.i.d. with a 00021 // mixture distribution (zero-mean Gaussian modeling the inliers and 00022 // uniform distribution modeling the outliers). The standard 00023 // deviation of the Gaussian is the prior scale supplied by the 00024 // problem or set in the search technique. The width of the uniform 00025 // distribution is given by \a outlier_sigma. The mixing parameter is 00026 // estimated via the EM algorithm. 00027 // 00028 // \a residual_dof is the number of "error random variables" are 00029 // combined in computing the residual. In the Torr and Zisserman 00030 // paper, for example, the residual for homography estimation results 00031 // from the combination of four errors: one in each coordinate of 00032 // each point in the correspondence pair. In general, this should be 00033 // set to rrel_estimation_problem::residual_dof(). 00034 00035 class rrel_mlesac_obj : public rrel_objective { 00036 public: 00037 //: Constructor. 00038 // \a residual_dof is the number of "error random variables" are 00039 // combined in computing the residual. In general, this should be 00040 // set to rrel_estimation_problem::residual_dof(). \a outlier_sigma 00041 // (\f$ os \f$) is the width of the outlier uniform distribution, 00042 // so that each residual has a \f$ (1-\gamma)/{os} \f$ probability of 00043 // being an outlier, where \f$ \gamma \f$ is the fraction of 00044 // inliers. \a outlier_frac is the initial value of the mixing 00045 // parameter for the EM algorithm. It can safely be left at the 00046 // default. 00047 rrel_mlesac_obj(unsigned int residual_dof, double outlier_sigma = 20.0, double outlier_frac = 0.5 ); 00048 00049 //: Destructor. 00050 ~rrel_mlesac_obj() {} 00051 00052 //: Evaluate the objective function on heteroscedastic residuals. 00053 // \sa rrel_objective::fcn. 00054 virtual double fcn(vect_const_iter res_begin, vect_const_iter res_end, 00055 vect_const_iter scale_begin, 00056 vnl_vector<double>* param_vector=0 ) const; 00057 00058 //: Evaluate the objective function on homoscedastic residuals. 00059 // \sa rrel_objective::fcn. 00060 virtual double fcn(vect_const_iter begin, vect_const_iter end, 00061 double scale, 00062 vnl_vector<double>* param_vector=0 ) const; 00063 00064 //: True. 00065 // The MLESAC algorithm is sensitive to the scale, and requires a prior scale. 00066 virtual bool requires_prior_scale() const 00067 { return true; } 00068 00069 protected: 00070 double outlier_sigma_; 00071 double outlier_frac_; 00072 unsigned int residual_dof_; 00073 }; 00074 00075 #endif // rrel_mlesac_obj_h_