contrib/rpl/rgrl/rgrl_initializer.cxx
Go to the documentation of this file.
00001 #include "rgrl_initializer.h"
00002 //:
00003 // \file
00004 // \author Amitha Perera
00005 // \date   Feb 2003
00006 
00007 #include <rgrl/rgrl_view.h>
00008 #include <rgrl/rgrl_scale.h>
00009 
00010 rgrl_initializer::
00011 ~rgrl_initializer()
00012 {
00013 }
00014 
00015 bool
00016 rgrl_initializer::
00017 next_initial( rgrl_mask_sptr           & from_image_roi,
00018               rgrl_mask_sptr           & to_image_roi,
00019               rgrl_mask_box            & current_region,
00020               rgrl_mask_box            & global_region,
00021               rgrl_estimator_sptr      & xform_estimator,
00022               rgrl_transformation_sptr & xform_estimate,
00023               unsigned                 & current_resolution,
00024               rgrl_scale_sptr          & prior_scale)
00025 {
00026   rgrl_view_sptr  view;
00027   bool has_next_view = next_initial( view, prior_scale );
00028 
00029   if (!has_next_view) return has_next_view;
00030 
00031   from_image_roi     = view->from_image_roi();
00032   to_image_roi       = view->to_image_roi();
00033   current_region     = view->region();
00034   global_region      = view->global_region();
00035   xform_estimator    = view->xform_estimator();
00036   xform_estimate     = view->xform_estimate();
00037   current_resolution = view->resolution();
00038   return has_next_view;
00039 }
00040 
00041 bool
00042 rgrl_initializer::
00043 next_initial( rgrl_mask_box            & current_region,
00044               rgrl_estimator_sptr      & xform_estimator,
00045               rgrl_transformation_sptr & xform_estimate,
00046               unsigned                 & current_resolution,
00047               rgrl_scale_sptr          & prior_scale)
00048 {
00049   rgrl_view_sptr  view;
00050   bool has_next_view = next_initial( view, prior_scale );
00051 
00052   if (!has_next_view) return has_next_view;
00053 
00054   current_region     = view->global_region();
00055   xform_estimator    = view->xform_estimator();
00056   xform_estimate     = view->xform_estimate();
00057   current_resolution = view->resolution();
00058   return has_next_view;
00059 }
00060 
00061 bool
00062 rgrl_initializer::
00063 next_initial( rgrl_mask_box            & current_region,
00064               rgrl_estimator_sptr      & xform_estimator,
00065               rgrl_transformation_sptr & xform_estimate,
00066               rgrl_scale_sptr          & prior_scale)
00067 {
00068   rgrl_view_sptr  view;
00069   bool has_next_view = next_initial( view, prior_scale );
00070 
00071   if (!has_next_view) return has_next_view;
00072 
00073   current_region     = view->global_region();
00074   xform_estimator    = view->xform_estimator();
00075   xform_estimate     = view->xform_estimate();
00076   return has_next_view;
00077 }
00078 
00079 //: force the setting of prior scale
00080 //  scale > 0    set to this scale value
00081 //  scale == 0   scale pointer is NULL, which indicates to use unwgted scale estimate
00082 //  scale < 0    use whatever scale set by the match
00083 void
00084 rgrl_initializer::
00085 set_prior_geometric_scale( double scale )
00086 {
00087   if ( scale < 0 ) {
00088     use_prior_scale_from_match_ = true;
00089   } else if ( scale == 0.0 ) {
00090     use_prior_scale_from_match_ = false;
00091     prior_scale_ = 0;
00092   } else {
00093     use_prior_scale_from_match_ = false;
00094     prior_scale_ = new rgrl_scale;
00095     prior_scale_->set_geometric_scale( scale, rgrl_scale::prior );
00096   }
00097 }
00098 
00099 rgrl_scale_sptr
00100 rgrl_initializer::
00101 enforce_prior_scale( rgrl_scale_sptr match_scale )
00102 {
00103   if ( use_prior_scale_from_match_ )
00104     return match_scale;
00105   else
00106     return prior_scale_;   // return the prior scale in this object
00107 }
00108 
00109