1 / 41

CSci 6971: Image Registration Lecture 12: RGRL February 24, 2004

CSci 6971: Image Registration Lecture 12: RGRL February 24, 2004. Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware Dr. Charlene Tsai. RGRL. Rensselaer Generalized Registration Library Emphasizes feature-based registration Really, correspondence-based registration Built on top of VXL

mara-leach
Download Presentation

CSci 6971: Image Registration Lecture 12: RGRL February 24, 2004

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSci 6971: Image Registration Lecture 12: RGRLFebruary 24, 2004 Prof. Chuck Stewart, RPI Dr. Luis Ibanez, Kitware Dr. Charlene Tsai

  2. RGRL • Rensselaer Generalized Registration Library • Emphasizes feature-based registration • Really, correspondence-based registration • Built on top of VXL • Can interact with ITK • Please refer to the CMake lecture for details • Doesn’t include feature extraction! • Range image points will be the features • Use vxl_src/core/vil/algo to create features or use ITK algorithms. • Work in progress! • Don’t expect the completeness of ITK Lecture 12

  3. Getting rgrl • Download rgrl.zip (for Windows) or rgrl.tar.gz (for Unix) from the course website • Place rgrl in your vxl_src/contrib/rpl • Add the following line to vxl_src/contrib/rpl/CMakeLists.txt SUBDIRS( rgrl ) Lecture 12

  4. Introductory Example: Aligning 2d Point Sets Point/feature set Lecture 12

  5. Introductory Example: Aligning 2d Point Sets Lecture 12

  6. Introductory Example: Aligning 2d Point Sets Initial affine transformation Lecture 12

  7. Introductory Example: Aligning 2d Point Sets 2nd iteration Lecture 12

  8. Introductory Example: Aligning 2d Point Sets 5th iteration Lecture 12

  9. Introductory Example: Aligning 2d Point Sets Final (25th) iteration Lecture 12

  10. Design Overview Moving feature set, Fixed feature set, Prior information • What’s Needed • Represent points / features • Represent point sets • Generate matches • Do estimation • Test for convergence • Iterate • rgrl has basic components for each of these, plus a few more • We’ll start with an example program MATCHING XFORM ESTIMATION failed passed CONVERGENCE TEST Lecture 12

  11. Example Application Program #include <rgrl/rgrl_feature_based_registration.h> #include <rgrl/rgrl_feature_point.h> #include <rgrl/rgrl_matcher_k_nearest.h> #include <rgrl/rgrl_trans_affine.h> // and many more ... extern void (*fb_callback)( rgrl_transformation_sptr trans, rgrl_set_of<rgrl_match_set_sptr> const& match_sets); void callback( rgrl_transformation_sptr trans, rgrl_set_of<rgrl_match_set_sptr> const& match_sets ); int main( int argc, char* argv[] ) { // features (point locations) are imported somehow ... // fixed_feature_points = moving_feature_points; rgrl_feature_set_sptr moving_feature_set, fixed_feature_set; moving_feature_set = new rgrl_feature_set_location<dimension>(moving_feature_points); fixed_feature_set = new rgrl_feature_set_location<dimension>(fixed_feature_points); Lecture 12

  12. Example Main Program // Set up the ICP matcher // unsigned int k = 1; rgrl_matcher_sptr cp_matcher = new rgrl_matcher_k_nearest(k); // Set up the estimator for affine // int dof = 6; //parameter degree of freedom int numSampleForFit = 3; //minimum # of samples for a fit rgrl_estimator_sptr estimator = new rgrl_est_affine(dof, numSampleForFit); // Set up the convergence tester // double tolerance = 1.5; rgrl_convergence_tester_sptr conv_test = new rgrl_convergence_on_median_error( tolerance ); Lecture 12

  13. Example Main Program // Collect prior information for initialization // typedef vnl_vector_fixed<double,2> vector_2d; vector_2d x0(0,0); //upper left corner vector_2d x1(300,300); //bottom right corner rgrl_roi image_roi(x0, x1); rgrl_transformation_sptr init_transform; vnl_matrix<double> A(2,2); A(0,0) = 0.98; A(0,1) = -0.17; A(1,0) = -0.17; A(1,1) =0.98; vector_2d t( 5, -3); init_transform = new rgrl_trans_affine(A, t); Lecture 12

  14. Example Main Program // Store the data in the data manager // rgrl_data_manager_sptr data = new rgrl_data_manager(); data->add_data( moving_feature_set, // data from moving image fixed_feature_set, // data from fixed image cp_matcher ); // matcher for this data // Now, ready to run! Initialize the process with the // prior information // fb_callback = callback; rgrl_feature_based_registration reg( data, conv_test ); reg.run( image_roi, estimator, init_transform ); } Lecture 12

  15. Running the Program • Put the following lines in vxl_src/contrib/rpl/rgrl/examples/CMakeLists.txt ADD_EXECUTABLE( registration_simple_shapes registration_simple_shapes.cxx ) TARGET_LINK_LIBRARIES( registration_simple_shapes rgrl ) • Compile and run … Lecture 12

  16. Digging Into the Details • Base classes for each of the main components • Derived classes for details • Mix-and-match use of derived classes to create different programs • For each component we will go over base class and one or two derived classes now • More detail in later lectures as the algorithm theory is explained Lecture 12

  17. rgrl_transformation • Major operations: • Map a location • Map a direction • Additional operations (to be discussed later) • Estimation covariance matrix • Inverse mapping (in special cases) • Important note • Transformation goes from the moving to the fixed image (opposite to ITK) • All transformations are computed in the coordinate system of the features (as opposed to a physical coordinate system of an image). Pixel spacing embedded in the feature locations. Lecture 12

  18. Quiz #1 Moving Image Fixed Image scaling = ? scaling = 1 Physical space (3,3) (3,3) Pixel space (2,2) scaling = ? scaling = 2/3 Lecture 12

  19. A Bit of the .h file • Map location: void map_location( vnl_vector<double> const& from, vnl_vector<double> & to ) const; • Map direction: void map_direction( vnl_vector<double> const& from_loc, vnl_vector<double> const& from_dir, vnl_vector<double> & to_dir) const; • Enumeration of transformation types: • Not the best design! enum rgrl_transformation_type { RGRL_UNKNOWN_XFORM, RGRL_AFFINE_XFORM, RGRL_SIMILARITY_XFORM, RGRL_REDUCED_QUAD_XFORM, RGRL_QUADRATIC_XFORM, RGRL_TRANSLATION_XFORM }; Lecture 12

  20. rgrl_transformation - Mapping Directions • Implemented in derived classes • Generic mechanism is • Map the location, • Map another point along the direction, • Normalize the vector transform Lecture 12

  21. rgrl_feature • Base class of feature hierarchy • Main capabilities • Mapping itself (applying transform to location, direction, etc) • Distance to other feature • Geometric error (using error projector, lecture 14) • Signature error vector • Enumeration of feature types: enum rgrl_feature_type { RGRL_TRACE_PT, RGRL_POINT, RGRL_FACE_PT, RGRL_LANDMARK}; Lecture 12

  22. rgrl_feature – derived classes • rgrl_feature_point • The simplest feature type • Location only • rgrl_feature_trace_pt • Point on a curve • Location and tangent direction • rgrl_feature_face_pt • Point on a face • Location and normal direction Lecture 12

  23. rgrl_feature – your own (advance) • What is part of the feature? • How to transform the components? • What’s the geometric error? • Any signature errors? • Signature error weight? • E.g. rgrl_feature_landmark (bifurcation/crossover point) • Center location and a set of outgoing directions • Transform applies to center location and outgoing directions • Geometric error is the Euclidean distance between center locations • No signature error vector defined • Signature error weight depends on the alignment of the outgoing directions Lecture 12

  24. rgrl_feature_set • Base class of feature set hierarchy • Collects features of • the same type • the same resolution • Provides methods to access the set of registration features • All methods defined in the derived classes • What are the methods? Lecture 12

  25. rgrl_feature_set_location • A set of features grouped by N-d location • Proximity is determined only by location K=3 feature_vector features_in_region(rgrl_roi const& roi ) feature_vector k_nearest_features(rgrl_feature_sptr feature, unsigned int k ) feature_vector features_within_distance(rgrl_feature_sptr feature,double distance ) Lecture 12

  26. rgrl_matcher • The base class of matcher hierarchy • Computes matches for features in a given ROI • Multiple matches allowed for each feature • Derived classes: • rgrl_matcher_k_nearest (ICP, when k=1) • rgrl_matcher_fixed Moving_feature_set Fixed_feature_set Lecture 12

  27. xformed_ from_feature match_info match_info match_info rgrl_match_set • The container for storing matches • Product of rgrl_matcher::compute_matches(.) • Data storage: vcl_vector< rgrl_feature_sptr > from_features_ from_feature vcl_vector< rgrl_feature_sptr > xformed_from_features_ vcl_vector<vcl_vector<match_info>> matches_and_weights_ Lecture 12

  28. rgrl_match_set • What’s in rgrl_match_set::match_info? • rgrl_feature_sptr to_feature; • double geometric_weight; • double signature_weight; • double cumulative_weight; • To update rgrl_match_set: void add_feature_and_match( rgrl_feature_sptr from_feature, rgrl_feature_sptr matching_to, double wgt = 1.0 ); void add_feature_and_matches( rgrl_feature_sptr from_feature, vcl_vector< rgrl_feature_sptr > const& matching_to ); void remap_from_features( rgrl_transformation const& trans ); Lecture 12

  29. rgrl_estimator • The base class of estimator hierarchy • A set of derived classes for different transformation types • rgrl_estimator::estimate(.) • Compute the transform of a given match set • A virtual function • The derived class implements the details virtual rgrl_transformation_sptr estimate( rgrl_set_of<rgrl_match_set_sptr> const& match_sets, rgrl_transformation const& cur_transform ) const = 0; virtual rgrl_transformation_sptr estimate( rgrl_match_set_sptr const& match_set, rgrl_transformation const& cur_transform ) const = 0; Lecture 12

  30. rgrl_estimator • rgrl_estimator::param_dof() • Degree of freedom in the parameter space • e.g. affine in 2D has 6, and 3D has 12 • rgrl_estimator::num_samples_to_instantiate() • Minimum number of samples to instantiate a fit • Depends on transformation and feature type • E.g. using features of type rgrl_feature_location, 3 feature pairs define an affine transform in 2D (param_dof=6 and each feature pair provides 2 constraints from the x- and y-component) • rgrl_estimator::type() • Type of tranformation estimated by this estimator Lecture 12

  31. rgrl_estimator • What derived classes? • rgrl_est_translation (N-D) • rgrl_est_affine (N-D) • rgrl_est_similarity2d (2D) • rgrl_est_quadratic (N-D) • rgrl_est_reduced_quad2d (2D) Lecture 12

  32. rgrl_convergence_tester • The base class of convergence tester hierarchy • The error measure implemented in the derived class • Determines if the estimation • converged: (new_error-old_error) / new_error ) < 1e-4 • oscillating: error_diff * prev_error_diff < 0.0 • Computation of errors and associated weights for( from_iter fitr = match_ses.from_begin(); fitr != match_set.from_end(); ++fitr ) { rgrl_feature_sptr mapped = fitr.from_feature()->transform( *current_xform ); for( to_iter titr=fitr.begin(); titr!=fitr.end(); ++titr ) { double error = titr.to_feature()->geometric_error(*mapped); errors.push_back( error ); weights.push_back( titr.cumulative_weight() ); } } Lecture 12

  33. rgrl_convergence_tester • Derived classes: • rgrl_convergence_on_median_error( double tol ) vcl_vector<double>::iterator middle = errors.begin() + errors.size()/2; vcl_nth_element( errors.begin(), middle, errors.end() ); double new_error = *middle; • rgrl_convergence_on_weighted_error( double tol ); vec_iter eitr = errors.begin(), witr = weights.begin(); double error_sum = 0, weight_sum = 0; for ( ; eitr!=errors.end(); ++eitr, ++witr ) { error_sum += (*eitr) * (*witr); weight_sum += (*witr); } double new_error = error_sum/weight_sum; • Note: tol determines if the transform estimate is good enough. No effect on the final error. Lecture 12

  34. rgrl_data_manager • What is stored before registration? • Feature sets (moving & fixed sets) • Matcher • Other components required for robust estimation (will discuss in lecture13 & 14) • Estimator ( can get from the initialization ) • How to set the data? void add_data( rgrl_feature_set_sptr from_set, rgrl_feature_set_sptr to_set, rgrl_matcher_sptr matcher, rgrl_weighter_sptr weighter = 0, rgrl_scale_estimator_unwgted_sptr unwgted_scale_est = 0, rgrl_scale_estimator_wgted_sptr wgted_scale_est = 0); void add_estimator( rgrl_estimator_sptr estimator); Lecture 12

  35. rgrl_data_manager – advance features • Data can be stored in multiple stages • Each stage can store multiple types of feature set, and multiple estimators • What determines a “stage”? • All feature sets in one stage together estimate a transformation • Need to specify relation between stages in terms of resolution • You don’t need this yet! Lecture 12

  36. Quiz #2 Q. How to register two images using multi-resolution in two levels? A1. Two registration problems, one for each resolution. Each problem takes one-stage data manager. The higher resolution is explicitly initialized by the result from the lower resolution. A2. One registration problem with two-stage data manager. The 0th stage for high resolution and the 1st stage for the low resolution. (advance) Lecture 12

  37. Debugging • Showing transformation and matches during iterations • Derived types of the rgrl_transformation and rgrl_feature depending on the application program. • Example: void callback( rgrl_transformation_sptr trans, rgrl_set_of<rgrl_match_set_sptr> const& match_sets ) { rgrl_trans_translation* xform = rgrl_cast<rgrl_trans_translation*>(trans); vcl_cout<<"Xform T = "<<xform->t()<<vcl_endl; } int main( int argc, char* argv[] ) { //... fb_callback = callback; //... } Lecture 12

  38. Moving featrue set, Fixed feature set, Prior information MATCHING XFORM ESTIMATION failed passed CONVERGENCE TEST rgrl_feature_based_registration • The registration engine • Put everything together (one stage, one data item, one estimator) Lecture 12

  39. rgrl_feature_based_registration unsigned iterations = 0; //total iteration rgrl_converge_status_sptr current_status = 0; bool failed = false; do { // Compute matches, and scales for each feature set. // match_set= matcher->compute_matches( *from_set, *to_set, *xform_estimate, image_region, *scale ); // Transformation estimation // double alignment_error; if ( !rgrl_util_irls( match_set, scale, weighter, *conv_tester_, xform_estimator, xform_estimate, alignment_error) ) { failed = true; continue; //no valid xform, so exit the loop } Lecture 12

  40. rgrl_feature_based_registration // For debugging ... // if( fb_callback ) fb_callback( xform_estimate, match_sets ); // Perform convergence test // current_status = conv_tester_->compute_status( current_status, xform_estimate, xform_estimator, match_set, scale ); ++iterations; } while( !failed && !current_status->has_converged() && !current_status->has_stagnated() && iterations < max_icp_iter_ ); Lecture 12

  41. Summary • Illustrated a simple ICP example • Introduced feature-based registration with components for doing least-squares estimation • All questions and comments on rgrl to Charlene Tsai (tsaic@cs.rpi.edu) Lecture 12

More Related