45{
46 unsigned int nb = 0, nbok = 0;
47
50
51 trace.
beginBlock (
"Load vol file -> build digital surface -> estimate mean curvature -> save OBJ." );
52 {
55 params( "colormap", "Tics" );
61
62
65 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
67 "al-H-II.obj" );
69 ++nb; nbok += ok ? 1 : 0;
70 }
72
73 trace.
beginBlock (
"Load vol file -> build digital surface -> estimate Gauss curvature -> save OBJ." );
74 {
76 params( "colormap", "Tics" );
84 std::transform( curv.cbegin(), curv.cend(), colors.begin(), cmap );
86 "al-G-II.obj" );
87 ++nb; nbok += ok ? 1 : 0;
88 }
90
91 trace.
beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth geometry." );
92 {
95 params( "polynomial", "3*x^2+2*y^2+z^2-90" )( "gridstep", 0.25 );
109 trace.
info() <<
" min(H)=" << stat_mean.min()
110 << " avg(H)=" << stat_mean.mean()
111 << " max(H)=" << stat_mean.max() << std::endl;
112 trace.
info() <<
" min(G)=" << stat_gauss.min()
113 << " avg(G)=" << stat_gauss.mean()
114 << " max(G)=" << stat_gauss.max() << std::endl;
115 ++nb; nbok += positions.size() == surfels.size() ? 1 : 0;
116 ++nb; nbok += normals.size() == surfels.size() ? 1 : 0;
117 ++nb; nbok += mean_curvs.size() == surfels.size() ? 1 : 0;
118 ++nb; nbok += gauss_curvs.size() == surfels.size() ? 1 : 0;
119 ++nb; nbok += stat_mean.min() > 0.08 ? 1 : 0;
120 ++nb; nbok += stat_gauss.min() > 0.0064 ? 1 : 0;
121 }
123
124 trace.
beginBlock (
"Build polynomial shape -> digitize -> get pointels -> save projected quadrangulated surface." );
125 {
128 const double h = 0.25;
129 params( "polynomial", "goursat" )( "gridstep", h );
139 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
140 [&] (
const SH3::Cell& c) { return h * embedder( c ); } );
143 [&] (
const SH3::Cell& c){
return ppos[ c2i[ c ] ];},
145 "goursat-quad-proj.obj" );
147 ++nb; nbok += ok ? 1 : 0;
148 }
150
151 trace.
beginBlock (
"Build polynomial shape -> digitize -> extract mean curvature -> save as OBJ with colors." );
152 {
155 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" );
165 std::transform( mean_curv.cbegin(), mean_curv.cend(), colors.begin(), cmap );
167 "goursat-H.obj" );
169 ++nb; nbok += ok ? 1 : 0;
170 }
172
173 trace.
beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth and estimated mean curvature -> display errors in OBJ with colors." );
174 {
177 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" )
178 ( "R-radius", 5.0 );
189 std::transform( t_curv.cbegin(), t_curv.cend(), colors.begin(), cmap );
191 std::transform( ii_curv.cbegin(), ii_curv.cend(), colors.begin(), cmap );
196 std::transform( errors.cbegin(), errors.cend(), colors.begin(), cmap_errors );
201 << std::endl;
203 ++nb; nbok += ( ok_t && ok_ii && ok_err ) ? 1 : 0;
204 }
206
207 trace.
beginBlock (
"Build polynomial shape -> digitize -> build digital surface -> save primal surface with VCM normals as obj." );
208 {
211 params( "polynomial", "goursat" )( "gridstep", 0.25 )
212 ( "surfaceTraversal", "Default" );
221 "goursat-primal-vcm.obj" );
223 ++nb; nbok += ok ? 1 : 0;
224 }
226
227 trace.
beginBlock (
"Build polynomial shape -> digitize implicitly -> estimate II normals and curvature." );
228 {
231 params( "polynomial", "goursat" )( "gridstep", .25 );
236 auto surfels =
SH3::getSurfelRange ( surface, params(
"surfaceTraversal",
"DepthFirst" ) );
237 auto def_surfels =
SH3::getSurfelRange ( surface, params(
"surfaceTraversal",
"Default" ) );
249 for (
SH3::Idx i = 0; i < colors.size(); i++ )
250 colors[ i ] = cmap( ii_mean_curv[ match[ i ] ] );
253 ++nb; nbok += ( ok_H && ii_mean_curv.size() == ii_mean_curv2.size() ) ? 1 : 0;
254 }
256
257 trace.
beginBlock (
"Build polynomial shape -> save several projected quadrangulated surface and digitized boundaries." );
258 {
260 std::vector<double> gridsteps {0.5, 0.25, 0.125};
261 for ( auto h : gridsteps ) {
262 params( "polynomial", "goursat" )( "gridstep", h );
272 std::transform( pointels.cbegin(), pointels.cend(), pos.begin(),
273 [&] (
const SH3::Cell& c) { return h * embedder( c ); } );
275 auto fname = std::string( "goursat-quad-" ) + std::to_string( h ) + std::string( ".obj" );
277 [&] (
const SH3::Cell& c){
return pos[ c2i[ c ] ];},
279 fname );
280 auto proj_fname = std::string( "goursat-quad-proj-" ) + std::to_string( h ) + std::string( ".obj" );
282 [&] (
const SH3::Cell& c){
return ppos[ c2i[ c ] ];},
284 proj_fname );
285 ++nb; nbok += ok ? 1 : 0;
286 ++nb; nbok += proj_ok ? 1 : 0;
287 }
288 }
290
291 trace.
beginBlock (
"Build polynomial shape -> digitize -> digital surface -> save primal surface and VCM normal field as obj." );
292 {
295 params( "polynomial", "goursat" )( "gridstep", 0.5 )
296 ( "surfaceTraversal", "Default" );
306 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
307 [&] (
const SH3::SCell& c) { return embedder( c ); } );
309 "goursat-primal-vcm.obj" );
311 "goursat-primal-vcm-normals.obj",
314 ++nb, nbok += ok ? 1 : 0;
315 ++nb, nbok += ok2 ? 1 : 0;
316 }
318
319 trace.
beginBlock (
"Build polynomial shape -> digitize -> extract ground-truth curvatures -> display in OBJ." );
320 {
323 params( "polynomial", "goursat" )( "gridstep", 0.25 )( "colormap", "Tics" );
336 std::transform( surfels.cbegin(), surfels.cend(), positions.begin(),
337 [&] (
const SH3::SCell& c) { return embedder( c ); } );
339 "goursat-primal.obj" );
340
343 std::transform( k1.cbegin(), k1.cend(), colors.begin(), cmap );
346 "goursat-primal-d1.obj", SH3::Color::Black );
347 std::transform( k2.cbegin(), k2.cend(), colors.begin(), cmap );
350 "goursat-primal-d2.obj", SH3::Color::Black );
352 }
354
355
356#if defined(WITH_EIGEN)
357
358 trace.
beginBlock (
"Load vol file -> build main digital surface -> II normals -> AT regularization -> save OBJ with colored normals." );
359 {
371 surface, surfels,
372 ii_normals, params );
373
375 for ( size_t i = 0; i < surfels.size(); i++ )
376 colors[ i ] =
SH3::Color( (
unsigned char) 255.0*fabs( at_normals[ i ][ 0 ] ),
377 (unsigned char) 255.0*fabs( at_normals[ i ][ 1 ] ),
378 (unsigned char) 255.0*fabs( at_normals[ i ][ 2 ] ) );
380 bool ok2 =
SH3::saveOBJ( surface, at_normals, colors,
"al-colored-at-normals.obj" );
381
384 for ( size_t i = 0; i < linels.size(); i++ )
385 {
386 if ( features[ i ] < 0.5 )
387 {
392 f0.push_back( uembedder( p0 ) );
393 f1.push_back( uembedder( p1 ) - uembedder( p0 ) );
394 }
395 }
397 "al-features.obj",
400 ++nb; nbok += ok1 ? 1 : 0;
401 ++nb; nbok += ok2 ? 1 : 0;
402 ++nb; nbok += ok3 ? 1 : 0;
403 }
405
406#endif
407
408 trace.
info() << nbok <<
"/" << nb <<
" passed tests." << std::endl;
409 return 0;
410}
Structure representing an RGB triple with alpha component.
Cell uIncident(const Cell &c, Dimension k, bool up) const
Return the forward or backward unsigned cell incident to [c] along axis [k], depending on [up].
DirIterator uDirs(const Cell &p) const
Given an unsigned cell [p], returns an iterator to iterate over each coordinate the cell spans.
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static Scalars getIIGaussianCurvatures(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Scalar getScalarsNormL1(const Scalars &v1, const Scalars &v2)
static Scalars getMeanCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static RealPoints getPositions(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static RealVectors getIINormalVectors(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Scalars getScalarsAbsoluteDifference(const Scalars &v1, const Scalars &v2)
static RealVectors getNormalVectors(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static RealVectors getFirstPrincipalDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static RealVectors getSecondPrincipalDirections(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static Scalars getIIMeanCurvatures(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Parameters defaultParameters()
static Scalars getGaussianCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static Scalar getScalarsNormL2(const Scalars &v1, const Scalars &v2)
static Scalars getFirstPrincipalCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static Scalar getScalarsNormLoo(const Scalars &v1, const Scalars &v2)
static ScalarStatistic getStatistic(const Scalars &v)
static VectorFieldInput getATVectorFieldApproximation(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const VectorFieldInput &input, const Parameters ¶ms=parametersATApproximation()|parametersGeometryEstimation())
static Scalars getSecondPrincipalCurvatures(CountedPtr< ImplicitShape3D > shape, const KSpace &K, const SurfelRange &surfels, const Parameters ¶ms=parametersShapeGeometry())
static RealVectors getVCMNormalVectors(CountedPtr< TAnyDigitalSurface > surface, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation())
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
static CellRange getCellRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Dimension k)
std::map< Cell, IdxVertex > Cell2Index
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
std::vector< Color > Colors
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static CanonicSCellEmbedder< KSpace > getSCellEmbedder(const KSpace &K)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static IdxRange getRangeMatch(const std::vector< TValue > &s1, const std::vector< TValue > &s2, bool perfect=false)
std::vector< RealPoint > RealPoints
std::vector< RealVector > RealVectors
std::vector< Scalar > Scalars
static bool saveVectorFieldOBJ(const RealPoints &positions, const RealVectors &vf, double thickness, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static Parameters defaultParameters()
static ColorMap getColorMap(Scalar min, Scalar max, const Parameters ¶ms=parametersUtilities())
static std::vector< TValue > getMatchedRange(const std::vector< TValue > &range, const IdxRange &match)
LightDigitalSurface::SCell SCell
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
LightDigitalSurface::Cell Cell
void beginBlock(const std::string &keyword="")
DGtal::uint32_t Dimension
ShortcutsGeometry< Z3i::KSpace > SHG3