contrib/rpl/rgrl/rgrl_trans_translation.h
Go to the documentation of this file.
00001 #ifndef rgrl_trans_translation_h_
00002 #define rgrl_trans_translation_h_
00003 //:
00004 // \file
00005 // \brief Derived class to represent a translation transformation in arbitrary dimensions.
00006 // \author Charlene Tsai
00007 // \date Dec 2003
00008 
00009 #include "rgrl_transformation.h"
00010 #include <vcl_iosfwd.h>
00011 
00012 class rgrl_trans_translation
00013   : public rgrl_transformation
00014 {
00015  public:
00016   //: Initialize to the identity transformation.
00017   //
00018   rgrl_trans_translation(unsigned int dimension = 0);
00019 
00020   //: Construct translation standard transform
00021   //
00022   //  The transform is q = p + \a trans.
00023   //
00024   rgrl_trans_translation( vnl_vector<double> const& trans,
00025                           vnl_matrix<double> const& covar );
00026 
00027   //: Construct translation standard transform with unknown covariance matrix
00028   //
00029   //  The transform is q = p + \a trans.
00030   //  The covariance matrix is set to 0 vector.
00031   //
00032   rgrl_trans_translation( vnl_vector<double> const& trans );
00033 
00034   //: Construct a centered translation transform.
00035   //
00036   //  The transform is q = ( p - \a from_centre ) + \a trans + \a to_centre.
00037   //
00038   rgrl_trans_translation( vnl_vector<double> const& trans,
00039                           vnl_matrix<double> const& covar,
00040                           vnl_vector<double> const& from_centre,
00041                           vnl_vector<double> const& to_centre );
00042 
00043   vnl_matrix<double> transfer_error_covar( vnl_vector<double> const& p  ) const;
00044 
00045   //: The translation component of the translation transform
00046   vnl_vector<double> t() const;
00047 
00048   //:  Inverse map with an initial guess
00049   void inv_map( const vnl_vector<double>& to,
00050                 bool initialize_next,
00051                 const vnl_vector<double>& to_delta,
00052                 vnl_vector<double>& from,
00053                 vnl_vector<double>& from_next_est) const;
00054 
00055   //:  Inverse map based on the transformation.
00056   void inv_map( const vnl_vector<double>& to,
00057                 vnl_vector<double>& from ) const;
00058 
00059   //: is this an invertible transformation?
00060   virtual bool is_invertible() const { return true; }
00061 
00062   //: Return an inverse transformation
00063   //  This function only exist for certain transformations.
00064   virtual rgrl_transformation_sptr inverse_transform() const;
00065 
00066   //: Compute jacobian w.r.t. location
00067   virtual void jacobian_wrt_loc( vnl_matrix<double>& jac, vnl_vector<double> const& from_loc ) const;
00068 
00069   //:  transform the transformation for images of different resolution
00070   rgrl_transformation_sptr scale_by( double scale ) const;
00071 
00072   // Defines type-related functions
00073   rgrl_type_macro( rgrl_trans_translation, rgrl_transformation );
00074 
00075   // for output
00076   void write(vcl_ostream& os ) const;
00077 
00078   // for input
00079   bool read(vcl_istream& is );
00080 
00081   //: make a clone copy
00082   rgrl_transformation_sptr clone() const;
00083 
00084  protected:
00085   void map_loc( vnl_vector<double> const& from,
00086                 vnl_vector<double>      & to ) const;
00087 
00088   void map_dir( vnl_vector<double> const& from_loc,
00089                 vnl_vector<double> const& from_dir,
00090                 vnl_vector<double>      & to_dir    ) const;
00091 
00092  private:
00093   vnl_vector<double> trans_;
00094   vnl_vector<double> from_centre_;
00095 };
00096 
00097 
00098 #endif