#include <fhs_searcher.h>
Model consists of a set of features, together with a tree of neighbour relationships of the form pos(j) = pos(i) + (N(mx,var_x),N(my,var_y)) where N(m,var) is a gaussian with mean m and variance var.
The aim is to find a set of points {p(i)} which minimise sum_i F_i(p(i)) + sum_k shape_cost(arc(k)) where k indexes the set of arcs defining neighbour relationships, and shape_cost(arc) = dx*dx/arc.var_x + dy*dy.var_y (dx=p(arc_j).x()-p(arc_i).x()-arc.mx) This is achieved using a combination of a quadratic distance function applied to each feature response image F(i), and a dynamic programming approach to combining the data.
Algorithm based on papers by Felzenszwalb and Huttenlocher on Pictoral Structure Matching.
Definition at line 28 of file fhs_searcher.h.
Public Member Functions | |
| fhs_searcher () | |
| Default constructor. | |
| void | set_tree (const vcl_vector< fhs_arc > &arcs, unsigned root_node) |
| Set tree defining relationships between features. | |
| unsigned | root_node () const |
| Index of root node (set by last call to set_tree(). | |
| unsigned | n_points () const |
| Number of points represented. | |
| void | search (const vcl_vector< vimt_image_2d_of< float > > &feature_response) |
| Perform global search. | |
| void | points_from_root (const vgl_point_2d< double > &root_pt, vcl_vector< vgl_point_2d< double > > &pts) const |
| Compute optimal position of all points given position of root. | |
| double | best_points (vcl_vector< vgl_point_2d< double > > &pts) const |
| Compute optimal position of all points. | |
| const vimt_image_2d_of< float > & | root_cost_image () const |
| Return final total cost image for root. | |
Private Member Functions | |
| void | combine_responses (unsigned im_index, const vimt_image_2d_of< float > &feature_response) |
| Combine responses for image im_index, given supplied feature_response for that node. | |
Private Attributes | |
| vcl_vector< fhs_arc > | arc_ |
| Arcs defining neighbour relationships between features. | |
| vcl_vector< unsigned > | arc_to_j_ |
| arc_to_j_[j] gives index of arc ending at given j. | |
| vcl_vector< vcl_vector< unsigned > > | children_ |
| children_[i] gives list of child nodes of node i in tree. | |
| vcl_vector< vimt_image_2d_of< float > > | sum_im_ |
| Workspace for accumulated sum of responses. | |
| vcl_vector< vimt_image_2d_of< float > > | dist_im_ |
| Workspace for sum of responses, transformed by distance function. | |
| vcl_vector< vimt_image_2d_of< int > > | pos_im_ |
| pos_[i](x,y,0),pos_[i](x,y,1) is position of best response for (x,y). | |
| fhs_searcher::fhs_searcher | ( | ) |
| void fhs_searcher::combine_responses | ( | unsigned | im_index, | |
| const vimt_image_2d_of< float > & | feature_response | |||
| ) | [private] |
Combine responses for image im_index, given supplied feature_response for that node.
Definition at line 48 of file fhs_searcher.cxx.
| void fhs_searcher::set_tree | ( | const vcl_vector< fhs_arc > & | arcs, | |
| unsigned | root_node | |||
| ) |
Set tree defining relationships between features.
Input arcs define neighbour relationships in any order. root_node defines which feature to be used as the root
Definition at line 25 of file fhs_searcher.cxx.
| unsigned fhs_searcher::root_node | ( | ) | const |
| unsigned fhs_searcher::n_points | ( | ) | const [inline] |
| void fhs_searcher::search | ( | const vcl_vector< vimt_image_2d_of< float > > & | feature_response | ) |
Perform global search.
Images of feature response supplied. The transformation (world2im()) for each image can be used to indicate regions which don't necessarily overlap. However, effective displacements are assumed to be in pixel sized steps.
After calling search(), results can be obtained using points() and best_points() etc
Definition at line 147 of file fhs_searcher.cxx.
| void fhs_searcher::points_from_root | ( | const vgl_point_2d< double > & | root_pt, | |
| vcl_vector< vgl_point_2d< double > > & | pts | |||
| ) | const |
Compute optimal position of all points given position of root.
Assumes search() has been called first
Definition at line 192 of file fhs_searcher.cxx.
| double fhs_searcher::best_points | ( | vcl_vector< vgl_point_2d< double > > & | pts | ) | const |
Compute optimal position of all points.
Assumes search() has been called first Returns cost at optimal position
Definition at line 239 of file fhs_searcher.cxx.
| const vimt_image_2d_of< float > & fhs_searcher::root_cost_image | ( | ) | const |
vcl_vector<fhs_arc> fhs_searcher::arc_ [private] |
Arcs defining neighbour relationships between features.
Ordered so that parents precede children
Definition at line 33 of file fhs_searcher.h.
vcl_vector<unsigned> fhs_searcher::arc_to_j_ [private] |
vcl_vector<vcl_vector<unsigned> > fhs_searcher::children_ [private] |
children_[i] gives list of child nodes of node i in tree.
Definition at line 39 of file fhs_searcher.h.
vcl_vector<vimt_image_2d_of<float> > fhs_searcher::sum_im_ [private] |
vcl_vector<vimt_image_2d_of<float> > fhs_searcher::dist_im_ [private] |
Workspace for sum of responses, transformed by distance function.
Definition at line 45 of file fhs_searcher.h.
vcl_vector<vimt_image_2d_of<int> > fhs_searcher::pos_im_ [private] |
pos_[i](x,y,0),pos_[i](x,y,1) is position of best response for (x,y).
Result is in image co-ordinates.
Definition at line 49 of file fhs_searcher.h.
1.5.1