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/topology/KhalimskySpaceND.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/helpers/Surfaces.h"
#include "DGtal/io/readers/PNMReader.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
#include "ConfigExamples.h"
using namespace std;
using namespace DGtal;
int main( int , char** )
{
std::string inputFilename = examplesPath + "samples/circleR10modif.pgm";
board << image.domain() << set2d;
board2 << image.domain() << set2d;
board3 << image.domain() << set2d;
bool space_ok = ks.
init( image.domain().lowerBound(), image.domain().upperBound(), true );
std::vector<Z2i::SCell> vectBdrySCell;
ks, SAdj, set2dPredicate, aCell );
board <<
CustomStyle( (*(vectBdrySCell.begin())).className(),
cmap_grad.addColor(
Color( 255, 0, 0 ) );
cmap_grad.addColor(
Color( 255, 255, 10 ) );
unsigned int d=0;
std::vector<Z2i::SCell>::iterator it;
for ( it=vectBdrySCell.begin() ; it != vectBdrySCell.end(); it++ ){
cmap_grad( d )))<< *it;
d++;
}
std::set<Z2i::SCell> bdry;
( bdry,
std::set<Z2i::SCell>::iterator itB;
for ( itB=bdry.begin() ; itB != bdry.end(); itB++ ){
cmap_grad( d )))<< *itB;
d++;
}
std::vector< std::vector<Z2i::SCell> > vectContoursBdrySCell;
ks, SAdj, set2dPredicate );
cmap_grad3.addColor(
Color( 255, 0, 0 ) );
cmap_grad3.addColor(
Color( 20, 200, 0 ) );
cmap_grad3.addColor(
Color( 200, 200, 200 ) );
cmap_grad3.addColor(
Color( 20, 200, 200 ) );
cmap_grad3.addColor(
Color( 200, 20, 200 ) );
d=0;
for(unsigned int i=0; i< vectContoursBdrySCell.size(); i++){
d++;
for(unsigned int j=0; j< vectContoursBdrySCell.at(i).size(); j++){
board3<<
CustomStyle(vectContoursBdrySCell.at(i).at(j).className() ,
cmap_grad3( d )))<<vectContoursBdrySCell.at(i).at(j) ;
}
}
board << aCell;
board.saveEPS( "ctopo-2.eps");
board.saveFIG( "ctopo-2.fig");
return (space_ok);
}