DGtal  1.3.beta
fullConvexityCollapsiblePoints2D.cpp
Go to the documentation of this file.
1 
39 #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 }
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
main
int main(int argc, char **argv)
Definition: fullConvexityCollapsiblePoints2D.cpp:61
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
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