00001 #ifndef mfpf_ssd_vec_cost_builder_h_ 00002 #define mfpf_ssd_vec_cost_builder_h_ 00003 //: 00004 // \file 00005 // \brief Builder for mfpf_ssd_vec_cost objects. 00006 // \author Tim Cootes 00007 00008 #include <mfpf/mfpf_vec_cost_builder.h> 00009 #include <vnl/vnl_vector.h> 00010 #include <vcl_iosfwd.h> 00011 #include <vcl_vector.h> 00012 00013 //: Builder for mfpf_ssd_vec_cost objects. 00014 // Computes mean and weights given the training data. 00015 // Currently uses the mean absolute difference to estimate the 00016 // weights (rather than variance, which is not so robust). 00017 class mfpf_ssd_vec_cost_builder : public mfpf_vec_cost_builder 00018 { 00019 private: 00020 //: Minimum variance allowed 00021 double min_var_; 00022 00023 //: Space to record examples 00024 vcl_vector<vnl_vector<double> > data_; 00025 00026 //: Define default values 00027 void set_defaults(); 00028 public: 00029 00030 // Dflt ctor 00031 mfpf_ssd_vec_cost_builder(); 00032 00033 // Destructor 00034 virtual ~mfpf_ssd_vec_cost_builder(); 00035 00036 00037 //: Create new mfpf_ssd_vec_cost on heap 00038 virtual mfpf_vec_cost* new_cost() const; 00039 00040 //: Initialise building 00041 // Must be called before any calls to add_example(...) 00042 virtual void clear(unsigned n_egs); 00043 00044 //: Add one example to the model 00045 virtual void add_example(const vnl_vector<double>& v); 00046 00047 //: Build object from the data supplied in add_example() 00048 virtual void build(mfpf_vec_cost&); 00049 00050 //: Initialise from a string stream 00051 virtual bool set_from_stream(vcl_istream &is); 00052 00053 //: Name of the class 00054 virtual vcl_string is_a() const; 00055 00056 //: Create a copy on the heap and return base class pointer 00057 virtual mfpf_vec_cost_builder* clone() const; 00058 00059 //: Print class to os 00060 virtual void print_summary(vcl_ostream& os) const; 00061 00062 //: Version number for I/O 00063 short version_no() const; 00064 00065 //: Save class to binary file stream 00066 virtual void b_write(vsl_b_ostream& bfs) const; 00067 00068 //: Load class from binary file stream 00069 virtual void b_read(vsl_b_istream& bfs); 00070 }; 00071 00072 #endif // mfpf_ssd_vec_cost_builder_h_