contrib/rpl/rgrl/rgrl_est_spline.h
Go to the documentation of this file.
00001 #ifndef rgrl_est_spline_h_
00002 #define rgrl_est_spline_h_
00003 //:
00004 // \file
00005 // \author Lee, Ying-Lin (Bess)
00006 // \date   Sept 2003
00007 
00008 #include "rgrl_estimator.h"
00009 #include "rgrl_estimator_sptr.h"
00010 #include "rgrl_mask.h"
00011 
00012 enum rgrl_optimize_method
00013 {
00014   RGRL_LEVENBERG_MARQUARDT=0,
00015   RGRL_CONJUGATE_GRADIENT=1,
00016   RGRL_AMOEBA=2,
00017   RGRL_LBFGS=3,
00018   RGRL_NONE=4,
00019   RGRL_POWELL=5
00020 };
00021 
00022 class rgrl_est_spline
00023   : public rgrl_nonlinear_estimator
00024 {
00025  public:
00026   //: Constructor
00027   //
00028   // Only B-spline estimation is performed. Neither is the global
00029   // estimation performed and nor is the global xformation used.
00030   rgrl_est_spline( unsigned dof, rgrl_mask_box const& roi, vnl_vector<double> const& delta,
00031                    vnl_vector< unsigned > const& m,
00032                    bool use_thin_plate = false, double lambda = 0.001 );
00033 
00034   //: Constructor
00035   //
00036   // global_xform is used as the global xformation. No global
00037   // estimation will be performed.
00038   rgrl_est_spline( unsigned dof, rgrl_transformation_sptr global_xform,
00039                    rgrl_mask_box const& roi, vnl_vector<double> const& delta,
00040                    vnl_vector< unsigned > const& m,
00041                    bool use_thin_plate = false, double lambda = 0.001 );
00042 
00043   rgrl_transformation_sptr
00044   estimate( rgrl_set_of<rgrl_match_set_sptr> const& matches,
00045             rgrl_transformation const& cur_transform ) const;
00046 
00047   rgrl_transformation_sptr
00048   estimate( rgrl_match_set_sptr matches,
00049             rgrl_transformation const& cur_transform ) const;
00050 
00051   //: Type of transformation estimated by this estimator.
00052   const vcl_type_info& transformation_type() const;
00053 
00054   void set_optimize_method( int optimize_method )
00055     { optimize_method_ = optimize_method; }
00056 
00057   // Defines type-related functions
00058   rgrl_type_macro( rgrl_est_spline, rgrl_nonlinear_estimator );
00059 
00060  private:
00061   void point_in_knots( vnl_vector< double > const& point, vnl_vector< double > & spline_pt ) const;
00062 
00063   rgrl_mask_box roi_;
00064   vnl_vector<double> delta_;
00065   vnl_vector<unsigned> m_;
00066   bool use_thin_plate_;
00067   // the multiplier for the thin-plate constraint
00068   double lambda_;
00069   // determine which method is used to estimate the parameters.
00070   int optimize_method_;
00071 
00072   //: A global transformation.
00073   //  If it's null, then the spline is used without other prior transformation.
00074   rgrl_transformation_sptr global_xform_;
00075 };
00076 
00077 #endif
00078