contrib/mul/mfpf/mfpf_sad_vec_cost.h
Go to the documentation of this file.
00001 #ifndef mfpf_sad_vec_cost_h_
00002 #define mfpf_sad_vec_cost_h_
00003 //:
00004 // \file
00005 // \brief Computes weighted sum of absolute 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 absolute differences to a mean
00012 class mfpf_sad_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_sad_vec_cost();
00025 
00026   //: Destructor
00027   virtual ~mfpf_sad_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 
00046   //: Version number for I/O
00047   short version_no() const;
00048 
00049   //: Name of the class
00050   virtual vcl_string is_a() const;
00051 
00052   //: Create a copy on the heap and return base class pointer
00053   virtual mfpf_vec_cost* clone() const;
00054 
00055   //: Print class to os
00056   virtual void print_summary(vcl_ostream& os) const;
00057 
00058   //: Save class to binary file stream
00059   virtual void b_write(vsl_b_ostream& bfs) const;
00060 
00061   //: Load class from binary file stream
00062   virtual void b_read(vsl_b_istream& bfs);
00063 };
00064 
00065 #endif