本文整理汇总了C++中Estimator::eval方法的典型用法代码示例。如果您正苦于以下问题:C++ Estimator::eval方法的具体用法?C++ Estimator::eval怎么用?C++ Estimator::eval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Estimator
的用法示例。
在下文中一共展示了Estimator::eval方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::vector<typename Estimator::Quantity>
estimateQuantity( Estimator & estimator,
ConstIterator it, ConstIterator it_end )
{
std::vector<typename Estimator::Quantity> values;
for ( ; it != it_end; ++it )
{
values.push_back( estimator.eval( it ) );
}
return values;
}
示例2: area_output
void computeEstimation
( const po::variables_map& vm, //< command-line parameters
const KSpace& K, //< cellular grid space
const ImplicitShape& shape, //< implicit shape "ground truth"
const Surface& surface, //< digital surface approximating shape
Estimator& estimator ) //< an initialized estimator
{
typedef typename Surface::ConstIterator ConstIterator;
typedef typename Surface::Surfel Surfel;
typedef typename Estimator::Quantity Quantity;
typedef double Scalar;
typedef DepthFirstVisitor< Surface > Visitor;
typedef GraphVisitorRange< Visitor > VisitorRange;
typedef typename VisitorRange::ConstIterator VisitorConstIterator;
std::string fname = vm[ "output" ].as<std::string>();
string nameEstimator = vm[ "estimator" ].as<string>();
trace.beginBlock( "Computing " + nameEstimator + " estimations." );
CountedPtr<VisitorRange> range( new VisitorRange( new Visitor( surface, *(surface.begin()) )) );
std::vector<Quantity> n_estimations;
estimator.eval( range->begin(), range->end(), std::back_inserter( n_estimations ) );
trace.info() << "- nb estimations = " << n_estimations.size() << std::endl;
trace.endBlock();
trace.beginBlock( "Computing areas." );
range = CountedPtr<VisitorRange>( new VisitorRange( new Visitor( surface, *(surface.begin()) )) );
double area_est = 0.0; // normal integration with absolute value.
unsigned int i = 0;
for ( typename VisitorRange::ConstIterator it = range->begin(), itE = range->end();
it != itE; ++it, ++i )
{
Surfel s = *it;
Dimension k = K.sOrthDir( s );
area_est += abs( n_estimations[ i ][ k ] );
}
double h = vm["gridstep"].as<double>();
trace.info() << setprecision(10) << "- Area_est " << ( area_est * h * h ) << std::endl;
std::ostringstream area_sstr;
area_sstr << fname << "-" << nameEstimator << "-area-" << h << ".txt";
std::ofstream area_output( area_sstr.str().c_str() );
area_output << "# Area estimation by digital surface integration." << std::endl;
area_output << "# X: " << nameEstimator << std::endl;
area_output << "# h Area[X] nb_surf" << std::endl;
area_output << setprecision(10) << h
<< " " << ( area_est * h * h )
<< " " << i << std::endl;
area_output.close();
trace.endBlock();
}
示例3: exportNOFFSurface
void exportNOFFSurface( const DigitalSurface& surface,
const Estimator& estimator,
std::ostream& output )
{
typedef typename DigitalSurface::KSpace KSpace;
typedef typename DigitalSurface::ConstIterator ConstIterator;
typedef typename DigitalSurface::Surfel Surfel;
typedef typename KSpace::SCell SCell;
typedef typename Estimator::Quantity Quantity;
const KSpace& ks = surface.container().space();
std::map<Surfel,Quantity> normals;
for ( ConstIterator it = surface.begin(), itE = surface.end(); it != itE; ++it )
{
Quantity n_est = estimator.eval( it );
normals[ *it ] = n_est;
}
CanonicSCellEmbedder<KSpace> surfelEmbedder( ks );
typedef SCellEmbedderWithNormal< CanonicSCellEmbedder<KSpace> > Embedder;
Embedder embedder( surfelEmbedder, normals );
surface.exportAs3DNOFF( output, embedder );
}
示例4: adev_output
void computeEstimation
( const po::variables_map& vm, //< command-line parameters
const KSpace& K, //< cellular grid space
const ImplicitShape& shape, //< implicit shape "ground truth"
const Surface& surface, //< digital surface approximating shape
TrueEstimator& true_estimator, //< "ground truth" estimator
Estimator& estimator ) //< an initialized estimator
{
typedef typename Surface::ConstIterator ConstIterator;
typedef typename Surface::Surfel Surfel;
typedef typename Estimator::Quantity Quantity;
typedef double Scalar;
typedef DepthFirstVisitor< Surface > Visitor;
typedef GraphVisitorRange< Visitor > VisitorRange;
typedef typename VisitorRange::ConstIterator VisitorConstIterator;
std::string fname = vm[ "output" ].as<std::string>();
string nameEstimator = vm[ "estimator" ].as<string>();
trace.beginBlock( "Computing " + nameEstimator + "estimations." );
CountedPtr<VisitorRange> range( new VisitorRange( new Visitor( surface, *(surface.begin()) )) );
std::vector<Quantity> n_estimations;
estimator.eval( range->begin(), range->end(), std::back_inserter( n_estimations ) );
trace.info() << "- nb estimations = " << n_estimations.size() << std::endl;
trace.endBlock();
trace.beginBlock( "Computing ground truth." );
range = CountedPtr<VisitorRange>( new VisitorRange( new Visitor( surface, *(surface.begin()) )) );
std::vector<Quantity> n_true_estimations;
true_estimator.eval( range->begin(), range->end(), std::back_inserter( n_true_estimations ) );
trace.info() << "- nb estimations = " << n_true_estimations.size() << std::endl;
trace.endBlock();
trace.beginBlock( "Correcting orientations." );
ASSERT( n_estimations.size() == n_true_estimations.size() );
for ( unsigned int i = 0; i < n_estimations.size(); ++i )
if ( n_estimations[ i ].dot( n_true_estimations[ i ] ) < 0 )
n_estimations[ i ] = -n_estimations[ i ];
trace.endBlock();
DGtal::GradientColorMap<double> grad( 0.0, 40.0 );
// 0 metallic blue, 5 light cyan, 10 light green, 15 light
// yellow, 20 yellow, 25 orange, 30 red, 35, dark red, 40- grey
grad.addColor( DGtal::Color( 128, 128, 255 ) ); // 0
grad.addColor( DGtal::Color( 128, 255, 255 ) ); // 5
grad.addColor( DGtal::Color( 128, 255, 128 ) ); // 10
grad.addColor( DGtal::Color( 255, 255, 128 ) ); // 15
grad.addColor( DGtal::Color( 255, 255, 0 ) ); // 20
grad.addColor( DGtal::Color( 255, 128, 0 ) ); // 25
grad.addColor( DGtal::Color( 255, 0, 0 ) ); // 30
grad.addColor( DGtal::Color( 128, 0, 0 ) ); // 35
grad.addColor( DGtal::Color( 128, 128, 128 ) ); // 40
if ( vm.count( "angle-deviation-stats" ) )
{
trace.beginBlock( "Computing angle deviation error stats." );
std::ostringstream adev_sstr;
adev_sstr << fname << "-" << nameEstimator << "-angle-deviation-"
<< estimator.h() << ".txt";
DGtal::Statistic<Scalar> adev_stat;
unsigned int i = 0;
range = CountedPtr<VisitorRange>( new VisitorRange( new Visitor( surface, *(surface.begin()) )) );
for ( VisitorConstIterator it = range->begin(), itE = range->end(); it != itE; ++it, ++i )
{
Quantity n_est = n_estimations[ i ];
Quantity n_true_est = n_true_estimations[ i ];
Scalar angle_error = acos( n_est.dot( n_true_est ) );
adev_stat.addValue( angle_error );
}
adev_stat.terminate();
std::ofstream adev_output( adev_sstr.str().c_str() );
adev_output << "# Average error X of the absolute angle between two vector estimations." << std::endl;
adev_output << "# h L1 L2 Loo E[X] Var[X] Min[X] Max[X] Nb[X]" << std::endl;
adev_output << estimator.h()
<< " " << adev_stat.mean() // L1
<< " " << sqrt( adev_stat.unbiasedVariance()
+ adev_stat.mean()*adev_stat.mean() ) // L2
<< " " << adev_stat.max() // Loo
<< " " << adev_stat.mean() // E[X] (=L1)
<< " " << adev_stat.unbiasedVariance() // Var[X]
<< " " << adev_stat.min() // Min[X]
<< " " << adev_stat.max() // Max[X]
<< " " << adev_stat.samples() // Nb[X]
<< std::endl;
adev_output.close();
trace.endBlock();
}
if ( vm[ "export" ].as<string>() != "None" )
{
trace.beginBlock( "Exporting cell geometry." );
std::ostringstream export_sstr;
export_sstr << fname << "-" << nameEstimator << "-cells-"
<< estimator.h() << ".txt";
std::ofstream export_output( export_sstr.str().c_str() );
export_output << "# ImaGene viewer (viewSetOfSurfels) file format for displaying cells." << std::endl;
bool adev = vm[ "export" ].as<string>() == "AngleDeviation";
unsigned int i = 0;
range = CountedPtr<VisitorRange>( new VisitorRange( new Visitor( surface, *(surface.begin()) )) );
for ( VisitorConstIterator it = range->begin(), itE = range->end(); it != itE; ++it, ++i )
{
Quantity n_est = n_estimations[ i ];
//.........这里部分代码省略.........