48 #ifndef _MIRA_INCREMENTALMOMENTS_H_ 49 #define _MIRA_INCREMENTALMOMENTS_H_ 61 template <
typename T,
int D,
int Order>
64 static_assert(
sizeof(T)==0,
"There is no implementation for the moment of the given dimension D and Order");
86 void insert(
const T& x, T weight = T(1))
89 _insert(x, weight, ctx);
123 ctx.alpha = k/ctx.nk;
124 ctx.beta = weight/ctx.nk;
127 m1 = ctx.alpha*m1 + ctx.beta*x;
132 template <
typename T>
136 typedef typename Base::Ctx Ctx;
154 _insert(x, weight, ctx);
158 T
var()
const {
return m2; }
169 Base::_insert(x, weight, ctx);
170 float alpha_beta = ctx.alpha*ctx.beta;
173 m2 = (ctx.alpha*m2) + alpha_beta * (d*d);
180 template <
typename T,
int D>
203 _insert(x, weight, ctx);
237 ctx.alpha = k/ctx.nk;
238 ctx.beta = weight/ctx.nk;
241 m1 = ctx.alpha*m1 + ctx.beta*x;
246 template <
typename T,
int D>
252 typedef typename Base::Ctx Ctx;
270 _insert(x, weight, ctx);
285 Base::_insert(x, weight, ctx);
286 float alpha_beta = ctx.alpha*ctx.beta;
289 m2 = (ctx.alpha*m2) + alpha_beta * (d*d.transpose());
T k
Definition: IncrementalMoments.h:106
Include file for all eigen related things.
T m1
the computed mean
Definition: IncrementalMoments.h:115
void reset()
Definition: IncrementalMoments.h:260
Eigen::Matrix< T, D, D > Matrix
Definition: IncrementalMoments.h:185
Incremental computation of one- and higher-dimensional statistical moments of first and higher orders...
Definition: IncrementalMoments.h:62
void reset()
Definition: IncrementalMoments.h:193
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
T nk
Definition: IncrementalMoments.h:107
T nk
Definition: IncrementalMoments.h:221
T sumWeight() const
Returns the sum of all sample weights, if all samples have the weight 1.0 this corresponds to the num...
Definition: IncrementalMoments.h:98
Matrix cov() const
Returns the computed covariance.
Definition: IncrementalMoments.h:274
T sumWeight() const
Returns the sum of all sample weights, if all samples have the weight 1.0 this corresponds to the num...
Definition: IncrementalMoments.h:212
void _insert(const Vector &x, T weight, Ctx &ctx)
Definition: IncrementalMoments.h:233
void _insert(const Vector &x, T weight, Ctx &ctx)
Definition: IncrementalMoments.h:283
Vector m1
the computed mean
Definition: IncrementalMoments.h:229
Eigen::Matrix< T, D, 1 > Vector
Definition: IncrementalMoments.h:184
T beta
Definition: IncrementalMoments.h:109
Definition: IncrementalMoments.h:181
T beta
Definition: IncrementalMoments.h:223
T alpha
Definition: IncrementalMoments.h:108
T var() const
Returns the computed variance.
Definition: IncrementalMoments.h:158
void insert(const T &x, T weight=T(1))
inserts a new sample
Definition: IncrementalMoments.h:151
void insert(const T &x, T weight=T(1))
inserts a new sample
Definition: IncrementalMoments.h:86
T k
the cumulated weights
Definition: IncrementalMoments.h:227
T mean() const
Returns the computed mean.
Definition: IncrementalMoments.h:101
IncrementalMoments()
Definition: IncrementalMoments.h:75
T k
Definition: IncrementalMoments.h:220
IncrementalMoments()
Definition: IncrementalMoments.h:140
IncrementalMoments()
Definition: IncrementalMoments.h:189
T m2
the computed variance
Definition: IncrementalMoments.h:163
IncrementalMoments()
Definition: IncrementalMoments.h:256
void reset()
Definition: IncrementalMoments.h:144
void reset()
Definition: IncrementalMoments.h:79
void _insert(const T &x, T weight, Ctx &ctx)
Definition: IncrementalMoments.h:119
void insert(const Vector &x, T weight=T(1))
inserts a new sample
Definition: IncrementalMoments.h:200
const Vector & mean() const
Returns the computed mean.
Definition: IncrementalMoments.h:215
Matrix m2
the computed covariance
Definition: IncrementalMoments.h:279
void _insert(const T &x, T weight, Ctx &ctx)
Definition: IncrementalMoments.h:167
T k
the cumulated weights
Definition: IncrementalMoments.h:113
void insert(const Vector &x, T weight=T(1))
inserts a new sample
Definition: IncrementalMoments.h:267
T alpha
Definition: IncrementalMoments.h:222
Definition: IncrementalMoments.h:71