Represents a rigid transformation. More...
#include <rgrl_trans_rigid.h>
Public Member Functions | |
rgrl_trans_rigid (unsigned int dimension=0) | |
Initialize to the identity transformation. | |
rgrl_trans_rigid (vnl_matrix< double > const &rot, vnl_vector< double > const &trans, vnl_matrix< double > const &covar) | |
Constructor based on an initial transformation and covar estimate. | |
rgrl_trans_rigid (vnl_matrix< double > const &rot, vnl_vector< double > const &trans) | |
Constructor based on an initial transformation and unknown covar. | |
void | set_translation (double tx, double ty, double tz) |
Sets the translation component of this transformation. | |
void | set_translation (double tx, double ty) |
Sets the translation component of this transformation. | |
void | set_rotation (double theta, double alpha, double phi) |
Sets the rotation part of this transformation. | |
void | set_rotation (double theta) |
Sets the rotation part of this transformation. | |
void | determine_angles (double &phi, double &alpha, double &theta) const |
Given a rotation matrix which is the product of three independent rotations, extract the angles. | |
void | determine_angles (double &theta) const |
Extract the angles. | |
vnl_matrix< double > | transfer_error_covar (vnl_vector< double > const &p) const |
Compute covariance of the transfer error based on transformation covariance. | |
vnl_matrix< double > const & | R () const |
The rotation component of this transform. | |
vnl_vector< double > | t () const |
The translation component of the transform. | |
void | inv_map (const vnl_vector< double > &to, bool initialize_next, const vnl_vector< double > &to_delta, vnl_vector< double > &from, vnl_vector< double > &from_next_est) const |
Inverse map with an initial guess. | |
void | inv_map (const vnl_vector< double > &to, vnl_vector< double > &from) const |
Inverse map based on the transformation. | |
virtual bool | is_invertible () const |
is this an invertible transformation?. | |
virtual rgrl_transformation_sptr | inverse_transform () const |
Return an inverse transformation. | |
virtual void | jacobian_wrt_loc (vnl_matrix< double > &jac, vnl_vector< double > const &from_loc) const |
Compute jacobian w.r.t. location. | |
rgrl_transformation_sptr | scale_by (double scale) const |
transform the transformation for images of different resolution. | |
rgrl_type_macro (rgrl_trans_rigid, rgrl_transformation) void write(vcl_ostream &os) const | |
bool | read (vcl_istream &is) |
input transformation. | |
rgrl_transformation_sptr | clone () const |
make a clone copy. | |
void | map_location (vnl_vector< double > const &from, vnl_vector< double > &to) const |
Apply the transformation to create a new (mapped) location. | |
vnl_vector< double > | map_location (vnl_vector< double > const &p) const |
Apply the transformation to create a new (mapped) location. | |
virtual void | map_tangent (vnl_vector< double > const &from_loc, vnl_vector< double > const &from_dir, vnl_vector< double > &to_dir) const |
Map a tangent direction. | |
virtual void | map_normal (vnl_vector< double > const &from_loc, vnl_vector< double > const &from_dir, vnl_vector< double > &to_dir) const |
Map a normal direction. | |
virtual void | map_normal (vnl_vector< double > const &from_loc, vnl_vector< double > const &from_dir, vnl_matrix< double > const &tangent_subspace, vnl_vector< double > &to_dir) const |
Map a normal direction, given the tangent subspace. | |
void | map_direction (vnl_vector< double > const &from_loc, vnl_vector< double > const &from_dir, vnl_vector< double > &to_dir) const |
Map an arbitrary direction which is neither a tangent nor a normal. | |
virtual double | map_intensity (vnl_vector< double > const &from, double intensity) const |
Apply to an intensity, with a default of the identity. | |
vnl_matrix< double > | covar () const |
Parameter covariance matrix. | |
virtual double | log_det_covar () const |
log of determinant of the covariance. | |
void | set_covar (const vnl_matrix< double > &covar) |
set parameter covariance matrix. | |
bool | is_covar_set () const |
is covariance set?. | |
vnl_matrix< double > | jacobian (vnl_vector< double > const &from_loc) const |
Return the jacobian of the transform. | |
virtual void | write (vcl_ostream &os) const |
output transformation. | |
void | set_scaling_factors (vnl_vector< double > const &scaling) |
set scaling factors. | |
const vnl_vector< double > & | scaling_factors () const |
return scaling factor. | |
rgrl_type_macro (rgrl_transformation, rgrl_object) | |
virtual bool | is_type (const vcl_type_info &type) const |
void | set_debug_flag (unsigned int debugFlag) const |
Set the value of the debug flag. A non-zero value turns debugging on. | |
unsigned int | debug_flag () const |
Get the value of the debug flag. | |
void | set_warning (bool) const |
Set the flag for warning messages. | |
bool | warning () const |
Get the warning flag. | |
unsigned int | add_observer (rgrl_event_sptr event, rgrl_command_sptr) |
Allow people to add/remove/invoke observers (callbacks) to any rgrl object. | |
rgrl_command_sptr | get_command (unsigned int tag) |
Get the command associated with the given tag. | |
void | invoke_event (const rgrl_event &) |
Call execute(.) on all the rgrl_commands observing this event id. | |
void | invoke_event (const rgrl_event &) const |
Call execute(.) on all the rgrl_commands observing this event id. | |
void | remove_observer (unsigned int tag) |
Remove the observer with this tag value. | |
bool | has_observer (const rgrl_event &event) const |
Return true if an observer is registered for this event. | |
void | ref () |
void | unref () |
int | get_references () const |
bool | is_referenced () const |
Static Public Member Functions | |
static const vcl_type_info & | type_id () |
Protected Member Functions | |
void | map_loc (vnl_vector< double > const &from, vnl_vector< double > &to) const |
Apply the transformation to create a new (mapped) location. | |
void | map_dir (vnl_vector< double > const &from_loc, vnl_vector< double > const &from_dir, vnl_vector< double > &to_dir) const |
Apply the transformation to create a new direction at the (mapped) location. | |
double | log_det_sym_matrix (vnl_matrix< double > const &m) const |
a slightly better way of computing log of determinant. | |
double | log_det_covar_deficient (int rank) const |
compute the log of determinant of the covariance when the matrix is rank deficient. | |
Protected Attributes | |
vnl_matrix< double > | covar_ |
covariance matrix. | |
bool | is_covar_set_ |
flag of setting covariance. | |
vnl_vector< double > | scaling_factors_ |
scaling factors of current transformation on each dimension. | |
Private Attributes | |
vnl_matrix< double > | R_ |
vnl_vector< double > | trans_ |
Represents a rigid transformation.
A rigid transform is q = R p + t where R is an n-dimensional rotation matrix, and t is an n-dimensional translation vector. This is just like a similarity transformation with scale=1. Note that R has {9,4} parameters, but only {3,1} degrees of freedom in {3D,2D}. t has {3,2} degrees of freedom in {3D,2D}. This can be most easily seen from the fact that rotation matrices are orthonormal. The rigid transform has {6,3} total degrees of freedom (rotation + translation) in {3D,2D}. The relationship between dimensionality(d) and dof(degrees of freedom) is: dof = 3(d-1)
Definition at line 21 of file rgrl_trans_rigid.h.
rgrl_trans_rigid::rgrl_trans_rigid | ( | unsigned int | dimension = 0 | ) |
Initialize to the identity transformation.
Definition at line 13 of file rgrl_trans_rigid.cxx.
rgrl_trans_rigid::rgrl_trans_rigid | ( | vnl_matrix< double > const & | rot, |
vnl_vector< double > const & | trans, | ||
vnl_matrix< double > const & | covar | ||
) |
Constructor based on an initial transformation and covar estimate.
Definition at line 32 of file rgrl_trans_rigid.cxx.
rgrl_trans_rigid::rgrl_trans_rigid | ( | vnl_matrix< double > const & | rot, |
vnl_vector< double > const & | trans | ||
) |
Constructor based on an initial transformation and unknown covar.
The covariance matrix is a zero matrix.
Definition at line 22 of file rgrl_trans_rigid.cxx.
unsigned int rgrl_object::add_observer | ( | rgrl_event_sptr | event, |
rgrl_command_sptr | cmd | ||
) | [inherited] |
Allow people to add/remove/invoke observers (callbacks) to any rgrl object.
This is an implementation of the subject/observer design pattern. An observer is added by specifying an event to respond to and an rgrl_command to execute. It returns an unsigned long tag which can be used later to remove the event or retrieve the command.
Definition at line 47 of file rgrl_object.cxx.
rgrl_transformation_sptr rgrl_trans_rigid::clone | ( | ) | const [virtual] |
make a clone copy.
Implements rgrl_transformation.
Definition at line 306 of file rgrl_trans_rigid.cxx.
vnl_matrix< double > rgrl_transformation::covar | ( | ) | const [inherited] |
Parameter covariance matrix.
Definition at line 325 of file rgrl_transformation.cxx.
unsigned int rgrl_object::debug_flag | ( | ) | const [inherited] |
Get the value of the debug flag.
Definition at line 26 of file rgrl_object.cxx.
void rgrl_trans_rigid::determine_angles | ( | double & | phi, |
double & | alpha, | ||
double & | theta | ||
) | const |
Given a rotation matrix which is the product of three independent rotations, extract the angles.
Definition at line 83 of file rgrl_trans_rigid.cxx.
void rgrl_trans_rigid::determine_angles | ( | double & | theta | ) | const |
Extract the angles.
Definition at line 108 of file rgrl_trans_rigid.cxx.
rgrl_command_sptr rgrl_object::get_command | ( | unsigned int | tag | ) | [inherited] |
Get the command associated with the given tag.
Definition at line 57 of file rgrl_object.cxx.
bool rgrl_object::has_observer | ( | const rgrl_event & | event | ) | const [inherited] |
Return true if an observer is registered for this event.
Definition at line 107 of file rgrl_object.cxx.
void rgrl_trans_rigid::inv_map | ( | const vnl_vector< double > & | to, |
bool | initialize_next, | ||
const vnl_vector< double > & | to_delta, | ||
vnl_vector< double > & | from, | ||
vnl_vector< double > & | from_next_est | ||
) | const [virtual] |
Inverse map with an initial guess.
Reimplemented from rgrl_transformation.
Definition at line 191 of file rgrl_trans_rigid.cxx.
void rgrl_trans_rigid::inv_map | ( | const vnl_vector< double > & | to, |
vnl_vector< double > & | from | ||
) | const [virtual] |
Inverse map based on the transformation.
The inverse mapping for R(p)+ t = q is p = A^-1(q-t)
Reimplemented from rgrl_transformation.
Definition at line 222 of file rgrl_trans_rigid.cxx.
rgrl_transformation_sptr rgrl_trans_rigid::inverse_transform | ( | ) | const [virtual] |
Return an inverse transformation.
This function only exist for certain transformations.
Reimplemented from rgrl_transformation.
Definition at line 231 of file rgrl_trans_rigid.cxx.
void rgrl_object::invoke_event | ( | const rgrl_event & | event | ) | [inherited] |
Call execute(.) on all the rgrl_commands observing this event id.
Definition at line 69 of file rgrl_object.cxx.
void rgrl_object::invoke_event | ( | const rgrl_event & | event | ) | const [inherited] |
Call execute(.) on all the rgrl_commands observing this event id.
The actions triggered by this call doesn't modify this object.
Definition at line 83 of file rgrl_object.cxx.
bool rgrl_transformation::is_covar_set | ( | ) | const [inline, inherited] |
is covariance set?.
Definition at line 131 of file rgrl_transformation.h.
virtual bool rgrl_trans_rigid::is_invertible | ( | ) | const [inline, virtual] |
is this an invertible transformation?.
Reimplemented from rgrl_transformation.
Definition at line 87 of file rgrl_trans_rigid.h.
virtual bool rgrl_object::is_type | ( | const vcl_type_info & | type | ) | const [inline, virtual, inherited] |
Reimplemented in rgrl_scale_estimator.
Definition at line 66 of file rgrl_object.h.
vnl_matrix< double > rgrl_transformation::jacobian | ( | vnl_vector< double > const & | from_loc | ) | const [inherited] |
Return the jacobian of the transform.
use only as backward compatibility
Definition at line 333 of file rgrl_transformation.cxx.
void rgrl_trans_rigid::jacobian_wrt_loc | ( | vnl_matrix< double > & | jac, |
vnl_vector< double > const & | from_loc | ||
) | const [virtual] |
Compute jacobian w.r.t. location.
Implements rgrl_transformation.
Definition at line 215 of file rgrl_trans_rigid.cxx.
double rgrl_transformation::log_det_covar | ( | ) | const [virtual, inherited] |
log of determinant of the covariance.
Reimplemented in rgrl_trans_rad_dis_homo2d, rgrl_trans_homography2d, and rgrl_trans_homo2d_proj_rad.
Definition at line 231 of file rgrl_transformation.cxx.
double rgrl_transformation::log_det_covar_deficient | ( | int | rank | ) | const [protected, inherited] |
compute the log of determinant of the covariance when the matrix is rank deficient.
Definition at line 258 of file rgrl_transformation.cxx.
double rgrl_transformation::log_det_sym_matrix | ( | vnl_matrix< double > const & | m | ) | const [protected, inherited] |
a slightly better way of computing log of determinant.
Definition at line 238 of file rgrl_transformation.cxx.
void rgrl_trans_rigid::map_dir | ( | vnl_vector< double > const & | from_loc, |
vnl_vector< double > const & | from_dir, | ||
vnl_vector< double > & | to_dir | ||
) | const [protected, virtual] |
Apply the transformation to create a new direction at the (mapped) location.
The resulting direction to_dir is a unit vector.
Implements rgrl_transformation.
Definition at line 125 of file rgrl_trans_rigid.cxx.
void rgrl_transformation::map_direction | ( | vnl_vector< double > const & | from_loc, |
vnl_vector< double > const & | from_dir, | ||
vnl_vector< double > & | to_dir | ||
) | const [inherited] |
Map an arbitrary direction which is neither a tangent nor a normal.
The resulting direction to_dir is a unit vector.
Definition at line 52 of file rgrl_transformation.cxx.
double rgrl_transformation::map_intensity | ( | vnl_vector< double > const & | from, |
double | intensity | ||
) | const [virtual, inherited] |
Apply to an intensity, with a default of the identity.
Definition at line 223 of file rgrl_transformation.cxx.
void rgrl_trans_rigid::map_loc | ( | vnl_vector< double > const & | from, |
vnl_vector< double > & | to | ||
) | const [protected, virtual] |
Apply the transformation to create a new (mapped) location.
Implements rgrl_transformation.
Definition at line 116 of file rgrl_trans_rigid.cxx.
void rgrl_transformation::map_location | ( | vnl_vector< double > const & | from, |
vnl_vector< double > & | to | ||
) | const [inherited] |
Apply the transformation to create a new (mapped) location.
Definition at line 35 of file rgrl_transformation.cxx.
vnl_vector< double > rgrl_transformation::map_location | ( | vnl_vector< double > const & | p | ) | const [inherited] |
Apply the transformation to create a new (mapped) location.
Convenience call to the two parameter version that allocates the result vector.
Definition at line 43 of file rgrl_transformation.cxx.
void rgrl_transformation::map_normal | ( | vnl_vector< double > const & | from_loc, |
vnl_vector< double > const & | from_dir, | ||
vnl_vector< double > & | to_dir | ||
) | const [virtual, inherited] |
Map a normal direction.
The resulting direction to_dir is a unit vector.
Reimplemented in rgrl_trans_couple.
Definition at line 76 of file rgrl_transformation.cxx.
void rgrl_transformation::map_normal | ( | vnl_vector< double > const & | from_loc, |
vnl_vector< double > const & | from_dir, | ||
vnl_matrix< double > const & | tangent_subspace, | ||
vnl_vector< double > & | to_dir | ||
) | const [virtual, inherited] |
Map a normal direction, given the tangent subspace.
The resulting direction to_dir is a unit vector.
Reimplemented in rgrl_trans_couple.
Definition at line 171 of file rgrl_transformation.cxx.
void rgrl_transformation::map_tangent | ( | vnl_vector< double > const & | from_loc, |
vnl_vector< double > const & | from_dir, | ||
vnl_vector< double > & | to_dir | ||
) | const [virtual, inherited] |
Map a tangent direction.
The resulting direction to_dir is a unit vector.
Reimplemented in rgrl_trans_couple.
Definition at line 61 of file rgrl_transformation.cxx.
vnl_matrix< double > const & rgrl_trans_rigid::R | ( | ) | const |
The rotation component of this transform.
Definition at line 177 of file rgrl_trans_rigid.cxx.
bool rgrl_trans_rigid::read | ( | vcl_istream & | is | ) | [virtual] |
input transformation.
Reimplemented from rgrl_transformation.
Definition at line 274 of file rgrl_trans_rigid.cxx.
void rgrl_object::remove_observer | ( | unsigned int | tag | ) | [inherited] |
Remove the observer with this tag value.
Definition at line 97 of file rgrl_object.cxx.
rgrl_trans_rigid::rgrl_type_macro | ( | rgrl_trans_rigid | , |
rgrl_transformation | |||
) | const |
rgrl_transformation::rgrl_type_macro | ( | rgrl_transformation | , |
rgrl_object | |||
) | [inherited] |
rgrl_transformation_sptr rgrl_trans_rigid::scale_by | ( | double | scale | ) | const [virtual] |
transform the transformation for images of different resolution.
Implements rgrl_transformation.
Definition at line 249 of file rgrl_trans_rigid.cxx.
const vnl_vector<double>& rgrl_transformation::scaling_factors | ( | ) | const [inline, inherited] |
return scaling factor.
Definition at line 170 of file rgrl_transformation.h.
void rgrl_transformation::set_covar | ( | const vnl_matrix< double > & | covar | ) | [inherited] |
set parameter covariance matrix.
Reimplemented in rgrl_trans_spline.
Definition at line 344 of file rgrl_transformation.cxx.
void rgrl_object::set_debug_flag | ( | unsigned int | debugFlag | ) | const [inherited] |
Set the value of the debug flag. A non-zero value turns debugging on.
Definition at line 19 of file rgrl_object.cxx.
void rgrl_trans_rigid::set_rotation | ( | double | theta, |
double | alpha, | ||
double | phi | ||
) |
Sets the rotation part of this transformation.
Definition at line 63 of file rgrl_trans_rigid.cxx.
void rgrl_trans_rigid::set_rotation | ( | double | theta | ) |
Sets the rotation part of this transformation.
Definition at line 75 of file rgrl_trans_rigid.cxx.
void rgrl_transformation::set_scaling_factors | ( | vnl_vector< double > const & | scaling | ) | [inherited] |
set scaling factors.
Unless the transformation is not estimated using estimators in rgrl, it does not need to be set explicitly
Definition at line 357 of file rgrl_transformation.cxx.
void rgrl_trans_rigid::set_translation | ( | double | tx, |
double | ty, | ||
double | tz | ||
) |
Sets the translation component of this transformation.
Definition at line 48 of file rgrl_trans_rigid.cxx.
void rgrl_trans_rigid::set_translation | ( | double | tx, |
double | ty | ||
) |
Sets the translation component of this transformation.
Definition at line 56 of file rgrl_trans_rigid.cxx.
void rgrl_object::set_warning | ( | bool | flag | ) | const [inherited] |
Set the flag for warning messages.
Definition at line 33 of file rgrl_object.cxx.
vnl_vector< double > rgrl_trans_rigid::t | ( | ) | const |
The translation component of the transform.
Definition at line 184 of file rgrl_trans_rigid.cxx.
vnl_matrix< double > rgrl_trans_rigid::transfer_error_covar | ( | vnl_vector< double > const & | p | ) | const [virtual] |
Compute covariance of the transfer error based on transformation covariance.
This gives the additional uncertainty of the transferred point location due to the uncertainty of the transform estimate.
Implements rgrl_transformation.
Definition at line 137 of file rgrl_trans_rigid.cxx.
static const vcl_type_info& rgrl_object::type_id | ( | ) | [inline, static, inherited] |
Reimplemented in rgrl_scale_estimator.
Definition at line 63 of file rgrl_object.h.
bool rgrl_object::warning | ( | ) | const [inherited] |
Get the warning flag.
Definition at line 40 of file rgrl_object.cxx.
void rgrl_transformation::write | ( | vcl_ostream & | os | ) | const [virtual, inherited] |
output transformation.
Reimplemented in rgrl_trans_affine, rgrl_trans_quadratic, rgrl_trans_rad_dis_homo2d, rgrl_trans_similarity, rgrl_trans_reduced_quad, rgrl_trans_couple, rgrl_trans_homography2d, rgrl_trans_homo2d_proj_rad, rgrl_trans_translation, and rgrl_trans_spline.
Definition at line 378 of file rgrl_transformation.cxx.
vnl_matrix<double> rgrl_transformation::covar_ [protected, inherited] |
covariance matrix.
Unlike transformation parameters, covariance is always a mtrix of double.
Definition at line 205 of file rgrl_transformation.h.
bool rgrl_transformation::is_covar_set_ [protected, inherited] |
flag of setting covariance.
Check it before using covariance matrix
Definition at line 209 of file rgrl_transformation.h.
vnl_matrix<double> rgrl_trans_rigid::R_ [private] |
Definition at line 120 of file rgrl_trans_rigid.h.
vnl_vector<double> rgrl_transformation::scaling_factors_ [protected, inherited] |
scaling factors of current transformation on each dimension.
This is computed from current transformation. And it has nothing to do with how to transform points
Definition at line 214 of file rgrl_transformation.h.
vnl_vector<double> rgrl_trans_rigid::trans_ [private] |
Definition at line 121 of file rgrl_trans_rigid.h.