33#include "DGtal/base/Common.h"
34#include "DGtal/helpers/StdDefs.h"
35#include "DGtal/geometry/volumes/estimation/VoronoiCovarianceMeasure.h"
36#include "DGtal/geometry/tools/SpatialCubicalSubdivision.h"
50 unsigned int nbok = 0;
53 using namespace DGtal;
55 trace.
beginBlock (
"testVoronoiCovarianceMeasure" );
58 typedef VCM::MatrixNN Matrix;
63 std::vector<Point> pts;
64 pts.push_back(
Point( 10,10,10 ) );
65 pts.push_back(
Point( 10,10,11 ) );
66 pts.push_back(
Point( 10,11,11 ) );
67 pts.push_back(
Point( 11,11,12 ) );
68 pts.push_back(
Point( 11,12,12 ) );
69 pts.push_back(
Point( 11,12,12 ) );
70 pts.push_back(
Point( 12,12,12 ) );
71 pts.push_back(
Point( 20,20,15 ) );
72 pts.push_back(
Point( 30,10,25 ) );
73 pts.push_back(
Point( 25,25,20 ) );
75 VCM vcm( 5.0, 4.0, l2,
true );
76 vcm.init( pts.begin(), pts.end() );
78 double sum_dist = 0.0;
79 std::map<Point,int> sizeCells;
82 sum_dist += l2( *it, vcm.voronoiMap()( *it ) );
83 sizeCells[ vcm.voronoiMap()( *it ) ] += 1;
85 double avg_dist = ( sum_dist / d.
size() );
86 trace.
info() <<
"Average distance is " << avg_dist << std::endl;
87 nbok += ( 9 <= avg_dist && avg_dist <= 11 ) ? 1 : 0;
89 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
90 <<
"9 <= " << avg_dist <<
" <= 11 " << std::endl;
91 for ( std::map<Point,int>::const_iterator it = sizeCells.begin(), itE = sizeCells.end();
93 trace.
info() <<
"Nb(" << it->first <<
")=" << it->second << std::endl;
94 nbok += sizeCells.size() == 9 ? 1 : 0;
96 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
97 <<
"sizeCells.size() == 10" << std::endl;
100 Matrix vcm_r = vcm.measure( chi_r,
Point( 10,10,10 ) );
101 trace.
info() <<
"- vcm_r.row(0) = " << vcm_r.row( 0 ) << std::endl;
102 trace.
info() <<
"- vcm_r.row(1) = " << vcm_r.row( 1 ) << std::endl;
103 trace.
info() <<
"- vcm_r.row(2) = " << vcm_r.row( 2 ) << std::endl;
115 using namespace DGtal;
116 trace.
beginBlock (
"Testing VoronoiCovarianceMeasure ..." );
118 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: implements separable l_p metrics with exact predicates.
Iterator for HyperRectDomain.
const ConstIterator & begin() const
const ConstIterator & end() const
void beginBlock(const std::string &keyword="")
Aim: This class precomputes the Voronoi Covariance Measure of a set of points. It can compute the cov...
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
HyperRectDomain< Space > Domain
bool testVoronoiCovarianceMeasure()