contrib/mul/mfpf/mfpf_vec_cost.h
Go to the documentation of this file.
00001 #ifndef mfpf_vec_cost_h_
00002 #define mfpf_vec_cost_h_
00003 //:
00004 // \file
00005 // \brief Cost functions to evaluate vector of pixel samples
00006 // \author Tim Cootes
00007 
00008 #include <vnl/vnl_vector.h>
00009 #include <vsl/vsl_binary_io.h>
00010 #include <vcl_string.h>
00011 #include <vcl_iosfwd.h>
00012 
00013 //: Cost functions to evaluate vector of pixel samples
00014 //  Derived functions return some form of sum of differences
00015 //  from a mean, or Mahalanobis type measure.  Perfect match
00016 //  returns zero, imperfect matches return positive numbers.
00017 class mfpf_vec_cost
00018 {
00019  public:
00020 
00021   //: Dflt ctor
00022   mfpf_vec_cost();
00023 
00024   //: Destructor
00025   virtual ~mfpf_vec_cost();
00026 
00027   //: Evaluate function given vector
00028   virtual double evaluate(const vnl_vector<double>& v)=0;
00029 
00030   //: Return a vector which is the most likely expected vector
00031   //  I.e., return the mean for a statistical model.
00032   //  Used when displaying results
00033   virtual void get_average(vnl_vector<double>& v) const=0;
00034 
00035   //: Version number for I/O
00036   short version_no() const;
00037 
00038   //: Name of the class
00039   virtual vcl_string is_a() const;
00040 
00041   //: Create a copy on the heap and return base class pointer
00042   virtual mfpf_vec_cost* clone() const = 0;
00043 
00044   //: Print class to os
00045   virtual void print_summary(vcl_ostream& os) const =0;
00046 
00047   //: Save class to binary file stream
00048   virtual void b_write(vsl_b_ostream& bfs) const =0;
00049 
00050   //: Load class from binary file stream
00051   virtual void b_read(vsl_b_istream& bfs) =0;
00052 };
00053 
00054 //: Allows derived class to be loaded by base-class pointer
00055 void vsl_add_to_binary_loader(const mfpf_vec_cost& b);
00056 
00057 //: Binary file stream output operator for class reference
00058 void vsl_b_write(vsl_b_ostream& bfs, const mfpf_vec_cost& b);
00059 
00060 //: Binary file stream input operator for class reference
00061 void vsl_b_read(vsl_b_istream& bfs, mfpf_vec_cost& b);
00062 
00063 //: Stream output operator for class reference
00064 vcl_ostream& operator<<(vcl_ostream& os,const mfpf_vec_cost& b);
00065 
00066 //: Stream output operator for class pointer
00067 vcl_ostream& operator<<(vcl_ostream& os,const mfpf_vec_cost* b);
00068 
00069 #endif // mfpf_vec_cost_h_