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;
Iterator for HyperRectDomain.
const ConstIterator & begin() const
const ConstIterator & end() const