contrib/mul/mfpf/mfpf_profile_pdf.h
Go to the documentation of this file.
00001 #ifndef mfpf_profile_pdf_h_
00002 #define mfpf_profile_pdf_h_
00003 //:
00004 // \file
00005 // \brief Searches along a profile using a statistical model
00006 // \author Tim Cootes
00007 
00008 #include <mfpf/mfpf_point_finder.h>
00009 #include <vpdfl/vpdfl_pdf_base.h>
00010 #include <mbl/mbl_cloneable_ptr.h>
00011 #include <vgl/vgl_fwd.h>
00012 #include <vcl_iosfwd.h>
00013 
00014 //: Searches along a profile using a statistical model.
00015 class mfpf_profile_pdf : public mfpf_point_finder
00016 {
00017  private:
00018   //: Kernel mask is [ilo_,ihi_]
00019   int ilo_;
00020   //: Kernel mask is [ilo_,ihi_]
00021   int ihi_;
00022 
00023   //: PDf for profile vector
00024   mbl_cloneable_ptr<vpdfl_pdf_base> pdf_;
00025 
00026   //: Define default values
00027   void set_defaults();
00028  public:
00029 
00030   // Dflt ctor
00031   mfpf_profile_pdf();
00032 
00033   // Destructor
00034   virtual ~mfpf_profile_pdf();
00035 
00036   //: Radius of circle containing modelled region
00037   virtual double radius() const;
00038 
00039   //: Define size and PDF (clone taken)
00040   void set(int ilo, int ihi, const vpdfl_pdf_base& pdf);
00041 
00042   //: Kernel mask is [ilo_,ihi_]
00043   int ilo() const { return ilo_; }
00044 
00045   //: Kernel mask is [ilo_,ihi_]
00046   int ihi() const { return ihi_; }
00047 
00048   //: PDf for profile vector
00049   const vpdfl_pdf_base& pdf() const { return pdf_; }
00050 
00051   //: Evaluate match at p, using u to define scale and orientation
00052   // Returns -1*logp(vector) at p along direction u
00053   virtual double evaluate(const vimt_image_2d_of<float>& image,
00054                           const vgl_point_2d<double>& p,
00055                           const vgl_vector_2d<double>& u);
00056 
00057   //: Evaluate match at in a region around p
00058   // Returns a quality of fit at a set of positions.
00059   // response image (whose size and transform is set inside the
00060   // function), indicates the points at which the function was
00061   // evaluated.  response(i,j) is the fit at the point
00062   // response.world2im().inverse()(i,j).  The world2im() transformation
00063   // may be affine.
00064   virtual void evaluate_region(const vimt_image_2d_of<float>& image,
00065                                const vgl_point_2d<double>& p,
00066                                const vgl_vector_2d<double>& u,
00067                                vimt_image_2d_of<double>& response);
00068 
00069   //: Search given image around p, using u to define scale and angle
00070   //  On exit, new_p defines position of the best nearby match.
00071   //  Returns a quality of fit measure at that
00072   //  point (the smaller the better).
00073   virtual double search_one_pose(const vimt_image_2d_of<float>& image,
00074                                  const vgl_point_2d<double>& p,
00075                                  const vgl_vector_2d<double>& u,
00076                                  vgl_point_2d<double>& new_p);
00077 
00078   //: Generate points in ref frame that represent boundary
00079   //  Points of a contour around the shape.
00080   //  Used for display purposes.
00081   virtual void get_outline(vcl_vector<vgl_point_2d<double> >& pts) const;
00082 
00083   //: Version number for I/O
00084   short version_no() const;
00085 
00086   //: Name of the class
00087   virtual vcl_string is_a() const;
00088 
00089   //: Create a copy on the heap and return base class pointer
00090   virtual mfpf_point_finder* clone() const;
00091 
00092   //: Print class to os
00093   virtual void print_summary(vcl_ostream& os) const;
00094 
00095   //: Save class to binary file stream
00096   virtual void b_write(vsl_b_ostream& bfs) const;
00097 
00098   //: Load class from binary file stream
00099   virtual void b_read(vsl_b_istream& bfs);
00100 
00101   //: Test equality
00102   bool operator==(const mfpf_profile_pdf& nc) const;
00103 };
00104 
00105 #endif