Builds mfpf_region_finder objects which use a linear classifier. More...
#include <mfpf_lin_clsfy_finder_builder.h>
Public Member Functions | |
mfpf_lin_clsfy_finder_builder () | |
virtual | ~mfpf_lin_clsfy_finder_builder () |
void | set_as_box (unsigned ni, unsigned nj, double ref_x, double ref_y) |
Define model region as an ni x nj box. | |
void | set_as_box (unsigned ni, unsigned nj) |
Define model region as an ni x nj box. | |
void | set_as_ellipse (double ri, double rj) |
Define model region as an ellipse with radii ri, rj. | |
void | set_region (const mfpf_region_form &form) |
Define model region using description in form. | |
void | set_norm_method (short norm_method) |
Which normalisation to use (0=none, 1=linear). | |
virtual void | set_region_size (double wi, double wj) |
Define region size in world co-ordinates. | |
unsigned | n_pixels () const |
Number of pixels in region. | |
const vcl_string & | shape () const |
String defining shape of region, eg "box" or "ellipse". | |
virtual unsigned | model_dim () |
Number of dimensions in the model. | |
virtual mfpf_point_finder * | new_finder () const |
Create new mfpf_region_finder on heap. | |
virtual void | clear (unsigned n_egs) |
Initialise building. | |
virtual void | add_example (const vimt_image_2d_of< float > &image, const vgl_point_2d< double > &p, const vgl_vector_2d< double > &u) |
Add one example to the model. | |
virtual void | build (mfpf_point_finder &) |
Build object from the data supplied in add_example(). | |
virtual bool | set_from_stream (vcl_istream &is) |
Initialise from a string stream. | |
virtual vcl_string | is_a () const |
Name of the class. | |
virtual mfpf_point_finder_builder * | clone () const |
Create a copy on the heap and return base class pointer. | |
virtual void | print_summary (vcl_ostream &os) const |
Print class to os. | |
void | print_shape (vcl_ostream &os) const |
Prints ASCII representation of shape to os. | |
short | version_no () const |
Version number for I/O. | |
virtual void | b_write (vsl_b_ostream &bfs) const |
Save class to binary file stream. | |
virtual void | b_read (vsl_b_istream &bfs) |
Load class from binary file stream. | |
virtual void | set_step_size (double) |
Size of step between sample points. | |
double | step_size () const |
Size of step between sample points. | |
virtual void | set_search_area (unsigned ni, unsigned nj) |
Define search region size. | |
void | set_search_angle_range (unsigned nA, double dA) |
Define angle search parameters. | |
void | set_search_scale_range (unsigned ns, double ds) |
Define scale search parameters. | |
int | search_ni () const |
int | search_nj () const |
unsigned | search_nA () const |
Number of angles to search at (ie try at A+idA, i in [-nA,+nA]). | |
double | search_dA () const |
Angle step size (ie try at A+idA, i in [-nA,+nA]). | |
unsigned | search_ns () const |
Number of scales to try at. | |
double | search_ds () const |
Scaling factor (ie try at ((ds)^i), i in [-ns,+ns]. | |
virtual void | get_sample_vector (const vimt_image_2d_of< float > &image, const vgl_point_2d< double > &p, const vgl_vector_2d< double > &u, vcl_vector< double > &v) |
Get sample of region around specified point in image. | |
Static Public Member Functions | |
static vcl_auto_ptr < mfpf_point_finder_builder > | create_from_stream (vcl_istream &is) |
Create a concrete object, from a text specification. | |
Protected Member Functions | |
bool | base_equality (const mfpf_point_finder_builder &b) const |
Return true if base class parameters are the same in b. | |
void | parse_base_props (mbl_read_props_type &props) |
Parse relevant parameters from props list. | |
void | set_base_parameters (mfpf_point_finder &pf) |
Set base-class parameters of point finder. | |
Protected Attributes | |
double | step_size_ |
Size of step between sample points. | |
int | search_ni_ |
Number of points either side of centre to search. | |
int | search_nj_ |
Number of points either side of centre to search. | |
unsigned | search_nA_ |
Define N. angles (ie try at A+idA, i in [-nA,+nA]). | |
double | search_dA_ |
Angle step size (ie try at A+idA, i in [-nA,+nA]). | |
unsigned | search_ns_ |
Number of scales to try at. | |
double | search_ds_ |
Scaling factor (ie try at ((ds)^i), i in [-ns,+ns]. | |
Private Member Functions | |
void | set_defaults () |
Define default values. | |
void | config_as_box (vcl_istream &is) |
Parse stream to set up as a box shape. | |
void | config_as_ellipse (vcl_istream &is) |
Parse stream to set up as an ellipse shape. | |
void | add_one_example (const vimt_image_2d_of< float > &image, const vgl_point_2d< double > &p, const vgl_vector_2d< double > &u) |
Add one example to the model. | |
Private Attributes | |
double | ref_x_ |
Kernel reference point (in roi_ni_ x roi_nj_ grid). | |
double | ref_y_ |
Kernel reference point (in roi_ni_ x roi_nj_ grid). | |
vcl_string | shape_ |
String defining shape of region, eg "box" or "ellipse". | |
vcl_vector< mbl_chord > | roi_ |
Chords defining the region of interest. | |
unsigned | roi_ni_ |
Size of bounding box of region of interest. | |
unsigned | roi_nj_ |
Size of bounding box of region of interest. | |
unsigned | n_pixels_ |
Number of pixels in region. | |
double | r1_ |
double | r2_ |
double | r3_ |
vcl_vector< vnl_vector< double > > | samples_ |
Training samples. | |
vcl_vector< unsigned > | class_id_ |
Indicate whether sample is positive (1) or negative (0) example. | |
short | norm_method_ |
Which normalisation to use (0=none, 1=linear). | |
unsigned | nA_ |
Number of angles either side of 0 to sample at. | |
double | dA_ |
Angle displacement. | |
double | overlap_f_ |
Relative size of region used for estimating overlap. | |
double | var_min_ |
lower bound on variance used in normalisation. | |
double | tvar_min_ |
lowest variance found so far in training set. | |
bool | estimate_var_min_ |
If true reset var_min based on min in training set. | |
unsigned | num_examples_ |
Number of examples added. |
Builds mfpf_region_finder objects which use a linear classifier.
Resulting mfpf_region_finder is set up with a mfpf_log_lin_class_cost function, which returns log(prob(patch)) based on a linear classifier, trained with positive examples at supplied points and negative examples in an annulus around the supplied points.
Text for configuring:
mfpf_lin_clsfy_finder_builder { shape: ellipse { ri: 5 rj: 3 } // Samples within r1 pixels of true pt are considered positive examples r1: 1.5 // Samples in range (r2,r3] of true pt are negative examples r2: 3 r3: 7 norm: linear search_ni: 5 search_nj: 4 } Alternative for shape: shape: box { ni: 5 nj: 3 ref_x: 2.5 ref_y: 1.5 }
Definition at line 34 of file mfpf_lin_clsfy_finder_builder.h.
mfpf_lin_clsfy_finder_builder::mfpf_lin_clsfy_finder_builder | ( | ) |
Definition at line 36 of file mfpf_lin_clsfy_finder_builder.cxx.
mfpf_lin_clsfy_finder_builder::~mfpf_lin_clsfy_finder_builder | ( | ) | [virtual] |
Definition at line 70 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::add_example | ( | const vimt_image_2d_of< float > & | image, |
const vgl_point_2d< double > & | p, | ||
const vgl_vector_2d< double > & | u | ||
) | [virtual] |
Add one example to the model.
Implements mfpf_point_finder_builder.
Definition at line 257 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::add_one_example | ( | const vimt_image_2d_of< float > & | image, |
const vgl_point_2d< double > & | p, | ||
const vgl_vector_2d< double > & | u | ||
) | [private] |
Add one example to the model.
Sample regions in a grid centred on supplied point. Record those close to the centre as positive examples, and those further away as negative examples.
Definition at line 188 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::b_read | ( | vsl_b_istream & | bfs | ) | [virtual] |
Load class from binary file stream.
Reimplemented from mfpf_point_finder_builder.
Definition at line 559 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::b_write | ( | vsl_b_ostream & | bfs | ) | const [virtual] |
Save class to binary file stream.
Reimplemented from mfpf_point_finder_builder.
Definition at line 533 of file mfpf_lin_clsfy_finder_builder.cxx.
bool mfpf_point_finder_builder::base_equality | ( | const mfpf_point_finder_builder & | b | ) | const [protected, inherited] |
Return true if base class parameters are the same in b.
Return true if base class parameters are the same in pf.
Definition at line 189 of file mfpf_point_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::build | ( | mfpf_point_finder & | pf | ) | [virtual] |
Build object from the data supplied in add_example().
Build this object from the data supplied in add_example().
Implements mfpf_point_finder_builder.
Definition at line 277 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::clear | ( | unsigned | n_egs | ) | [virtual] |
Initialise building.
Must be called before any calls to add_example(...)
Implements mfpf_point_finder_builder.
Definition at line 179 of file mfpf_lin_clsfy_finder_builder.cxx.
mfpf_point_finder_builder * mfpf_lin_clsfy_finder_builder::clone | ( | ) | const [virtual] |
Create a copy on the heap and return base class pointer.
Implements mfpf_point_finder_builder.
Definition at line 485 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::config_as_box | ( | vcl_istream & | is | ) | [private] |
Parse stream to set up as a box shape.
Expects: "{ ni: 3 nj: 5 ref_x: 1.0 ref_y: 2.0 }
Definition at line 322 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::config_as_ellipse | ( | vcl_istream & | is | ) | [private] |
Parse stream to set up as an ellipse shape.
Expects: "{ ri: 2.1 rj: 5.2 }
Definition at line 366 of file mfpf_lin_clsfy_finder_builder.cxx.
vcl_auto_ptr< mfpf_point_finder_builder > mfpf_point_finder_builder::create_from_stream | ( | vcl_istream & | is | ) | [static, inherited] |
Create a concrete object, from a text specification.
Definition at line 153 of file mfpf_point_finder_builder.cxx.
void mfpf_point_finder_builder::get_sample_vector | ( | const vimt_image_2d_of< float > & | image, |
const vgl_point_2d< double > & | p, | ||
const vgl_vector_2d< double > & | u, | ||
vcl_vector< double > & | v | ||
) | [virtual, inherited] |
Get sample of region around specified point in image.
Reimplemented in mfpf_grad_corr2d_builder, and mfpf_norm_corr2d_builder.
Definition at line 74 of file mfpf_point_finder_builder.cxx.
vcl_string mfpf_lin_clsfy_finder_builder::is_a | ( | ) | const [virtual] |
Name of the class.
Reimplemented from mfpf_point_finder_builder.
Definition at line 479 of file mfpf_lin_clsfy_finder_builder.cxx.
unsigned mfpf_lin_clsfy_finder_builder::model_dim | ( | ) | [virtual] |
Number of dimensions in the model.
Reimplemented from mfpf_point_finder_builder.
Definition at line 172 of file mfpf_lin_clsfy_finder_builder.cxx.
unsigned mfpf_lin_clsfy_finder_builder::n_pixels | ( | ) | const [inline] |
Number of pixels in region.
Definition at line 147 of file mfpf_lin_clsfy_finder_builder.h.
mfpf_point_finder * mfpf_lin_clsfy_finder_builder::new_finder | ( | ) | const [virtual] |
Create new mfpf_region_finder on heap.
Implements mfpf_point_finder_builder.
Definition at line 75 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_point_finder_builder::parse_base_props | ( | mbl_read_props_type & | props | ) | [protected, inherited] |
Parse relevant parameters from props list.
Definition at line 85 of file mfpf_point_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::print_shape | ( | vcl_ostream & | os | ) | const |
Prints ASCII representation of shape to os.
Definition at line 511 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::print_summary | ( | vcl_ostream & | os | ) | const [virtual] |
Print class to os.
Reimplemented from mfpf_point_finder_builder.
Definition at line 494 of file mfpf_lin_clsfy_finder_builder.cxx.
double mfpf_point_finder_builder::search_dA | ( | ) | const [inline, inherited] |
Angle step size (ie try at A+idA, i in [-nA,+nA]).
Definition at line 90 of file mfpf_point_finder_builder.h.
double mfpf_point_finder_builder::search_ds | ( | ) | const [inline, inherited] |
Scaling factor (ie try at ((ds)^i), i in [-ns,+ns].
Definition at line 96 of file mfpf_point_finder_builder.h.
unsigned mfpf_point_finder_builder::search_nA | ( | ) | const [inline, inherited] |
Number of angles to search at (ie try at A+idA, i in [-nA,+nA]).
Definition at line 87 of file mfpf_point_finder_builder.h.
int mfpf_point_finder_builder::search_ni | ( | ) | const [inline, inherited] |
Definition at line 83 of file mfpf_point_finder_builder.h.
int mfpf_point_finder_builder::search_nj | ( | ) | const [inline, inherited] |
Definition at line 84 of file mfpf_point_finder_builder.h.
unsigned mfpf_point_finder_builder::search_ns | ( | ) | const [inline, inherited] |
Number of scales to try at.
Definition at line 93 of file mfpf_point_finder_builder.h.
void mfpf_lin_clsfy_finder_builder::set_as_box | ( | unsigned | ni, |
unsigned | nj, | ||
double | ref_x, | ||
double | ref_y | ||
) |
Define model region as an ni x nj box.
Definition at line 128 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::set_as_box | ( | unsigned | ni, |
unsigned | nj | ||
) |
Define model region as an ni x nj box.
Ref. point in centre.
Definition at line 122 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::set_as_ellipse | ( | double | ri, |
double | rj | ||
) |
Define model region as an ellipse with radii ri, rj.
Ref. point in centre.
Definition at line 144 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_point_finder_builder::set_base_parameters | ( | mfpf_point_finder & | pf | ) | [protected, inherited] |
Set base-class parameters of point finder.
Definition at line 126 of file mfpf_point_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::set_defaults | ( | ) | [private] |
Define default values.
Definition at line 42 of file mfpf_lin_clsfy_finder_builder.cxx.
bool mfpf_lin_clsfy_finder_builder::set_from_stream | ( | vcl_istream & | is | ) | [virtual] |
Initialise from a string stream.
Reimplemented from mfpf_point_finder_builder.
Definition at line 399 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::set_norm_method | ( | short | norm_method | ) |
Which normalisation to use (0=none, 1=linear).
Definition at line 166 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::set_region | ( | const mfpf_region_form & | form | ) |
Define model region using description in form.
Assumes form defined in world-coords. Sets step_size() to form.pose().scale().
Assumes form defined in world-coords. Assumes step_size() pixel units (ie dimensions are divided by step_size() to map to reference frame).
Definition at line 84 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_lin_clsfy_finder_builder::set_region_size | ( | double | wi, |
double | wj | ||
) | [virtual] |
Define region size in world co-ordinates.
Sets up ROI to cover given box (with samples at step_size()), with ref point at centre. Currently just defines as a box
Sets up ROI to cover given box (with samples at step_size()), with ref point at centre.
Implements mfpf_point_finder_builder.
Definition at line 111 of file mfpf_lin_clsfy_finder_builder.cxx.
void mfpf_point_finder_builder::set_search_angle_range | ( | unsigned | nA, |
double | dA | ||
) | [inherited] |
Define angle search parameters.
Definition at line 54 of file mfpf_point_finder_builder.cxx.
void mfpf_point_finder_builder::set_search_area | ( | unsigned | ni, |
unsigned | nj | ||
) | [virtual, inherited] |
Define search region size.
During search, samples at points on grid [-ni,ni]x[-nj,nj], with axes defined by u.
Definition at line 47 of file mfpf_point_finder_builder.cxx.
void mfpf_point_finder_builder::set_search_scale_range | ( | unsigned | ns, |
double | ds | ||
) | [inherited] |
Define scale search parameters.
Definition at line 61 of file mfpf_point_finder_builder.cxx.
void mfpf_point_finder_builder::set_step_size | ( | double | s | ) | [virtual, inherited] |
Size of step between sample points.
Definition at line 39 of file mfpf_point_finder_builder.cxx.
const vcl_string& mfpf_lin_clsfy_finder_builder::shape | ( | ) | const [inline] |
String defining shape of region, eg "box" or "ellipse".
Definition at line 150 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_point_finder_builder::step_size | ( | ) | const [inline, inherited] |
Size of step between sample points.
Definition at line 65 of file mfpf_point_finder_builder.h.
short mfpf_lin_clsfy_finder_builder::version_no | ( | ) | const |
Version number for I/O.
Reimplemented from mfpf_point_finder_builder.
Definition at line 528 of file mfpf_lin_clsfy_finder_builder.cxx.
vcl_vector<unsigned> mfpf_lin_clsfy_finder_builder::class_id_ [private] |
Indicate whether sample is positive (1) or negative (0) example.
Definition at line 67 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::dA_ [private] |
Angle displacement.
Definition at line 76 of file mfpf_lin_clsfy_finder_builder.h.
bool mfpf_lin_clsfy_finder_builder::estimate_var_min_ [private] |
If true reset var_min based on min in training set.
Definition at line 89 of file mfpf_lin_clsfy_finder_builder.h.
unsigned mfpf_lin_clsfy_finder_builder::n_pixels_ [private] |
Number of pixels in region.
Definition at line 54 of file mfpf_lin_clsfy_finder_builder.h.
unsigned mfpf_lin_clsfy_finder_builder::nA_ [private] |
Number of angles either side of 0 to sample at.
Definition at line 73 of file mfpf_lin_clsfy_finder_builder.h.
short mfpf_lin_clsfy_finder_builder::norm_method_ [private] |
Which normalisation to use (0=none, 1=linear).
Definition at line 70 of file mfpf_lin_clsfy_finder_builder.h.
unsigned mfpf_lin_clsfy_finder_builder::num_examples_ [private] |
Number of examples added.
Definition at line 92 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::overlap_f_ [private] |
Relative size of region used for estimating overlap.
If 0.5, then overlap requires pt inside central 50% of region.
Definition at line 80 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::r1_ [private] |
Definition at line 57 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::r2_ [private] |
Definition at line 59 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::r3_ [private] |
Definition at line 61 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::ref_x_ [private] |
Kernel reference point (in roi_ni_ x roi_nj_ grid).
Definition at line 38 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::ref_y_ [private] |
Kernel reference point (in roi_ni_ x roi_nj_ grid).
Definition at line 40 of file mfpf_lin_clsfy_finder_builder.h.
vcl_vector<mbl_chord> mfpf_lin_clsfy_finder_builder::roi_ [private] |
Chords defining the region of interest.
Definition at line 46 of file mfpf_lin_clsfy_finder_builder.h.
unsigned mfpf_lin_clsfy_finder_builder::roi_ni_ [private] |
Size of bounding box of region of interest.
Definition at line 49 of file mfpf_lin_clsfy_finder_builder.h.
unsigned mfpf_lin_clsfy_finder_builder::roi_nj_ [private] |
Size of bounding box of region of interest.
Definition at line 51 of file mfpf_lin_clsfy_finder_builder.h.
vcl_vector<vnl_vector<double> > mfpf_lin_clsfy_finder_builder::samples_ [private] |
Training samples.
Definition at line 64 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_point_finder_builder::search_dA_ [protected, inherited] |
Angle step size (ie try at A+idA, i in [-nA,+nA]).
Definition at line 36 of file mfpf_point_finder_builder.h.
double mfpf_point_finder_builder::search_ds_ [protected, inherited] |
Scaling factor (ie try at ((ds)^i), i in [-ns,+ns].
Definition at line 42 of file mfpf_point_finder_builder.h.
unsigned mfpf_point_finder_builder::search_nA_ [protected, inherited] |
Define N. angles (ie try at A+idA, i in [-nA,+nA]).
Definition at line 33 of file mfpf_point_finder_builder.h.
int mfpf_point_finder_builder::search_ni_ [protected, inherited] |
Number of points either side of centre to search.
Definition at line 27 of file mfpf_point_finder_builder.h.
int mfpf_point_finder_builder::search_nj_ [protected, inherited] |
Number of points either side of centre to search.
Definition at line 30 of file mfpf_point_finder_builder.h.
unsigned mfpf_point_finder_builder::search_ns_ [protected, inherited] |
Number of scales to try at.
Definition at line 39 of file mfpf_point_finder_builder.h.
vcl_string mfpf_lin_clsfy_finder_builder::shape_ [private] |
String defining shape of region, eg "box" or "ellipse".
Definition at line 43 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_point_finder_builder::step_size_ [protected, inherited] |
Size of step between sample points.
Definition at line 24 of file mfpf_point_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::tvar_min_ [private] |
lowest variance found so far in training set.
Definition at line 86 of file mfpf_lin_clsfy_finder_builder.h.
double mfpf_lin_clsfy_finder_builder::var_min_ [private] |
lower bound on variance used in normalisation.
Definition at line 83 of file mfpf_lin_clsfy_finder_builder.h.