Go to the documentation of this file.00001 #ifndef sdet_mrf_site_bp_h_
00002 #define sdet_mrf_site_bp_h_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <vbl/vbl_ref_count.h>
00033 #include <vcl_vector.h>
00034 class sdet_mrf_site_bp : public vbl_ref_count
00035 {
00036 public:
00037
00038 sdet_mrf_site_bp(unsigned n_labels, float lambda, float truncation_cost);
00039 void switch_buffers() { prior_ = 1-prior_; }
00040 int prior() const { return prior_; }
00041 int current() const { return 1-prior_; }
00042
00043 void set_label(float obs_label) { obs_label_ = obs_label; }
00044
00045
00046
00047
00048 float D(unsigned fp);
00049
00050
00051 float M(unsigned nq, unsigned fp);
00052
00053
00054 float h(unsigned nq, unsigned fp) { return D(fp) + M(nq, fp); }
00055
00056
00057 float b(unsigned fp);
00058
00059
00060 unsigned believed_label();
00061
00062
00063 void set_cur_message(unsigned nq, unsigned fp, float msg);
00064
00065
00066 float cur_message(unsigned nq, unsigned fp) const { return msg_[1-prior_][nq][fp]; }
00067
00068
00069 float prior_message(unsigned nq, unsigned fp) const { return msg_[prior_][nq][fp]; }
00070
00071
00072 vcl_vector<float> prior_message(unsigned nq);
00073
00074
00075 void set_prior_message(unsigned nq, vcl_vector<float>const& msg);
00076
00077
00078 void clear();
00079
00080
00081 void print_prior_messages();
00082 void print_current_messages();
00083 void print_belief_vector();
00084
00085 protected:
00086
00087 float lambda_;
00088 float truncation_cost_;
00089
00090
00091 int prior_;
00092
00093
00094 unsigned n_labels_;
00095
00096
00097 unsigned n_ngbh_;
00098
00099
00100
00101
00102
00103
00104
00105
00106 vcl_vector< vcl_vector<vcl_vector<short> > > msg_;
00107
00108
00109
00110 float obs_label_;
00111 };
00112
00113 #include "sdet_mrf_site_bp_sptr.h"
00114 #endif // sdet_mrf_site_bp_h_