contrib/rpl/rgrl/rgrl_weighter_m_est.h
Go to the documentation of this file.
00001 #ifndef rgrl_weighter_m_est_h_
00002 #define rgrl_weighter_m_est_h_
00003 //:
00004 // \file
00005 // \brief  Compute weights in the manner described in the IMCF algorithm
00006 // \author Chuck Stewart
00007 // \date   25 Nov 2002
00008 //
00009 // 20 Sept 2003, CS:  Added the possibility that the intensity and signature
00010 //  weights are pre-computed.  I am not sure that this is the most
00011 //  appropriate way to handle this.  The weighting could be moved
00012 //  into the matching stage, but then the matcher needs to know
00013 //  whether or not to set the weights.
00014 //
00015 // 27 Jan 2004, CT: Intensity is no long considered. The class allows
00016 // the freedom of using the absolute signature weight computed
00017 // somewhere else (\a use_precomputed_signature_wgt ), or the robust
00018 // signature weight from the signature error vector of a match (\a
00019 // use_signature_error ), or neither. \a use_precomputed_signature_wgt
00020 // has precedence over \a use_signature_error.
00021 //
00022 
00023 #include <vcl_memory.h>
00024 class rrel_m_est_obj;
00025 class rgrl_transformation;
00026 
00027 #include "rgrl_weighter.h"
00028 
00029 class rgrl_weighter_m_est
00030   : public rgrl_weighter
00031 {
00032  public:
00033   //:  constructor takes a pointer to M estimator objective function
00034   rgrl_weighter_m_est( vcl_auto_ptr<rrel_m_est_obj>  m_est,
00035                        bool                          use_signature_error,
00036                        bool                          use_precomputed_signature_wgt = false );
00037 
00038   ~rgrl_weighter_m_est();
00039 
00040   //: set true if desires to weight more on distinct match
00041   void set_weight_more_on_distinct_match( bool flag )
00042   {    weight_more_on_distinct_match_ = flag; }
00043   
00044   virtual
00045   void
00046   compute_weights( rgrl_scale const&  scale,
00047                    rgrl_match_set&    match_set ) const;
00048 
00049   // Defines type-related functions
00050   rgrl_type_macro( rgrl_weighter_m_est, rgrl_weighter );
00051 
00052   // Auxiliary functions related to the m_est
00053   virtual
00054   double 
00055   aux_sum_weighted_residuals( rgrl_scale const&  scale,
00056                               rgrl_match_set&    match_set,
00057                               rgrl_transformation const&  xform );
00058   virtual
00059   double
00060   aux_sum_rho_values( rgrl_scale const&  scale,
00061                       rgrl_match_set&    match_set,
00062                       rgrl_transformation const&  xform);
00063   virtual
00064   double 
00065   aux_neg_log_likelihood( rgrl_scale const&  scale,
00066                           rgrl_match_set&    match_set,
00067                           rgrl_transformation const&  xform );
00068 
00069   virtual
00070   double 
00071   aux_avg_neg_log_likelihood( rgrl_scale const&  scale,
00072                               rgrl_match_set&    match_set,
00073                               rgrl_transformation const&  xform );
00074 
00075  protected:
00076   vcl_auto_ptr<rrel_m_est_obj> m_est_;
00077   bool use_signature_error_;
00078   bool signature_precomputed_;
00079   bool weight_more_on_distinct_match_;
00080 };
00081 
00082 #endif
00083 
00084