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;
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;
258 QApplication application(argc,argv);
260 auto params = SH3::defaultParameters();
263 trace.
info() <<
"Building set or importing vol ... ";
265 params(
"thresholdMin", m );
266 params(
"thresholdMax", M );
267 auto bimage = SH3::makeBinaryImage( fn, params );
268 K = SH3::getKSpace( bimage );
271 params(
"surfaceComponents" ,
"All" );
272 auto surface = SH3::makeDigitalSurface( bimage,
K, params );
276 std::vector< Point > points;
277 std::map< SCell, int > surfel2idx;
278 std::map< Point, int > point2idx;
286 auto it = point2idx.find( p );
287 if ( it == point2idx.end() )
289 points.push_back( p );
290 surfel2idx[ s ] = idx;
291 point2idx [ p ] = idx++;
294 surfel2idx[ s ] = it->second;
296 trace.
info() <<
"Shape has " << points.size() <<
" interior boundary points"
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 ) };
312 auto surfels = SH3::getSurfelRange(
surface, params );
314 for (
int i = 0; i < surfels.size(); i++ )
316 const auto j = surfel2idx[ surfels[ i ] ];
317 all_colors[ i ] = colors[ result[ j ] ];
321 viewer.setWindowTitle(
"fullConvexityAnalysis3D");
331 viewer<< Viewer3D<>::updateDisplay;
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 ) };
354 auto surfels = SH3::getSurfelRange(
surface, params );
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 ) ];
365 all_colors[ i ] = colors_ccv[ 5 -
abs( m0 - m1 ) ];
371 viewer.setWindowTitle(
"fullConvexityAnalysis3D");
380 viewer<< Viewer3D<>::updateDisplay;
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].
std::vector< Color > Colors
std::vector< RealVector > RealVectors
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.