Go to the documentation of this file.00001 #include "rgrl_invariant_match.h"
00002
00003 #include <vcl_cassert.h>
00004
00005 rgrl_invariant_match::
00006 rgrl_invariant_match( rgrl_invariant_sptr from,
00007 rgrl_invariant_sptr to)
00008 : from_(from),
00009 to_(to),
00010 is_estimate_set_(false)
00011 {
00012 assert(from->cartesian_invariants().size() == to->cartesian_invariants().size() &&
00013 from->angular_invariants().size() == to->angular_invariants().size());
00014 distance_ = 0;
00015
00016
00017 const vnl_vector<double>& from_inv_cart = from->cartesian_invariants();
00018 const vnl_vector<double>& to_inv_cart = to->cartesian_invariants();
00019 double dist_cartesian = vnl_vector_ssd(from_inv_cart, to_inv_cart);
00020
00021
00022 const vnl_vector<double>& from_inv_ang = from->angular_invariants();
00023 const vnl_vector<double>& to_inv_ang = to->angular_invariants();
00024 double dist_angular = vnl_vector_ssd(from_inv_ang, to_inv_ang);
00025
00026 distance_ = vcl_sqrt(dist_cartesian + dist_angular);
00027 }
00028
00029 rgrl_transformation_sptr
00030 rgrl_invariant_match::
00031 transform() const
00032 {
00033 assert( is_estimate_set_ );
00034 return xform_;
00035 }
00036
00037 rgrl_scale_sptr
00038 rgrl_invariant_match::
00039 scale()const
00040 {
00041 assert( is_estimate_set_ );
00042 return scale_;
00043 }
00044
00045 rgrl_mask_box
00046 rgrl_invariant_match::
00047 initial_region() const
00048 {
00049 return from_->region();
00050 }
00051
00052 bool
00053 rgrl_invariant_match::
00054 has_initial_region() const
00055 {
00056 return from_->has_region();
00057 }
00058
00059 bool
00060 rgrl_invariant_match::
00061 estimate()
00062 {
00063 if ( !is_estimate_set_ )
00064 is_estimate_set_ = to_->estimate( from_, xform_, scale_ );
00065
00066 return is_estimate_set_;
00067 }
00068
00069
00070
00071
00072 bool operator < (const rgrl_invariant_match& left,
00073 const rgrl_invariant_match& right)
00074 {
00075 return left.distance() < right.distance();
00076 }
00077
00078 bool operator > (const rgrl_invariant_match& left,
00079 const rgrl_invariant_match& right)
00080 {
00081 return left.distance() > right.distance();
00082 }
00083
00084 bool dist_less (const vbl_smart_ptr<rgrl_invariant_match>& left,
00085 const vbl_smart_ptr<rgrl_invariant_match>& right)
00086 {
00087 return left->distance() < right->distance();
00088 }
00089
00090 bool dist_greater (const vbl_smart_ptr<rgrl_invariant_match>& left,
00091 const vbl_smart_ptr<rgrl_invariant_match>& right)
00092 {
00093 return left->distance() > right->distance();
00094 }
00095