Go to the documentation of this file.00001 #ifndef rgrl_transformation_h_
00002 #define rgrl_transformation_h_
00003
00004
00005
00006
00007
00008
00009 #include <vnl/vnl_vector.h>
00010 #include <vnl/vnl_matrix.h>
00011 #include <vcl_iosfwd.h>
00012
00013 #include <rgrl/rgrl_object.h>
00014 #include <rgrl/rgrl_set_of.h>
00015 #include <rgrl/rgrl_match_set_sptr.h>
00016
00017 #include <rgrl/rgrl_transformation_sptr.h>
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class rgrl_transformation
00034 : public rgrl_object
00035 {
00036 public:
00037 virtual ~rgrl_transformation();
00038
00039
00040 rgrl_transformation() : is_covar_set_(false) { }
00041
00042
00043 rgrl_transformation( const vnl_matrix<double>& cov );
00044
00045
00046 void map_location( vnl_vector<double> const& from,
00047 vnl_vector<double> & to ) const;
00048
00049
00050
00051
00052
00053
00054 vnl_vector<double> map_location( vnl_vector<double> const& p ) const;
00055
00056
00057
00058
00059
00060 virtual void map_tangent( vnl_vector<double> const& from_loc,
00061 vnl_vector<double> const& from_dir,
00062 vnl_vector<double> & to_dir ) const;
00063
00064
00065
00066
00067
00068 virtual void map_normal( vnl_vector<double> const & from_loc,
00069 vnl_vector<double> const & from_dir,
00070 vnl_vector<double> & to_dir ) const;
00071
00072
00073
00074
00075
00076 virtual void map_normal( vnl_vector<double> const & from_loc,
00077 vnl_vector<double> const & from_dir,
00078 vnl_matrix< double > const& tangent_subspace,
00079 vnl_vector<double> & to_dir ) const;
00080
00081
00082
00083
00084
00085
00086 void map_direction( vnl_vector<double> const& from_loc,
00087 vnl_vector<double> const& from_dir,
00088 vnl_vector<double> & to_dir ) const;
00089
00090 #if 0
00091
00092
00093
00094
00095
00096 vnl_vector<double> map_direction( vnl_vector<double> const& from_loc,
00097 vnl_vector<double> const& from_dir ) const;
00098 #endif // 0
00099
00100
00101 virtual
00102 double map_intensity( vnl_vector<double> const& from, double intensity ) const;
00103
00104
00105
00106
00107
00108
00109 virtual
00110 vnl_matrix<double> transfer_error_covar( vnl_vector<double> const& p ) const = 0;
00111
00112
00113
00114 virtual void inv_map( const vnl_vector<double>& to,
00115 bool initialize_next,
00116 const vnl_vector<double>& to_delta,
00117 vnl_vector<double>& from,
00118 vnl_vector<double>& from_next_est) const;
00119
00120
00121 vnl_matrix<double> covar() const;
00122
00123
00124 virtual double
00125 log_det_covar() const;
00126
00127
00128 void set_covar( const vnl_matrix<double>& covar );
00129
00130
00131 bool is_covar_set() const { return is_covar_set_; }
00132
00133
00134
00135 virtual void inv_map( const vnl_vector<double>& to,
00136 vnl_vector<double>& from ) const;
00137
00138
00139 virtual bool is_invertible() const { return false; }
00140
00141
00142
00143 virtual rgrl_transformation_sptr inverse_transform() const;
00144
00145
00146
00147 vnl_matrix<double> jacobian( vnl_vector<double> const& from_loc ) const;
00148
00149
00150 virtual void jacobian_wrt_loc( vnl_matrix<double>& jac, vnl_vector<double> const& from_loc ) const = 0;
00151
00152
00153 virtual rgrl_transformation_sptr scale_by( double scale ) const = 0;
00154
00155
00156 virtual void write( vcl_ostream& os ) const;
00157
00158
00159 virtual bool read( vcl_istream& is );
00160
00161
00162 virtual rgrl_transformation_sptr clone() const=0;
00163
00164
00165
00166
00167 void set_scaling_factors( vnl_vector<double> const& scaling );
00168
00169
00170 const vnl_vector<double>& scaling_factors() const { return scaling_factors_; }
00171
00172
00173 rgrl_type_macro( rgrl_transformation, rgrl_object );
00174
00175
00176 protected:
00177
00178
00179
00180 virtual
00181 void map_loc( vnl_vector<double> const& from,
00182 vnl_vector<double> & to ) const = 0;
00183
00184
00185
00186
00187
00188 virtual
00189 void map_dir( vnl_vector<double> const& from_loc,
00190 vnl_vector<double> const& from_dir,
00191 vnl_vector<double> & to_dir ) const = 0;
00192
00193
00194 double
00195 log_det_sym_matrix( vnl_matrix<double> const& m ) const;
00196
00197
00198 double
00199 log_det_covar_deficient( int rank ) const;
00200
00201 protected:
00202
00203
00204
00205 vnl_matrix<double> covar_;
00206
00207
00208
00209 bool is_covar_set_;
00210
00211
00212
00213
00214 vnl_vector<double> scaling_factors_;
00215 };
00216
00217 vcl_ostream&
00218 operator<< (vcl_ostream& os, rgrl_transformation const& xform );
00219
00220 #endif