31#ifndef STATISTICS_PROBER_H
32#define STATISTICS_PROBER_H
39#include "SegmentProber.h"
76 void add(
const int &i,
const int &j){
94 return static_cast<double>(
size);
141 return cyy / (
cxx + cyy);
160 double getVarianceHorz()
const {
166 double getVarianceVert()
const {
232 return (eigenValue1 - eigenValue2) / (eigenValue1 + eigenValue2);
237 double getEigenValue1()
const {
244 double getEigenValue2()
const {
250 void toOstr(std::ostream & ostr)
const {
252 ostr <<
"s=" <<
getSize() <<
',';
256 ostr <<
"C=" <<
'[' <<
cxx <<
',' << cxy <<
';' << cxy <<
',' << cyy <<
']' <<
',';
257 ostr <<
"e12=" << getEigenValue1() <<
',' << getEigenValue2() <<
',';
275 cy =
static_cast<double>(sumY)/
sizeD;
284 cxy =
static_cast<double>(sumXY)/
sizeD -
cx*
cy;
285 cyy =
static_cast<double>(sumYY)/
sizeD -
cy*
cy;
290 const double epsilon = 0.00001;
291 if ((cxy > -epsilon) && (cxy < epsilon)){
316 double cxy2 = cxy*cxy;
317 double cxxPcyy =
cxx+cyy;
318 double cxxMcyy =
cxx-cyy;
321 temp = sqrt(cxxMcyy*cxxMcyy + 4.0*cxy2);
322 eigenValue1 = (cxxPcyy + temp)/2.0;
323 eigenValue2 = (cxxPcyy - temp)/2.0;
327 temp =
cxx-eigenValue1;
328 scale = sqrt(cxy2 + temp*temp);
329 eigenVector1x = temp/scale;
330 eigenVector1y = cxy/scale;
332 temp =
cxx-eigenValue2;
333 scale = sqrt(cxy2 + temp*temp);
334 eigenVector2x = temp/scale;
335 eigenVector2y = cxy/scale;
339 _updateNeeded =
false;
342 mutable bool _updateNeeded;
363 mutable double cxx, cyy, cxy;
365 mutable double eigenValue1;
366 mutable double eigenVector1x;
367 mutable double eigenVector1y;
368 mutable double eigenValue2;
369 mutable double eigenVector2x;
370 mutable double eigenVector2y;
371 mutable double elongation;
390template <
class T,
class D>
405 const std::string & stats;
430 this->statistics.
add(i,j);
437template <
class T,
class D>
440 ostr << prober.statistics;
Image with static geometry.
Definition ImageChannel.h:58
bool isValidIntensity(S x) const
Criterion.
Definition SegmentProber.h:79
A recursive method for visiting pixels of a segment in an image.
Definition SegmentProber.h:98
A helper class applied by FloodFillOp and SegmentAreaOp.
Definition SegmentStatisticsProber.h:391
virtual bool isValidSegment(int i, int j) const
Application dependent, to be redefined. Assumes checked coordinates.
Definition SegmentStatisticsProber.h:410
virtual void update(int i, int j)
Application dependent operation performed in each segment location (i,j).
Definition SegmentStatisticsProber.h:429
virtual void clear()
Called before processing each segment. Compare with init(), which is called once for each image.
Definition SegmentStatisticsProber.h:422
A structure for accumulating coordinates and computing statistics thereof: area, centroid,...
Definition SegmentStatisticsProber.h:52
double getSlimness() const
Returns the proportion in which the variance equals the variance of an annulus.
Definition SegmentStatisticsProber.h:205
double getMeanY() const
Returns the horizontal coordinate of centre of mass.
Definition SegmentStatisticsProber.h:118
void updateStats() const
Definition SegmentStatisticsProber.h:267
double cy
Center of mass, y coordinate.
Definition SegmentStatisticsProber.h:360
long sumXX
Sum of squared coordinates.
Definition SegmentStatisticsProber.h:351
double getMeanX() const
Returns the horizontal coordinate of centre of mass.
Definition SegmentStatisticsProber.h:105
double getElongation() const
Returns the proportion in which the variance equals the variance of an annulus.
Definition SegmentStatisticsProber.h:230
double sizeD
Size in double precision.
Definition SegmentStatisticsProber.h:354
double getSize() const
Returns the size of the segment.
Definition SegmentStatisticsProber.h:93
virtual void clear()
Resets the statistics.
Definition SegmentStatisticsProber.h:64
double getHorizontality() const
Returns the horizontal variance $\sigma_x$ scaled with total variance $\sigma_x + \sigma_y$....
Definition SegmentStatisticsProber.h:131
double cx
Center of mass, x coordinate.
Definition SegmentStatisticsProber.h:357
double getVariance() const
Returns the total variance of the pixel coordinates.
Definition SegmentStatisticsProber.h:153
double getVerticality() const
Returns the vertical variance scaled with total variance. Takes values in [0,1].
Definition SegmentStatisticsProber.h:139
virtual void add(const int &i, const int &j)
Accumulate location (i,j) in the statistics.
Definition SegmentStatisticsProber.h:76
long sumX
Sum of coordinates.
Definition SegmentStatisticsProber.h:348
long int size
Size of segment (area).
Definition SegmentStatisticsProber.h:345
double cxx
Elements of covariance matrix.
Definition SegmentStatisticsProber.h:363
Definition DataSelector.cpp:1277