DGtal  1.2.0
Functions
exampleConstImageFunctorHolder.cpp File Reference

An example file for DGtal::functors::ConstImageFunctorHolder. More...

#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/boards/Board2D.h"
#include <cmath>
#include <DGtal/io/colormaps/HueShadeColorMap.h>
#include "DGtal/images/ConstImageFunctorHolder.h"
Include dependency graph for exampleConstImageFunctorHolder.cpp:

Go to the source code of this file.

Functions

int main ()
 [include] More...
 

Detailed Description

An example file for DGtal::functors::ConstImageFunctorHolder.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Roland Denis (denis.nosp@m.@mat.nosp@m.h.uni.nosp@m.v-ly.nosp@m.on1.f.nosp@m.r ) CNRS, Institut Camille Jordan (UMR 5208), Université Lyon 1, France
Date
2018/07/18

This file is part of the DGtal library.

Definition in file exampleConstImageFunctorHolder.cpp.

Function Documentation

◆ main()

int main ( void  )

[include]

[include]

[def]

[def]

[example1]

[example1]

[example2]

[example2]

[example3]

[example3]

Definition at line 44 of file exampleConstImageFunctorHolder.cpp.

45 {
46  using namespace DGtal::Z2i;
47 
48  DGtal::Board2D aBoard;
49 
51  using Value = double; // value type of the image
52  using HueShadeDouble = DGtal::HueShadeColorMap<Value>; // a simple HueShadeColorMap varying on 'double' values
54 
55  // Image from a unary lambda
57  const Domain domain1(Point(1,1), Point(16,16));
58 
60  domain1,
61  [] (Point const& pt) { return 25 * ( std::cos( (pt - Point(4,4)).norm() ) + 1 ); }
62  );
64 
65  aBoard.clear();
66  DGtal::Display2DFactory::drawImage<HueShadeDouble>(aBoard, image1, 0, 225);
67  aBoard.saveSVG("ConstImageFunctorHolder_example1.svg");
68 
69  // Image from a binary lambda
71  const Domain domain2(Point(-1,1), Point(18,18));
72 
74  domain2,
75  [] (Point const& pt, Domain const& d) { // we could also capture the domain
76  return 2 * std::min( ( pt - d.lowerBound() ).norm(), ( pt - d.upperBound() ).norm() );
77  }
78  );
80 
81  aBoard.clear();
82  DGtal::Display2DFactory::drawImage<HueShadeDouble>(aBoard, image2, 0, 225);
83  aBoard.saveSVG("ConstImageFunctorHolder_example2.svg");
84 
85  // Image that depends on other images
88  domain1,
89  [&image1, &image2] (Point const& pt) { return image1(pt) + image2(pt); }
90  );
92 
93  aBoard.clear();
94  DGtal::Display2DFactory::drawImage<HueShadeDouble>(aBoard, image3, 0, 225);
95  aBoard.saveSVG("ConstImageFunctorHolder_example3.svg");
96  return 0;
97 }
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
const Point & lowerBound() const
const Point & upperBound() const
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
Z2i this namespace gathers the standard of types for 2D imagery.
Space::Point Point
Definition: StdDefs.h:95
auto holdConstImageFunctor(TDomain const &aDomain, TFunctor &&aFunctor) -> ConstImageFunctorHolder< TDomain, TValue, decltype(holdFunctor(std::forward< TFunctor >(aFunctor)))>
ConstImageFunctorHolder construction helper with specification of the return type.

References LibBoard::Board::clear(), DGtal::functors::holdConstImageFunctor(), DGtal::HyperRectDomain< TSpace >::lowerBound(), LibBoard::Board::saveSVG(), and DGtal::HyperRectDomain< TSpace >::upperBound().