31 #ifndef STATISTICS_PROBER_H
32 #define STATISTICS_PROBER_H
40 #include "SegmentProber.h"
77 void add(
const int &i,
const int &j){
95 return static_cast<double>(
size);
142 return cyy / (
cxx + cyy);
161 double getVarianceHorz()
const {
167 double getVarianceVert()
const {
233 return (eigenValue1 - eigenValue2) / (eigenValue1 + eigenValue2);
238 double getEigenValue1()
const {
245 double getEigenValue2()
const {
251 void toOstr(std::ostream & ostr)
const {
253 ostr <<
"s=" <<
getSize() <<
',';
257 ostr <<
"C=" <<
'[' <<
cxx <<
',' << cxy <<
';' << cxy <<
',' << cyy <<
']' <<
',';
258 ostr <<
"e12=" << getEigenValue1() <<
',' << getEigenValue2() <<
',';
276 cy =
static_cast<double>(sumY)/
sizeD;
285 cxy =
static_cast<double>(sumXY)/
sizeD -
cx*
cy;
286 cyy =
static_cast<double>(sumYY)/
sizeD -
cy*
cy;
291 const double epsilon = 0.00001;
292 if ((cxy > -epsilon) && (cxy < epsilon)){
317 double cxy2 = cxy*cxy;
318 double cxxPcyy =
cxx+cyy;
319 double cxxMcyy =
cxx-cyy;
322 temp = sqrt(cxxMcyy*cxxMcyy + 4.0*cxy2);
323 eigenValue1 = (cxxPcyy + temp)/2.0;
324 eigenValue2 = (cxxPcyy - temp)/2.0;
328 temp =
cxx-eigenValue1;
329 scale = sqrt(cxy2 + temp*temp);
330 eigenVector1x = temp/scale;
331 eigenVector1y = cxy/scale;
333 temp =
cxx-eigenValue2;
334 scale = sqrt(cxy2 + temp*temp);
335 eigenVector2x = temp/scale;
336 eigenVector2y = cxy/scale;
340 _updateNeeded =
false;
343 mutable bool _updateNeeded;
364 mutable double cxx, cyy, cxy;
366 mutable double eigenValue1;
367 mutable double eigenVector1x;
368 mutable double eigenVector1y;
369 mutable double eigenValue2;
370 mutable double eigenVector2x;
371 mutable double eigenVector2y;
372 mutable double elongation;
391 template <
class T,
class D>
406 const std::string & stats;
431 this->statistics.
add(i,j);
438 template <
class T,
class D>
441 ostr << prober.statistics;
Image with static geometry.
Definition: ImageChannel.h:60
bool isValidIntensity(S x) const
Criterion.
Definition: SegmentProber.h:81
A recursive method for visiting pixels of a segment in an image.
Definition: SegmentProber.h:100
A helper class applied by FloodFillOp and SegmentAreaOp.
Definition: SegmentStatisticsProber.h:392
virtual bool isValidSegment(int i, int j) const
Application dependent, to be redefined. Assumes checked coordinates.
Definition: SegmentStatisticsProber.h:411
virtual void update(int i, int j)
Application dependent operation performed in each segment location (i,j).
Definition: SegmentStatisticsProber.h:430
virtual void clear()
Called before processing each segment. Compare with init(), which is called once for each image.
Definition: SegmentStatisticsProber.h:423
A structure for accumulating coordinates and computing statistics thereof: area, centroid,...
Definition: SegmentStatisticsProber.h:53
double getSlimness() const
Returns the proportion in which the variance equals the variance of an annulus.
Definition: SegmentStatisticsProber.h:206
double getMeanY() const
Returns the horizontal coordinate of centre of mass.
Definition: SegmentStatisticsProber.h:119
void updateStats() const
Definition: SegmentStatisticsProber.h:268
double cy
Center of mass, y coordinate.
Definition: SegmentStatisticsProber.h:361
long sumXX
Sum of squared coordinates.
Definition: SegmentStatisticsProber.h:352
double getMeanX() const
Returns the horizontal coordinate of centre of mass.
Definition: SegmentStatisticsProber.h:106
double getElongation() const
Returns the proportion in which the variance equals the variance of an annulus.
Definition: SegmentStatisticsProber.h:231
double sizeD
Size in double precision.
Definition: SegmentStatisticsProber.h:355
double getSize() const
Returns the size of the segment.
Definition: SegmentStatisticsProber.h:94
virtual void clear()
Resets the statistics.
Definition: SegmentStatisticsProber.h:65
double getHorizontality() const
Returns the horizontal variance $\sigma_x$ scaled with total variance $\sigma_x + \sigma_y$....
Definition: SegmentStatisticsProber.h:132
double cx
Center of mass, x coordinate.
Definition: SegmentStatisticsProber.h:358
double getVariance() const
Returns the total variance of the pixel coordinates.
Definition: SegmentStatisticsProber.h:154
double getVerticality() const
Returns the vertical variance scaled with total variance. Takes values in [0,1].
Definition: SegmentStatisticsProber.h:140
virtual void add(const int &i, const int &j)
Accumulate location (i,j) in the statistics.
Definition: SegmentStatisticsProber.h:77
long sumX
Sum of coordinates.
Definition: SegmentStatisticsProber.h:349
long int size
Size of segment (area).
Definition: SegmentStatisticsProber.h:346
double cxx
Elements of covariance matrix.
Definition: SegmentStatisticsProber.h:364
Definition: DataSelector.cpp:1277