Go to the documentation of this file.00001
00002 #ifndef bsta_joint_histogram_h_
00003 #define bsta_joint_histogram_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <vbl/vbl_array_2d.h>
00020 #include <vcl_vector.h>
00021 #include <vcl_iostream.h>
00022 #include <bsta/bsta_joint_histogram_base.h>
00023
00024 template <class T> class bsta_joint_histogram : public bsta_joint_histogram_base
00025 {
00026 public:
00027 bsta_joint_histogram();
00028
00029 bsta_joint_histogram(const T range, const unsigned int nbins,
00030 const T min_prob = 0.0);
00031
00032 bsta_joint_histogram(const T range_a, const unsigned int nbins_a,
00033 const T range_b, const unsigned int nbins_b,
00034 const T min_prob = 0.0);
00035
00036 bsta_joint_histogram(const T min_a, const T max_a,
00037 const unsigned int nbins_a,
00038 const T min_b, const T max_b,
00039 const unsigned int nbins_b,
00040 const T min_prob = 0.0);
00041
00042 ~bsta_joint_histogram() {}
00043
00044
00045 unsigned int nbins() const { return nbins_a_; }
00046
00047
00048 unsigned int nbins_a() const {return nbins_a_;}
00049
00050 unsigned int nbins_b() const {return nbins_b_;}
00051
00052
00053 T range() const {return range_a_;}
00054
00055
00056 T range_a() const {return range_a_;}
00057
00058 T range_b() const {return range_b_;}
00059
00060 T min_a() const {return min_a_;}
00061
00062 T max_a() const {return max_a_;}
00063
00064 T min_b() const {return min_b_;}
00065
00066 T max_b() const {return max_b_;}
00067
00068 T delta_a() const { return delta_a_; }
00069
00070 T delta_b() const { return delta_b_; }
00071
00072 T min_prob() const {return min_prob_;}
00073
00074 vbl_array_2d<T> counts() const {return counts_;}
00075
00076 void upcount(T a, T mag_a,
00077 T b, T mag_b);
00078 void parzen(const T sigma);
00079
00080
00081 T p(unsigned int a, unsigned int b) const;
00082
00083
00084 T p(T a, T b) const;
00085
00086 T volume() const;
00087 T entropy() const;
00088 T mutual_information() const;
00089 T renyi_entropy() const;
00090 T entropy_marginal_a() const;
00091
00092 void print(vcl_ostream& os = vcl_cout) const;
00093
00094
00095 bool avg_and_variance_bin_for_row_a(const unsigned int a, T & avg, T & var) const;
00096
00097 void set_count(unsigned r, unsigned c, T cnt)
00098 { if (r<static_cast<unsigned>(counts_.rows())&&
00099 c<static_cast<unsigned>(counts_.cols()))
00100 counts_[r][c]=cnt;
00101 }
00102
00103
00104 T get_count(unsigned r, unsigned c) const
00105 { if (r<static_cast<unsigned>(counts_.rows())&&
00106 c<static_cast<unsigned>(counts_.cols()))
00107 return counts_[r][c];
00108 else
00109 return T(0);
00110 }
00111
00112 T get_count(T a, T b) const;
00113
00114 void print_to_vrml(vcl_ostream& os) const;
00115 void print_to_m(vcl_ostream& os) const;
00116 void print_to_text(vcl_ostream& os) const;
00117
00118
00119 void clear();
00120
00121 private:
00122 void compute_volume() const;
00123 mutable bool volume_valid_;
00124 mutable T volume_;
00125 unsigned int nbins_a_, nbins_b_;
00126 T range_a_, range_b_;
00127 T delta_a_, delta_b_;
00128 T min_a_, max_a_;
00129 T min_b_, max_b_;
00130 T min_prob_;
00131 vbl_array_2d<T> counts_;
00132 };
00133 #include <bsta/bsta_joint_histogram_sptr.h>
00134 #define BSTA_JOINT_HISTOGRAM_INSTANTIATE(T) extern "Please #include <bsta/bsta_joint_histogram.txx>"
00135
00136 #endif // bsta_joint_histogram_h_