00001 #ifndef rrel_shift2d_est_h_ 00002 #define rrel_shift2d_est_h_ 00003 00004 //: 00005 // \file 00006 // \author Fred Wheeler 00007 // \date October 2002 00008 // \brief Class to maintain data and optimization model for 2d shift estimation 00009 00010 #include <vcl_vector.h> 00011 #include <vgl/vgl_fwd.h> 00012 #include <vnl/vnl_fwd.h> 00013 #include <rrel/rrel_estimation_problem.h> 00014 00015 //: Class to maintain data and optimization model for 2d shift estimation. 00016 // 00017 // This class is an adaptation of rrel_homography2d_est to compute a 00018 // 2D shift instead of a 2D homography. 00019 00020 class rrel_shift2d_est : public rrel_estimation_problem { 00021 public: 00022 00023 //: Constructor from vgl_homg_point_2d's 00024 rrel_shift2d_est( const vcl_vector< vgl_homg_point_2d<double> > & from_pts, 00025 const vcl_vector< vgl_homg_point_2d<double> > & to_pts ); 00026 00027 //: Constructor from vnl_vectors 00028 rrel_shift2d_est( const vcl_vector< vnl_vector<double> > & from_pts, 00029 const vcl_vector< vnl_vector<double> > & to_pts ); 00030 00031 //: Destructor. 00032 virtual ~rrel_shift2d_est(); 00033 00034 //: Total number of correspondences. 00035 unsigned int num_samples( ) const; 00036 00037 //: The degrees of freedom in the residual. Each coordinate has 00038 // Gaussian error, so the Euclidean distance residual has 2 degrees 00039 // of freedom. 00040 unsigned int residual_dof() const { return 2; } 00041 00042 //: Generate a parameter estimate from a minimal sample. 00043 bool fit_from_minimal_set( const vcl_vector<int>& point_indices, 00044 vnl_vector<double>& params ) const; 00045 00046 //: Compute unsigned fit residuals relative to the parameter estimate. 00047 void compute_residuals( const vnl_vector<double>& params, 00048 vcl_vector<double>& residuals ) const; 00049 00050 //: Weighted least squares parameter estimate. The normalized covariance is not yet filled in. 00051 bool weighted_least_squares_fit( vnl_vector<double>& params, 00052 vnl_matrix<double>& norm_covar, 00053 const vcl_vector<double>* weights=0 ) const; 00054 00055 protected: 00056 vcl_vector< vnl_vector< double > > del_pts_; 00057 void compute_del_pts (); 00058 00059 protected: 00060 vcl_vector< vnl_vector< double > > from_pts_; 00061 vcl_vector< vnl_vector< double > > to_pts_; 00062 }; 00063 00064 #endif // rrel_shift2d_est_h_