DGtal  1.0.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"
46 
48 using namespace DGtal;
49 
50 int main()
51 {
53  auto mickey = functors::holdPointFunctor<Z2i::Point>(
54  [] ( Z2i::Point const& pt ) {
55  return
56  (pt - Z2i::Point(0, -5)).norm() > 3
57  && ( pt.norm() <= 20
58  || (pt - Z2i::Point(-18,21)).norm() <= 10
59  || (pt - Z2i::Point( 18,21)).norm() <= 10
60  );
61  });
63 
65  Z2i::Domain domain( Z2i::Point(-35,-25), Z2i::Point(35, 35) );
66 
67  using DTL2 = DistanceTransformation<Z2i::Space, decltype(mickey), Z2i::L2Metric>;
68 
69  DTL2 dt( domain, mickey, Z2i::l2Metric );
71 
72 
74  DTL2::Value maxDT = *std::max_element( dt.constRange().begin(), dt.constRange().end() );
75  using HueTwice = HueShadeColorMap<DTL2::Value, 1>;
76 
77  Board2D aBoard;
78  aBoard << domain;
79  Display2DFactory::drawImage<HueTwice>(aBoard, dt, 0, maxDT);
80  aBoard.saveEPS("examplePointFunctorHolder.eps");
82 
83  return 0;
84 
85 }
Aim: Implementation of the linear in time distance transformation for separable metrics.
SpaceND< 2, Integer > Space
Definition: StdDefs.h:75
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Domain domain
Aim: implements separable l_p metrics with exact predicates.
double norm(const NormType type=L_2) const
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Space::Point Point
Definition: StdDefs.h:95
DGtal is the top-level namespace which contains all DGtal functions and types.
static const L2Metric l2Metric
Definition: StdDefs.h:123
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70