DGtal  1.4.beta
geometry/volumes/fullConvexityCollapsiblePoints2D.cpp

Displays fully convex collapsible points in the given image. All these points can be safely flipped without changing the topology of the image.

See also
Applications of full digital convexity
#include <vector>
#include "DGtal/shapes/Shapes.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
#include "DGtal/geometry/volumes/DigitalConvexity.h"
#include "DGtal/geometry/volumes/NeighborhoodConvexityAnalyzer.h"
#include "DGtal/helpers/Shortcuts.h"
#include "ConfigExamples.h"
// Using standard 2D digital space.
using namespace std;
using namespace DGtal;
using namespace Z2i;
typedef Shortcuts<KSpace> SH2;
typedef NeighborhoodConvexityAnalyzer<KSpace,1> NCA1;
int main( int argc, char** argv )
{
double noise = argc > 1 ? atof( argv[ 1 ] ) : 0.1;
auto params = SH2::defaultParameters();
params( "noise", noise )( "thresholdMin", 128 );
auto g_image = SH2::makeGrayScaleImage( examplesPath + "samples/contourS.pgm" );
auto b_image = SH2::makeBinaryImage ( g_image, params );
Board2D board;
Domain image_domain = b_image->domain();
NCA1 nca1( image_domain.lowerBound(), image_domain.upperBound() );
for ( auto p : image_domain )
{
nca1.setCenter( p, (*b_image) );
bool simple = nca1.isFullyConvexCollapsible();
if ( (*b_image)( p ) )
board << CustomStyle( p.className(),
simple
? new CustomColors( Color( 0, 0, 0 ),
Color( 10, 255, 10 ) )
: new CustomColors( Color( 0, 0, 0 ),
Color( 255, 10, 10 ) ) );
else
board << CustomStyle( p.className(),
simple
? new CustomColors( Color( 0, 0, 0 ),
Color( 180, 255, 180 ) )
: new CustomColors( Color( 0, 0, 0 ),
Color( 255, 180, 180 ) ) );
board << p;
}
board.saveEPS( "contour-fcvx-collapsible.eps" );
return 0;
}
NeighborhoodConvexityAnalyzer< KSpace, 1 > NCA1
DigitalConvexity< KSpace > DConv
Shortcuts< KSpace > SH2
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)
HyperRectDomain< Space > Domain