Go to the documentation of this file.00001 #ifndef rgrl_trans_spline_h_
00002 #define rgrl_trans_spline_h_
00003
00004
00005
00006
00007
00008
00009 #include "rgrl_transformation.h"
00010 #include "rgrl_spline.h"
00011 #include "rgrl_spline_sptr.h"
00012 #include <vnl/vnl_vector.h>
00013 #include <vnl/vnl_matrix.h>
00014 #include <vcl_vector.h>
00015 #include <vcl_iosfwd.h>
00016
00017 class rgrl_trans_spline
00018 : public rgrl_transformation
00019 {
00020 public:
00021
00022
00023
00024 rgrl_trans_spline(unsigned int dim = 0);
00025
00026
00027 rgrl_trans_spline( vcl_vector<rgrl_spline_sptr> const& splines,
00028 vnl_vector< double > const& x0, vnl_vector< double > const& delta,
00029 rgrl_transformation_sptr xform = 0 );
00030
00031 rgrl_trans_spline( vcl_vector<rgrl_spline_sptr> const& splines,
00032 vnl_vector< double > const& x0, vnl_vector< double > const& delta,
00033 vnl_matrix< double > const& covar,
00034 rgrl_transformation_sptr xform = 0 );
00035
00036 ~rgrl_trans_spline() {}
00037
00038 vnl_vector< double > const& get_delta() const { return delta_; }
00039 void set_covar( vnl_matrix<double> const& cov ) { covar_ = cov; }
00040
00041 vnl_matrix<double> transfer_error_covar( vnl_vector<double> const& p ) const;
00042
00043 rgrl_transformation_sptr get_global_xform( ) const { return xform_; }
00044 rgrl_spline_sptr get_spline( unsigned i ) const { return splines_[i]; }
00045
00046
00047 virtual void jacobian_wrt_loc( vnl_matrix<double>& jac, vnl_vector<double> const& from_loc ) const;
00048
00049
00050 friend class test_rgrl_trans_spline;
00051
00052
00053 void write( vcl_ostream& os ) const;
00054
00055
00056 bool read( vcl_istream& is );
00057
00058
00059 rgrl_transformation_sptr clone() const;
00060
00061
00062 rgrl_type_macro( rgrl_trans_spline, rgrl_transformation);
00063
00064 protected:
00065 void map_loc( vnl_vector<double> const& from,
00066 vnl_vector<double> & to ) const;
00067
00068 void map_dir( vnl_vector<double> const& from_loc,
00069 vnl_vector<double> const& from_dir,
00070 vnl_vector<double> & to_dir) const;
00071
00072 private:
00073 void point_in_knots( vnl_vector< double > const& point, vnl_vector< double > & spline_pt ) const;
00074
00075
00076
00077 rgrl_transformation_sptr xform_;
00078
00079
00080
00081 vcl_vector<rgrl_spline_sptr> splines_;
00082
00083
00084
00085
00086
00087
00088 vnl_vector<double> x0_;
00089 vnl_vector<double> delta_;
00090
00091
00092 virtual void inv_map(vnl_vector<double> const&, bool,
00093 vnl_vector<double> const&, vnl_vector<double>&, vnl_vector<double>&) const;
00094 virtual void inv_map(vnl_vector<double> const&, vnl_vector<double>&) const;
00095 virtual rgrl_transformation_sptr inverse_transform() const;
00096 virtual rgrl_transformation_sptr scale_by(double) const;
00097 };
00098
00099 #endif