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;
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;
}
DGtal::HyperRectDomain< Space >
DGtal::NeighborhoodConvexityAnalyzer::isFullyConvexCollapsible
bool isFullyConvexCollapsible()
Definition: NeighborhoodConvexityAnalyzer.h:243
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
DGtal::Shortcuts
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Definition: Shortcuts.h:104
DGtal::CustomStyle
Definition: Board2D.h:217
DConv
DigitalConvexity< KSpace > DConv
Definition: fullConvexityCollapsiblePoints2D.cpp:56
SH2
Shortcuts< KSpace > SH2
Definition: fullConvexityCollapsiblePoints2D.cpp:57
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::NeighborhoodConvexityAnalyzer::setCenter
void setCenter(Point c, const PointPredicate &X)
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
DGtal::NeighborhoodConvexityAnalyzer
Aim: A class that models a neighborhood and that provides services to analyse the convexity properti...
Definition: NeighborhoodConvexityAnalyzer.h:94
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
DGtal::DigitalConvexity< KSpace >
DGtal::HyperRectDomain::lowerBound
const Point & lowerBound() const
NCA1
NeighborhoodConvexityAnalyzer< KSpace, 1 > NCA1
Definition: fullConvexityCollapsiblePoints2D.cpp:58