00001 // This is brl/bseg/bmrf/bmrf_arc.h 00002 #ifndef bmrf_arc_h_ 00003 #define bmrf_arc_h_ 00004 //: 00005 // \file 00006 // \brief An arc in a Markov Random Field (MRF) network 00007 // \author Matt Leotta, (mleotta@lems.brown.edu) 00008 // \date 6/7/04 00009 // 00010 // The MRF arc contains a directed link from one node to another 00011 // 00012 // \verbatim 00013 // Modifications 00014 // \endverbatim 00015 00016 00017 #include <vbl/vbl_ref_count.h> 00018 #include <vsl/vsl_binary_io.h> 00019 #include <bmrf/bmrf_node_sptr.h> 00020 #include <bmrf/bmrf_gamma_func_sptr.h> 00021 00022 #include "bmrf_arc_sptr.h" 00023 00024 //: Directed arc from one node to another 00025 class bmrf_arc : public vbl_ref_count 00026 { 00027 public: 00028 friend class bmrf_node; 00029 00030 //: Constructor 00031 bmrf_arc(); 00032 //: Copy constructor 00033 bmrf_arc(bmrf_arc const& a); 00034 //: Constructor 00035 bmrf_arc( const bmrf_node_sptr& f, const bmrf_node_sptr& t); 00036 //: Destructor 00037 ~bmrf_arc() {} 00038 00039 //: Produce a new arc which is the reverse of this one efficiently 00040 bmrf_arc_sptr reverse() const; 00041 00042 //: Binary save self to stream. 00043 void b_write(vsl_b_ostream &os) const; 00044 00045 //: Binary load self from stream. 00046 void b_read(vsl_b_istream &is); 00047 00048 //: Return the probability of this arc 00049 double probability(); 00050 00051 //: Return the minimum alpha in common with both nodes 00052 double min_alpha() const { return min_alpha_; } 00053 00054 //: Return the maximum alpha in common with both nodes 00055 double max_alpha() const { return max_alpha_; } 00056 00057 //: Return the average intesity error 00058 double avg_intensity_error() const { return avg_intensity_error_; } 00059 00060 //: Return the constant gamma value induced by the segment pair 00061 // \note this maps the "from" arc to the "to" arc 00062 double induced_gamma() const { return gamma_; } 00063 00064 //: Return the constant inverse gamma value induced by the segment pair 00065 // \note this maps the "to" arc to the "from" arc 00066 double induced_gamma_inv() const { return inv_gamma_; } 00067 00068 //: Return the piecewise linear gamma function fit to the pair 00069 bmrf_gamma_func_sptr gamma_func(); 00070 00071 //: Return the average match error given the induced gamma 00072 double induced_match_error() const { return induced_match_error_; } 00073 00074 //: The change in time spanned by this arc 00075 int time_step() const; 00076 00077 //: Smart pointer to the node where this arc originates 00078 bmrf_node_sptr from() { return bmrf_node_sptr(from_); } 00079 00080 //: Smart pointer to the node where this arc ends 00081 bmrf_node_sptr to() { return bmrf_node_sptr(to_); } 00082 00083 //: Compute the alpha range and intensity comparison 00084 // \note vertices must be set 00085 void time_init(); 00086 00087 private: 00088 bmrf_node* from_; 00089 bmrf_node* to_; 00090 00091 double probability_; 00092 double min_alpha_, max_alpha_; 00093 00094 double gamma_, inv_gamma_; 00095 double avg_intensity_error_; 00096 double induced_match_error_; 00097 00098 bmrf_gamma_func_sptr gamma_func_; 00099 }; 00100 00101 00102 //: Binary save bmrf_arc* to stream 00103 void vsl_b_write(vsl_b_ostream &os, const bmrf_arc* a); 00104 00105 //: Binary load bmrf_arc* from stream. 00106 void vsl_b_read(vsl_b_istream &is, bmrf_arc* &a); 00107 00108 //: Print an ASCII summary to the stream 00109 void vsl_print_summary(vcl_ostream &os, const bmrf_arc* a); 00110 00111 #endif // bmrf_arc_h_
1.4.4