243{
244 if ( argc <= 2 )
245 {
246 trace.info() <<
"Usage: " << argv[ 0 ] <<
" <K> <input.vol> <m> <M>" << std::endl;
247 trace.info() <<
"\tAnalyze the shape with local full convexity" << std::endl;
248 trace.info() <<
"\t- 1 <= K <= 5: analysis at scale K" << std::endl;
249 trace.info() <<
"\t- K == 0: multiscale analysis (using scales 1-5)" << std::endl;
250 trace.info() <<
"\t- input.vol: choose your favorite shape" << std::endl;
251 trace.info() <<
"\t- m [==0], M [==255]: used to threshold input vol image" << std::endl;
252 return 1;
253 }
254 int N = atoi( argv[ 1 ] );
255 std::string fn= argv[ 2 ];
256 int m = argc > 3 ? atoi( argv[ 3 ] ) : 0;
257 int M = argc > 4 ? atoi( argv[ 4 ] ) : 255;
258
260
261
262 trace.info() <<
"Building set or importing vol ... ";
264 params( "thresholdMin", m );
265 params( "thresholdMax", M );
268 trace.info() <<
" [Done]" << std::endl;
269
270 params( "surfaceComponents" , "All" );
272
273
274
275 std::vector< Point > points;
276 std::map< SCell, int > surfel2idx;
277 std::map< Point, int > point2idx;
278 int idx = 0;
280 {
281
283 auto voxel =
K.sIncident( s, k,
K.sDirect( s, k ) );
284 Point p =
K.sCoords( voxel );
285 auto it = point2idx.find( p );
286 if ( it == point2idx.end() )
287 {
288 points.push_back( p );
289 surfel2idx[ s ] = idx;
290 point2idx [ p ] = idx++;
291 }
292 else
293 surfel2idx[ s ] = it->second;
294 }
295 trace.info() <<
"Shape has " << points.size() <<
" interior boundary points"
296 << std::endl;
297 if ( N != 0 )
298 {
299 std::vector< int > result;
300 trace.beginBlock (
"Single scale analysis" );
309 {
Color( 255, 0, 0, 255 ),
Color( 0, 255, 0, 255 ),
310 Color( 0, 0, 255, 255 ),
Color( 255, 255, 255, 255 ) };
313 for ( int i = 0; i < surfels.size(); i++ )
314 {
315 const auto j = surfel2idx[ surfels[ i ] ];
316 all_colors[ i ] = colors[ result[ j ] ];
317 }
320 int i = 0;
322 {
323 viewer << all_colors[ i ]
324 << s;
325 i++;
326 }
328 }
329 else
330 {
331 trace.beginBlock (
"Multiscale analysis" );
332 auto geometry =
335 Color colors_planar[ 6 ] =
336 {
Color( 0, 255, 255, 255),
337 Color( 50, 255, 255, 255),
Color( 100, 255, 255, 255),
338 Color( 150, 255, 255, 255),
Color( 200, 255, 255, 255 ),
339 Color( 255, 255, 255, 255 ) };
340 Color color_atypical( 255, 0, 0, 255 );
341 Color colors_cvx[ 5 ] =
342 {
Color( 0, 255, 0, 255 ),
Color( 50, 255, 50, 255 ),
343 Color( 100, 255, 100, 255 ),
Color( 150, 255, 150, 255 ),
344 Color( 200, 255, 200, 255 ) };
345 Color colors_ccv[ 5 ] =
346 {
Color( 0, 0, 255, 255 ),
Color( 50, 50, 255, 255 ),
347 Color( 100, 100, 255, 255 ),
Color( 150, 150, 255, 255 ),
348 Color( 200, 200, 255, 255 ) };
351 for ( int i = 0; i < surfels.size(); i++ ) {
352 const auto j = surfel2idx[ surfels[ i ] ];
353 int m0 = std::min( geometry[ j ].first, geometry[ j ].second );
354 int m1 = std::max( geometry[ j ].first, geometry[ j ].second );
355 if ( m1 == 0 ) all_colors[ i ] = color_atypical;
356 else if ( m0 == m1 ) all_colors[ i ] = colors_planar[ 5 ];
357 else if ( geometry[ j ].first > geometry[ j ].second )
358 all_colors[ i ] = colors_cvx[ 5 -
abs( m0 - m1 ) ];
359 else
360 all_colors[ i ] = colors_ccv[ 5 -
abs( m0 - m1 ) ];
361 }
364 int i = 0;
367 {
368 viewer << all_colors[ i ]
369 << s;
370 i++;
371 }
373 }
374 return 0;
375}
Structure representing an RGB triple with alpha component.
void show() override
Starts the event loop and display of elements.
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
std::vector< Color > Colors
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
std::vector< RealVector > RealVectors
static Parameters defaultParameters()
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)
CountedPtr< SH3::DigitalSurface > surface
KhalimskySpaceND< 3, Integer > KSpace
DGtal::uint32_t Dimension
static std::vector< int > run(const KSpace &aK, const std::vector< Point > &pts, ImagePtr bimage)
static std::vector< Geometry > multiscale_run(const KSpace &aK, const std::vector< Point > &pts, ImagePtr bimage)