contrib/rpl/rrel/rrel_m_est_obj.h
Go to the documentation of this file.
00001 #ifndef rrel_m_est_obj_h_
00002 #define rrel_m_est_obj_h_
00003 
00004 //:
00005 // \file
00006 // \author Amitha Perera (perera@cs.rpi.edu)
00007 //  Generic implementation for standard m-estimators.
00008 
00009 #include <rrel/rrel_wls_obj.h>
00010 
00011 //: Generic implementation for standard M-estimators.
00012 //  Most standard M-estimators are defined by a rho and psi functions
00013 //  on a normalised residual. This class allows derived classes to
00014 //  merely implement those two functions, and implements the fcn() and
00015 //  wgt() functions based on rho() and psi(). (See Stewart, "Robust
00016 //  Parameter Estimation in Computer Vision", SIAM Reviews 41, Sept
00017 //  1999.)
00018 
00019 class rrel_m_est_obj : public rrel_wls_obj {
00020 public:
00021   //: Constructor.
00022   rrel_m_est_obj() {}
00023 
00024   //: Destructor.
00025   virtual ~rrel_m_est_obj() {}
00026 
00027 
00028   //: Evaluate the objective function on heteroscedastic residuals.
00029   //  \sa rrel_objective::fcn.
00030   virtual double fcn( vect_const_iter res_begin, vect_const_iter res_end,
00031                       vect_const_iter scale_begin,
00032                       vnl_vector<double>* = 0 /* param vector is unused */ ) const;
00033 
00034   //: Evaluate the objective function on homoscedastic residuals.  
00035   //  \sa rrel_objective::fcn.
00036   virtual double fcn( vect_const_iter begin, vect_const_iter end,
00037                       double scale,
00038                       vnl_vector<double>* = 0 /* param vector is unused */ ) const;
00039 
00040   //: Evaluate the objective function on heteroscedastic residuals.
00041   //  \sa rrel_wls_obj::wgt()
00042   virtual void wgt( vect_const_iter res_begin, vect_const_iter res_end,
00043                     vect_const_iter scale_begin,
00044                     vect_iter wgt_begin ) const;
00045 
00046   //: Computes the weights for homoscedastic residuals.  
00047   //  \sa rrel_wls_obj::wgt()
00048   virtual void wgt( vect_const_iter begin, vect_const_iter end,
00049                     double scale,
00050                     vect_iter wgt_begin ) const;
00051 
00052   //: The robust loss function for the M-estimator.
00053   //  \a u is a normalised residual (i.e. u=r/scale).
00054   virtual double rho( double u ) const = 0;
00055 
00056   //: The robust loss function for the M-estimator.
00057   //  \a r is the residual and \a s is the scale for that residual.
00058   inline  double rho( double r, double s ) const { return rho(r/s); }
00059 
00060   //: The weight of the residual.
00061   //  \a u is a normalised residual (i.e. u=r/scale). wgt(u) is
00062   //  normally \f$ (1/u) (\partial{\rho} / \partial{u}) \f$.
00063   virtual double wgt( double u ) const = 0;
00064 
00065   //: The weight of the residual.
00066   //  \a r is the residual and \a s is the scale for that residual.
00067   inline  double wgt( double r, double s ) const { return wgt(r/s)/(s*s); }
00068 
00069   //: False.
00070   //  In general, most M-estimators work quite well with an estimated
00071   //  scale. The scale estimate should be robust, but not necessarily
00072   //  efficient (e.g. MAD scale estimate.)
00073   virtual bool requires_prior_scale() const
00074     { return false; }
00075 
00076 };
00077 
00078 #endif