本文整理汇总了C++中Statistic::addValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Statistic::addValue方法的具体用法?C++ Statistic::addValue怎么用?C++ Statistic::addValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statistic
的用法示例。
在下文中一共展示了Statistic::addValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testStatistics
/**
* Example of a test. To be completed.
*
*/
bool testStatistics()
{
unsigned int nbok = 0;
unsigned int nb = 3;
trace.beginBlock ( "Testing Statistics ..." );
Statistic<double> stat;
for(unsigned int k=0; k < 1000; k++)
stat.addValue((double)k);
stat.terminate();
trace.info() << "Mean value = "<<stat.mean() << std::endl;
nbok += (stat.mean()==499.5) ? 1 : 0;
trace.info() << "Variance value = "<<stat.variance()<<std::endl;
trace.info() << "Max value = "<<stat.max()<<std::endl;
nbok += (stat.max()==999) ? 1 : 0;
trace.info() << "Min value = "<<stat.min()<<std::endl;
nbok += (stat.min()==0) ? 1 : 0;
trace.info() << "(" << nbok << "/" << nb << ") "
<< "true == true" << std::endl;
trace.endBlock();
return nbok == nb;
}
示例2: if
bool
checkPlane( Integer a, Integer b, Integer c, Integer d,
int diameter, unsigned int nbpoints,
Statistic<double> & stats )
{
typedef typename NaivePlaneComputer::Point Point;
typedef typename Point::Component PointInteger;
IntegerComputer<Integer> ic;
Integer absA = ic.abs( a );
Integer absB = ic.abs( b );
Integer absC = ic.abs( c );
Integer x, y, z;
Dimension axis;
if ( ( absA >= absB ) && ( absA >= absC ) )
axis = 0;
else if ( ( absB >= absA ) && ( absB >= absC ) )
axis = 1;
else
axis = 2;
Point p;
NaivePlaneComputer plane;
plane.init( axis, diameter, 1, 1 );
// Checks that points within the naive plane are correctly recognized.
unsigned int nb = 0;
unsigned int nbok = 0;
unsigned int nbchanges = 0;
unsigned int complexity = plane.complexity();
while ( nb != nbpoints )
{
p[ 0 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
p[ 1 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
p[ 2 ] = getRandomInteger<PointInteger>( -diameter+1, diameter );
x = (Integer) p[ 0 ];
y = (Integer) p[ 1 ];
z = (Integer) p[ 2 ];
switch ( axis ) {
case 0: p[ 0 ] = NumberTraits<Integer>::castToInt64_t( ic.ceilDiv( d - b * y - c * z, a ) ); break;
case 1: p[ 1 ] = NumberTraits<Integer>::castToInt64_t( ic.ceilDiv( d - a * x - c * z, b ) ); break;
case 2: p[ 2 ] = NumberTraits<Integer>::castToInt64_t( ic.ceilDiv( d - a * x - b * y, c ) ); break;
}
bool ok = plane.extend( p ); // should be ok
++nb, nbok += ok ? 1 : 0;
if ( ! ok )
{
std::cerr << "[ERROR] p=" << p << " NOT IN plane=" << plane << std::endl;
break;
}
if ( plane.complexity() != complexity )
{
complexity = plane.complexity();
++nbchanges;
}
}
stats.addValue( (double) nbchanges );
return nb == nbok;
}
示例3: aPredicate
void
getStatsFromDistanceMap(Statistic<double> & stats, const Image3D &imageA, int aMin, int aMax,
const Image3D & imageB, int bMin, int bMax,
bool statOnFalsePositiveOnly=false, Point *ptMax=0){
// Get the digital set from ref image by computing the surface (use -1 and +1 since the interval of append function are open)
Z3i::DigitalSet set3dRef (imageA.domain());
SetFromImage<Z3i::DigitalSet>::append<Image3D>(set3dRef, imageA, aMin-1,aMax);
typedef functors::NotPointPredicate<Z3i::DigitalSet> NegPredicate;
// Applying the distance transform on the digital surface of the set:
typedef DistanceTransformation<Z3i::Space, NegPredicate, Z3i::L2Metric> DTL2;
const NegPredicate aPredicate( set3dRef );
DTL2 dtL2( imageA.domain(), aPredicate, Z3i::l2Metric );
// Get the set of point of imageB: (use -1 and +1 since the interval of append function are open)
Z3i::DigitalSet set3dComp (imageB.domain());
SetFromImage<Z3i::DigitalSet>::append<Image3D>(set3dComp, imageB, bMin-1, bMax);
unsigned int nbAdded=0;
double maxDist=0;
//Applying stats from the set to be compared (from imageB)
for(Z3i::DigitalSet::ConstIterator it= set3dComp.begin(); it!= set3dComp.end(); ++it){
if((!statOnFalsePositiveOnly) || (isDiff(imageA, aMin, aMax, imageB, bMin, bMax, *it))){
DTL2::Value distance = dtL2(*it);
stats.addValue(distance);
nbAdded++;
if(maxDist<distance){
maxDist=distance;
if(ptMax!=0){
(*ptMax)[0]=(*it)[0];
(*ptMax)[1]=(*it)[1];
(*ptMax)[2]=(*it)[2];
}
}
}
}
if(nbAdded==0)
trace.error() << "No point added to statistics, will failed..." << endl;
}