DGtal  1.1.0
examplePointFunctorHolder.cpp
Go to the documentation of this file.
1 
31 // Inclusions
33 
35 #include <algorithm>
36 
37 #include "DGtal/base/Common.h"
38 #include "DGtal/helpers/StdDefs.h"
39 
40 #include "DGtal/kernel/PointFunctorHolder.h"
41 #include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
42 
43 #include "DGtal/io/boards/Board2D.h"
44 #include "DGtal/io/colormaps/HueShadeColorMap.h"
45 
46 #include <boost/algorithm/minmax_element.hpp>
48 
50 using namespace DGtal;
51 
52 int main()
53 {
55  auto mickey = functors::holdPointFunctor<Z2i::Point>(
56  [] ( Z2i::Point const& pt ) {
57  return
58  (pt - Z2i::Point(0, -5)).norm() > 3
59  && ( pt.norm() <= 20
60  || (pt - Z2i::Point(-18,21)).norm() <= 10
61  || (pt - Z2i::Point( 18,21)).norm() <= 10
62  );
63  });
65 
67  Z2i::Domain domain( Z2i::Point(-35,-25), Z2i::Point(35, 35) );
68 
69  using DTL2 = DistanceTransformation<Z2i::Space, decltype(mickey), Z2i::L2Metric>;
70 
71  DTL2 dt( domain, mickey, Z2i::l2Metric );
73 
74 
76  DTL2::Value maxDT = *boost::first_max_element( dt.constRange().begin(), dt.constRange().end() );
77  using HueTwice = HueShadeColorMap<DTL2::Value, 1>;
78 
79  Board2D aBoard;
80  aBoard << domain;
81  Display2DFactory::drawImage<HueTwice>(aBoard, dt, 0, maxDT);
82  aBoard.saveEPS("examplePointFunctorHolder.eps");
84 
85  return 0;
86 
87 }
DGtal::HyperRectDomain< Space >
DGtal::HueShadeColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition: HueShadeColorMap.h:91
DGtal::Z2i::l2Metric
static const L2Metric l2Metric
Definition: StdDefs.h:123
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::Z2i::Space
SpaceND< 2, Integer > Space
Definition: StdDefs.h:75
DGtal::PointVector::norm
double norm(const NormType type=L_2) const
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
DGtal::ExactPredicateLpSeparableMetric
Aim: implements separable l_p metrics with exact predicates.
Definition: ExactPredicateLpSeparableMetric.h:88
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
DGtal::DistanceTransformation
Aim: Implementation of the linear in time distance transformation for separable metrics.
Definition: DistanceTransformation.h:100
main
int main()
Definition: examplePointFunctorHolder.cpp:52
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38