242{
243 if ( argc <= 2 )
244 {
245 trace.
info() <<
"Usage: " << argv[ 0 ] <<
" <K> <input.vol> <m> <M>" << std::endl;
246 trace.
info() <<
"\tAnalyze the shape with local full convexity" << std::endl;
247 trace.
info() <<
"\t- 1 <= K <= 5: analysis at scale K" << std::endl;
248 trace.
info() <<
"\t- K == 0: multiscale analysis (using scales 1-5)" << std::endl;
249 trace.
info() <<
"\t- input.vol: choose your favorite shape" << std::endl;
250 trace.
info() <<
"\t- m [==0], M [==255]: used to threshold input vol image" << std::endl;
251 return 1;
252 }
253 int N = atoi( argv[ 1 ] );
254 std::string fn= argv[ 2 ];
255 int m = argc > 3 ? atoi( argv[ 3 ] ) : 0;
256 int M = argc > 4 ? atoi( argv[ 4 ] ) : 255;
257
258 QApplication application(argc,argv);
259
261
262
263 trace.
info() <<
"Building set or importing vol ... ";
265 params( "thresholdMin", m );
266 params( "thresholdMax", M );
270
271 params( "surfaceComponents" , "All" );
273
274
275
276 std::vector< Point > points;
277 std::map< SCell, int > surfel2idx;
278 std::map< Point, int > point2idx;
279 int idx = 0;
281 {
282
286 auto it = point2idx.find( p );
287 if ( it == point2idx.end() )
288 {
289 points.push_back( p );
290 surfel2idx[ s ] = idx;
291 point2idx [ p ] = idx++;
292 }
293 else
294 surfel2idx[ s ] = it->second;
295 }
296 trace.
info() <<
"Shape has " << points.size() <<
" interior boundary points"
297 << std::endl;
298 if ( N != 0 )
299 {
300 std::vector< int > result;
302 if ( N == 1 ) result = Analyzer< KSpace, 1 >::run(
K, points, bimage );
303 if ( N == 2 ) result = Analyzer< KSpace, 2 >::run(
K, points, bimage );
304 if ( N == 3 ) result = Analyzer< KSpace, 3 >::run(
K, points, bimage );
305 if ( N == 4 ) result = Analyzer< KSpace, 4 >::run(
K, points, bimage );
306 if ( N == 5 ) result = Analyzer< KSpace, 5 >::run(
K, points, bimage );
310 {
Color( 255, 0, 0, 255 ),
Color( 0, 255, 0, 255 ),
311 Color( 0, 0, 255, 255 ),
Color( 255, 255, 255, 255 ) };
314 for ( int i = 0; i < surfels.size(); i++ )
315 {
316 const auto j = surfel2idx[ surfels[ i ] ];
317 all_colors[ i ] = colors[ result[ j ] ];
318 }
321 viewer.setWindowTitle("fullConvexityAnalysis3D");
323 int i = 0;
326 {
328 << s;
329 i++;
330 }
331 viewer<< Viewer3D<>::updateDisplay;
332 application.exec();
333 }
334 else
335 {
337 auto geometry =
338 MultiScaleAnalyzer< KSpace, 5 >::multiscale_run(
K, points, bimage );
340 Color colors_planar[ 6 ] =
341 {
Color( 0, 255, 255, 255),
342 Color( 50, 255, 255, 255),
Color( 100, 255, 255, 255),
343 Color( 150, 255, 255, 255),
Color( 200, 255, 255, 255 ),
344 Color( 255, 255, 255, 255 ) };
345 Color color_atypical( 255, 0, 0, 255 );
346 Color colors_cvx[ 5 ] =
347 {
Color( 0, 255, 0, 255 ),
Color( 50, 255, 50, 255 ),
348 Color( 100, 255, 100, 255 ),
Color( 150, 255, 150, 255 ),
349 Color( 200, 255, 200, 255 ) };
350 Color colors_ccv[ 5 ] =
351 {
Color( 0, 0, 255, 255 ),
Color( 50, 50, 255, 255 ),
352 Color( 100, 100, 255, 255 ),
Color( 150, 150, 255, 255 ),
353 Color( 200, 200, 255, 255 ) };
356 for ( int i = 0; i < surfels.size(); i++ ) {
357 const auto j = surfel2idx[ surfels[ i ] ];
358 int m0 = std::min( geometry[ j ].first, geometry[ j ].second );
359 int m1 = std::max( geometry[ j ].first, geometry[ j ].second );
360 if ( m1 == 0 ) all_colors[ i ] = color_atypical;
361 else if ( m0 == m1 ) all_colors[ i ] = colors_planar[ 5 ];
362 else if ( geometry[ j ].first > geometry[ j ].second )
363 all_colors[ i ] = colors_cvx[ 5 -
abs( m0 - m1 ) ];
364 else
365 all_colors[ i ] = colors_ccv[ 5 -
abs( m0 - m1 ) ];
366 }
369 int i = 0;
371 viewer.setWindowTitle("fullConvexityAnalysis3D");
375 {
377 << s;
378 i++;
379 }
380 viewer<< Viewer3D<>::updateDisplay;
381 application.exec();
382 }
383 return 0;
384}
Structure representing an RGB triple with alpha component.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Dimension sOrthDir(const SCell &s) const
Given a signed surfel [s], returns its orthogonal direction (ie, the coordinate where the surfel is c...
Point sCoords(const SCell &c) const
Return its digital coordinates.
bool sDirect(const SCell &p, Dimension k) const
Return 'true' if the direct orientation of [p] along [k] is in the positive coordinate direction.
SCell sIncident(const SCell &c, Dimension k, bool up) const
Return the forward or backward signed cell incident to [c] along axis [k], depending on [up].
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)
void beginBlock(const std::string &keyword="")
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
CountedPtr< SH3::DigitalSurface > surface
DGtal::uint32_t Dimension
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
std::string className() const
Return the style name used for drawing this object.