contrib/rpl/rgrl/rgrl_util.h
Go to the documentation of this file.
00001 #ifndef rgrl_util_h_
00002 #define rgrl_util_h_
00003 //:
00004 // \file
00005 // \author Charlene Tsai / Chuck Stewart / Gehua Yang
00006 // \date   Sep 2003
00007 
00008 #include <rgrl/rgrl_transformation_sptr.h>
00009 #include <rgrl/rgrl_weighter_sptr.h>
00010 #include <rgrl/rgrl_scale_sptr.h>
00011 #include <rgrl/rgrl_match_set_sptr.h>
00012 #include <rgrl/rgrl_estimator_sptr.h>
00013 #include <rgrl/rgrl_mask_sptr.h>
00014 
00015 #include <vnl/vnl_vector.h>
00016 #include <vcl_iosfwd.h>
00017 #include <vcl_vector.h>
00018 #include <rgrl/rgrl_fwd.h>
00019 
00020 class rgrl_match_set;
00021 
00022 //: Estimate the maximum overlap region/volume based on the curr_xform
00023 rgrl_mask_box
00024 rgrl_util_estimate_global_region(
00025           rgrl_mask_sptr      const&   from_image_roi,
00026           rgrl_mask_sptr      const&   to_image_roi,
00027           rgrl_mask_box       const&   current_region,
00028           rgrl_transformation const&   curr_xform,
00029           bool                         union_with_curr = false,
00030           double                       drastic_change_ratio = 1.75 );
00031 
00032 //: Estimate the maximum overlap region/volume based on the inverse xfrom
00033 //  The inverse xform transforms points on Fixed image coordinate to Moving image
00034 rgrl_mask_box
00035 rgrl_util_estimate_global_region_with_inverse_xform(
00036           rgrl_mask_sptr      const&   from_image_roi,
00037           rgrl_mask_sptr      const&   to_image_roi,
00038           rgrl_mask_box       const&   current_region,
00039           rgrl_transformation const&   inv_xform,
00040           bool                         union_with_curr = false,
00041           double                       drastic_change_ratio = 1.75 );
00042 
00043 //: Estimate the change between the spreads of the from_feature_set and mapped_feature_set
00044 double
00045 rgrl_util_geometric_error_scaling( rgrl_match_set const& match_set );
00046 
00047 double
00048 rgrl_util_geometric_error_scaling( rgrl_set_of<rgrl_match_set_sptr> const& current_match_sets );
00049 
00050 //: Estimate the change between the spreads of the from_feature_set and mapped_feature_set
00051 bool
00052 rgrl_util_geometric_scaling_factors( rgrl_set_of<rgrl_match_set_sptr> const& current_match_sets,
00053                                      vnl_vector<double>& factors );
00054 
00055 //: Estimate the change between the spreads of the from_feature_set and mapped_feature_set
00056 bool
00057 rgrl_util_geometric_scaling_factors( rgrl_match_set const& current_match_set,
00058                                      vnl_vector<double>& factors );
00059 
00060 //:
00061 //  Given an oriented, rectangular solid in any number of dimensions, represented by
00062 //  the basis_directions and radii, find the pixel locations that are within the solid.
00063 //  basis_dirs are unit vectors and normal to each other.
00064 void
00065 rgrl_util_extract_region_locations( vnl_vector< double >             const& center,
00066                                     vcl_vector< vnl_vector<double> > const& basis_dirs,
00067                                     vnl_vector< double >             const& basis_radii,
00068                                     vcl_vector< vnl_vector<int> >         & pixel_locations );
00069 
00070 //: A simplified version of irls w/o scale re-estimation.
00071 //  This takes single match set
00072 //  The \a fast_remapping indicates whether to re-map the features (false),
00073 //  or to re-map only the locations (true). This save the computations
00074 //  on re-mapping scales, orientations.  However, the result may be
00075 //  inaccurate due to out-of-date signature weights.
00076 bool
00077 rgrl_util_irls( rgrl_match_set_sptr              match_set,
00078                 rgrl_scale_sptr                  scale,
00079                 rgrl_weighter_sptr               weighter,
00080                 rgrl_convergence_tester   const& conv_tester,
00081                 rgrl_estimator_sptr              estimator,
00082                 rgrl_transformation_sptr       & estimate,
00083                 const bool                       fast_remapping = false,
00084                 unsigned int                     debug_flag = 0);
00085 
00086 //: A simplified version of irls w/o scale re-estimation.
00087 //  This takes multiple match sets
00088 //  The \a fast_remapping indicates whether to re-map the features (false),
00089 //  or to re-map only the locations (true). This save the computations
00090 //  on re-mapping scales, orientations.  However, the result may be
00091 //  inaccurate due to out-of-date signature weights.
00092 bool
00093 rgrl_util_irls( rgrl_set_of<rgrl_match_set_sptr> const& match_sets,
00094                 rgrl_set_of<rgrl_scale_sptr>     const& scales,
00095                 vcl_vector<rgrl_weighter_sptr>   const& weighters,
00096                 rgrl_convergence_tester          const& conv_tester,
00097                 rgrl_estimator_sptr              estimator,
00098                 rgrl_transformation_sptr&        estimate,
00099                 const bool                       fast_remapping = false,
00100                 unsigned int                     debug_flag = 0);
00101 
00102 //: skip empty lines in input stream
00103 void
00104 rgrl_util_skip_empty_lines( vcl_istream& is );
00105 
00106 
00107 #endif // rgrl_util_h_