contrib/mul/mfpf/mfpf_profile_pdf_builder.h
Go to the documentation of this file.
00001 #ifndef mfpf_profile_pdf_builder_h_
00002 #define mfpf_profile_pdf_builder_h_
00003 //:
00004 // \file
00005 // \brief Builder for mfpf_profile_pdf objects.
00006 // \author Tim Cootes
00007 
00008 #include <mfpf/mfpf_point_finder_builder.h>
00009 #include <vpdfl/vpdfl_builder_base.h>
00010 #include <mbl/mbl_cloneable_ptr.h>
00011 #include <vgl/vgl_fwd.h>
00012 #include <vcl_iosfwd.h>
00013 
00014 //: Builder for mfpf_profile_pdf objects.
00015 class mfpf_profile_pdf_builder : public mfpf_point_finder_builder
00016 {
00017  private:
00018   //: Kernel mask is [ilo_,ihi_]
00019   int ilo_;
00020   //: Kernel mask is [ilo_,ihi_]
00021   int ihi_;
00022 
00023   //: Builder for PDf for profile vector
00024   mbl_cloneable_ptr<vpdfl_builder_base> pdf_builder_;
00025 
00026   //: Samples added in calls to add_example()
00027   vcl_vector<vnl_vector<double> > data_;
00028 
00029   //: Define default values
00030   void set_defaults();
00031  public:
00032 
00033   // Dflt ctor
00034   mfpf_profile_pdf_builder();
00035 
00036   // Destructor
00037   virtual ~mfpf_profile_pdf_builder();
00038 
00039   void set(int ilo, int ihi,
00040            const vpdfl_builder_base& builder);
00041 
00042   //: Define region size in world co-ordinates
00043   //  Sets up ROI to cover given box (with samples at step_size()),
00044   //  with ref point at centre.
00045   //  Sets ihi = ceil(wi/2*step_size), ilo=-ihi
00046   virtual void set_region_size(double wi, double wj);
00047 
00048   //: Kernel mask is [ilo_,ihi_]
00049   int ilo() const { return ilo_; }
00050 
00051   //: Kernel mask is [ilo_,ihi_]
00052   int ihi() const { return ihi_; }
00053 
00054   vpdfl_builder_base& pdf_builder() { return pdf_builder_; }
00055 
00056   //: Create new mfpf_profile_pdf on heap
00057   virtual mfpf_point_finder* new_finder() const;
00058 
00059   //: Initialise building
00060   // Must be called before any calls to add_example(...)
00061   virtual void clear(unsigned n_egs);
00062 
00063   //: Add one example to the model
00064   virtual void add_example(const vimt_image_2d_of<float>& image,
00065                            const vgl_point_2d<double>& p,
00066                            const vgl_vector_2d<double>& u);
00067 
00068   //: Build object from the data supplied in add_example()
00069   virtual void build(mfpf_point_finder&);
00070 
00071   //: Initialise from a string stream
00072   virtual bool set_from_stream(vcl_istream &is);
00073 
00074   //: Name of the class
00075   virtual vcl_string is_a() const;
00076 
00077   //: Create a copy on the heap and return base class pointer
00078   virtual mfpf_point_finder_builder* clone() const;
00079 
00080   //: Print class to os
00081   virtual void print_summary(vcl_ostream& os) const;
00082 
00083   //: Version number for I/O
00084   short version_no() const;
00085 
00086   //: Save class to binary file stream
00087   virtual void b_write(vsl_b_ostream& bfs) const;
00088 
00089   //: Load class from binary file stream
00090   virtual void b_read(vsl_b_istream& bfs);
00091 };
00092 
00093 #endif