A simple example illustrating the extraction of the sequence of surfels boudary. This program outputs this image.
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include <QtGui/qapplication.h>
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/helpers/Surfaces.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "ConfigExamples.h"
using namespace std;
using namespace DGtal;
int main( int argc, char** argv )
{
QApplication application(argc,argv);
std::string inputFilename = examplesPath + "samples/cat10.vol";
viewer.show();
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;
}
std::vector<Z3i::SCell> vectBdrySCell;
std::vector<Z3i::SCell> vectBdrySCell2;
std::set<Z3i::SCell> vectBdrySCellALL;
ks,SAdj, set3dPredicate, aCell );
ks, *(ks.
sDirs( aCell )), SAdj,
set3dPredicate, aCell );
ks, *(++(ks.
sDirs( aCell ))), SAdj,
set3dPredicate, aCell );
viewer <<
SetMode3D((*(vectBdrySCellALL.begin())).className(),
"Transparent");
for( std::set<Z3i::SCell>::iterator it=vectBdrySCellALL.begin();
it!= vectBdrySCellALL.end(); it++){
viewer<< *it;
}
cmap_grad.addColor(
Color( 255, 0, 0 ) );
cmap_grad.addColor(
Color( 255, 255, 10 ) );
viewer << Viewer3D::shiftSurfelVisu;
viewer <<
SetMode3D((*(vectBdrySCell2.begin())).className(),
"");
viewer.setFillColor(
Color(180, 200, 25, 255));
int d=0;
for( std::vector<Z3i::SCell>::iterator it=vectBdrySCell2.begin();
it!= vectBdrySCell2.end(); it++){
viewer<< *it;
d++;
}
cmap_grad2.addColor(
Color( 255, 0, 0 ) );
cmap_grad2.addColor(
Color( 255, 255, 10 ) );
d=0;
for( std::vector<Z3i::SCell>::iterator it=vectBdrySCell.begin();
it!= vectBdrySCell.end(); it++){
Color col= cmap_grad2(d);
viewer<< *it;
d++;
}
viewer << Viewer3D::shiftSurfelVisu;
viewer.setFillColor(
Color(18, 200, 25, 255));
viewer << aCell ;
viewer << Viewer3D::updateDisplay;
return application.exec();
}