00001
00002
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 #ifndef OLN_UTILS_SE_STAT_HH
00030 # define OLN_UTILS_SE_STAT_HH
00031
00032 # include <oln/core/abstract/point.hh>
00033 # include <oln/core/abstract/image.hh>
00034 # include <oln/core/abstract/struct_elt.hh>
00035
00036 # include <ntg/core/abstract_hierarchy.hh>
00037 # include <ntg/all.hh>
00038 # include <ntg/core/macros.hh>
00039 # include <oln/math/macros.hh>
00040
00041 namespace oln {
00042 namespace utils {
00043 namespace internal {
00063 template <typename DestT,
00064 typename SrcT>
00065 struct f_to_float_
00066 {
00067 static
00068 DestT
00069 doit(const SrcT& s)
00070 {
00071 return s;
00072 }
00073 };
00074
00076 template <unsigned ncomps,
00077 unsigned qbits,
00078 template <unsigned> class color_system>
00079 struct f_to_float_<typename ntg::color<ncomps,
00080 qbits,
00081 color_system>::float_vec_type,
00082 ntg::color<ncomps, qbits, color_system> >
00083 {
00084 static
00085 typename ntg::color<ncomps, qbits, color_system>::float_vec_type
00086 doit(const ntg::color<ncomps, qbits, color_system>& s)
00087 {
00088 return s.to_float();
00089 }
00090 };
00091 }
00092
00093
00102 template <typename Sum = ntg::float_s, typename Var = ntg::float_s>
00103 class se_stat
00104 {
00105 public:
00107 typedef Sum sum_type;
00109 typedef Var variance_type;
00110
00116 template <class I, class S>
00117 se_stat(const oln::abstract::image<I> &im,
00118 const oln_point_type(I) &p,
00119 const oln::abstract::struct_elt<S> &s)
00120 {
00121 compute(im, p, s);
00122 }
00123
00125 template <class I, class S>
00126 se_stat &
00127 compute(const oln::abstract::image<I> &im,
00128 const oln_point_type(I) &p,
00129 const oln::abstract::struct_elt<S> &s);
00130
00132 inline Sum
00133 mean() const
00134 {
00135 return mean_;
00136 }
00137
00139 inline Var
00140 variance() const
00141 {
00142 return variance_;
00143 }
00144
00146 inline Sum
00147 sum() const
00148 {
00149 return sum_;
00150 }
00151
00153 inline unsigned
00154 card() const
00155 {
00156 return card_;
00157 }
00158
00159 protected:
00160 Var variance_;
00161 Sum mean_;
00162 Sum sum_;
00163 int card_;
00164 };
00165
00166 }
00167
00168 }
00169
00170 #include "se_stat.hxx"
00171
00172 #endif