DGtal 1.3.0
Loading...
Searching...
No Matches
examplePointFunctorHolder.cpp
Go to the documentation of this file.
1
32// 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
50using namespace DGtal;
51
52int 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}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: Implementation of the linear in time distance transformation for separable metrics.
Aim: implements separable l_p metrics with exact predicates.
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
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
SpaceND< 2, Integer > Space
Definition: StdDefs.h:75
static const L2Metric l2Metric
Definition: StdDefs.h:123
DGtal is the top-level namespace which contains all DGtal functions and types.
Domain domain