DGtal 1.4.0
Loading...
Searching...
No Matches
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;
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;
}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition Board2D.h:71
Structure representing an RGB triple with alpha component.
Definition Color.h:68
Aim: A class that models a neighborhood and that provides services to analyse the convexity properti...
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Definition Shortcuts.h:105
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition Board.cpp:804
NeighborhoodConvexityAnalyzer< KSpace, 1 > NCA1
DigitalConvexity< KSpace > DConv
Shortcuts< KSpace > SH2
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition Board2D.h:279
int main()
Definition testBits.cpp:56
HyperRectDomain< Space > Domain