00001 #ifndef mfpf_ssd_vec_cost_h_ 00002 #define mfpf_ssd_vec_cost_h_ 00003 //: 00004 // \file 00005 // \brief Computes weighted sum of square differences to a mean 00006 // \author Tim Cootes 00007 00008 #include <mfpf/mfpf_vec_cost.h> 00009 #include <vcl_iosfwd.h> 00010 00011 //: Computes weighted sum of square differences to a mean 00012 class mfpf_ssd_vec_cost : public mfpf_vec_cost 00013 { 00014 private: 00015 //: Mean for vector 00016 vnl_vector<double> mean_; 00017 00018 //: Weights to apply to each element in sum 00019 vnl_vector<double> wts_; 00020 00021 public: 00022 00023 //: Dflt ctor 00024 mfpf_ssd_vec_cost(); 00025 00026 //: Destructor 00027 virtual ~mfpf_ssd_vec_cost(); 00028 00029 //: Define mean and weights 00030 void set(const vnl_vector<double>& mean, 00031 const vnl_vector<double>& wts); 00032 00033 //: Mean for vector 00034 const vnl_vector<double>& mean() const { return mean_; } 00035 00036 //: Weights to apply to each element in sum 00037 const vnl_vector<double>& wts() const { return wts_; } 00038 00039 //: Evaluate weighted sum of absolute difference from mean 00040 virtual double evaluate(const vnl_vector<double>& v); 00041 00042 //: Return the mean 00043 virtual void get_average(vnl_vector<double>& v) const; 00044 00045 //: Version number for I/O 00046 short version_no() const; 00047 00048 //: Name of the class 00049 virtual vcl_string is_a() const; 00050 00051 //: Create a copy on the heap and return base class pointer 00052 virtual mfpf_vec_cost* clone() const; 00053 00054 //: Print class to os 00055 virtual void print_summary(vcl_ostream& os) const; 00056 00057 //: Save class to binary file stream 00058 virtual void b_write(vsl_b_ostream& bfs) const; 00059 00060 //: Load class from binary file stream 00061 virtual void b_read(vsl_b_istream& bfs); 00062 }; 00063 00064 #endif