DGtal  1.5.beta
fullConvexityCollapsiblePoints2D.cpp
Go to the documentation of this file.
1 
40 #include <vector>
41 #include "DGtal/shapes/Shapes.h"
42 #include "DGtal/io/boards/Board2D.h"
43 #include "DGtal/io/Color.h"
44 #include "DGtal/geometry/volumes/DigitalConvexity.h"
45 #include "DGtal/geometry/volumes/NeighborhoodConvexityAnalyzer.h"
46 #include "DGtal/helpers/Shortcuts.h"
47 #include "ConfigExamples.h"
48 
49 // Using standard 2D digital space.
51 
52 using namespace std;
53 using namespace DGtal;
54 using namespace Z2i;
55 
59 
61 int main( int argc, char** argv )
62 {
63  double noise = argc > 1 ? atof( argv[ 1 ] ) : 0.1;
64  auto params = SH2::defaultParameters();
65  params( "noise", noise )( "thresholdMin", 128 );
66  auto g_image = SH2::makeGrayScaleImage( examplesPath + "samples/contourS.pgm" );
67  auto b_image = SH2::makeBinaryImage ( g_image, params );
68  Board2D board;
69  Domain image_domain = b_image->domain();
70  NCA1 nca1( image_domain.lowerBound(), image_domain.upperBound() );
71  for ( auto p : image_domain )
72  {
73  nca1.setCenter( p, (*b_image) );
74  bool simple = nca1.isFullyConvexCollapsible();
75  if ( (*b_image)( p ) )
76  board << CustomStyle( p.className(),
77  simple
78  ? new CustomColors( Color( 0, 0, 0 ),
79  Color( 10, 255, 10 ) )
80  : new CustomColors( Color( 0, 0, 0 ),
81  Color( 255, 10, 10 ) ) );
82  else
83  board << CustomStyle( p.className(),
84  simple
85  ? new CustomColors( Color( 0, 0, 0 ),
86  Color( 180, 255, 180 ) )
87  : new CustomColors( Color( 0, 0, 0 ),
88  Color( 255, 180, 180 ) ) );
89  board << p;
90  }
91  board.saveEPS( "contour-fcvx-collapsible.eps" );
92  return 0;
93 }
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
const Point & lowerBound() const
const Point & upperBound() const
Aim: A class that models a neighborhood and that provides services to analyse the convexity properti...
void setCenter(Point c, const PointPredicate &X)
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
int main(int argc, char **argv)
Shortcuts< KSpace > SH2
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279