Examples of breadth-first traversal on a digital surface You can use these commands:
#include <iostream>
#include <queue>
#include <QImageReader>
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/LightImplicitDigitalSurface.h"
#include "DGtal/io/viewers/Viewer3D.h"
void usage(
int,
char** argv )
{
std::cerr << "Usage: " << argv[ 0 ] << " <fileName.vol> <minT> <maxT>" << std::endl;
std::cerr << "\t - displays the boundary of the shape stored in vol file <fileName.vol>." << std::endl;
std::cerr << "\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT." << std::endl;
}
int main(
int argc,
char** argv )
{
if ( argc < 4 )
{
return 1;
}
std::string inputFilename = argv[ 1 ];
unsigned int minThreshold = atoi( argv[ 2 ] );
unsigned int maxThreshold = atoi( argv[ 3 ] );
minThreshold, maxThreshold);
trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
bool space_ok = ks.init( image.domain().lowerBound(),
image.domain().upperBound(), true );
if (!space_ok)
{
trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
return 2;
}
MySurfelAdjacency surfAdj( true );
MyDigitalSurfaceContainer* ptrSurfContainer =
MyDigitalSurface digSurf( ptrSurfContainer );
trace.
beginBlock(
"Extracting boundary by tracking from an initial bel." );
typedef MyBreadthFirstVisitor::Node MyNode;
typedef MyBreadthFirstVisitor::Size MySize;
MyBreadthFirstVisitor visitor( digSurf, bel );
unsigned long nbSurfels = 0;
MyNode node;
while ( ! visitor.finished() )
{
node = visitor.current();
++nbSurfels;
visitor.expand();
}
MySize maxDist = node.second;
QApplication application(argc,argv);
MyBreadthFirstVisitor visitor2( digSurf, bel );
<< ks.unsigns( bel );
visitor2.expand();
while ( ! visitor2.finished() )
{
node = visitor2.current();
Color c = hueShade( node.second );
<< ks.unsigns( node.first );
visitor2.expand();
}
viewer << Viewer3D<>::updateDisplay;
trace.
info() <<
"nb surfels = " << nbSurfels << std::endl;
return application.exec();
}