DGtal 1.3.0
Loading...
Searching...
No Matches
imageSetDT.cpp
Go to the documentation of this file.
1
31#include <iostream>
32#include <fstream>
33#include <algorithm>
34#include <boost/algorithm/minmax_element.hpp>
36
38#include "DGtal/base/Common.h"
39#include "DGtal/helpers/StdDefs.h"
40
41#include "DGtal/base/BasicFunctors.h"
42#include "DGtal/kernel/BasicPointPredicates.h"
43#include "DGtal/kernel/sets/DigitalSetInserter.h"
44
45#include "DGtal/images/ImageContainerBySTLVector.h"
46#include "DGtal/images/ImageHelper.h"
47#include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
48#include "DGtal/images/IntervalForegroundPredicate.h"
49
50#include "DGtal/io/boards/Board2D.h"
51#include "DGtal/io/readers/PGMReader.h"
52#include "DGtal/io/colormaps/HueShadeColorMap.h"
53#include "DGtal/io/colormaps/GrayscaleColorMap.h"
54
55#include "ConfigExamples.h"
57
58
60using namespace DGtal;
61
62int main()
63{
68
69
71 std::string filename = examplesPath + "samples/contourS.pgm";
73 DGtal::trace.info() << "Imported image: "<<image<<std::endl;
75
76
78 DGtal::Board2D aBoard;
79 aBoard << image.domain();
80 aBoard.saveSVG("imageDomainTuto.svg");
81 aBoard.clear();
82 Display2DFactory::drawImage<Gray>(aBoard, image, (unsigned char)0, (unsigned char)255);
83 aBoard.saveEPS("imageDomainTuto2.eps");
85
86
87 Z2i::DigitalSet mySet(image.domain());
89 setFromImage(image, inserter, 1, 135);
90 aBoard.clear();
91 aBoard << mySet.domain()
92 << mySet;
93 aBoard.saveEPS("imageDomainTuto2bis.eps");
94
95
98 Binarizer b(image,1, 135);
100 DTL2 dt(&image.domain(),&b, &Z2i::l2Metric );
102
103
105 DTL2::Value maxDT = (*boost::first_max_element(dt.constRange().begin(),
106 dt.constRange().end(), std::less<DTL2::Value>() ));
108
109 aBoard.clear();
110 Display2DFactory::drawImage<HueTwice>(aBoard, dt, (DTL2::Value)0,
111 (DTL2::Value)maxDT);
112 aBoard.saveEPS("imageDomainTuto3.eps");
114
115 return 0;
116
117}
118
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: this output iterator class is designed to allow algorithms to insert points in the digital set....
Aim: Implementation of the linear in time distance transformation for separable metrics.
Aim: This class template may be used to (linearly) convert scalar values in a given range into gray l...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
std::ostream & info()
Aim: Define a simple Foreground predicate thresholding image values between two constant values (the ...
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
int main()
Definition: imageSetDT.cpp:62
static const L2Metric l2Metric
Definition: StdDefs.h:123
DGtal is the top-level namespace which contains all DGtal functions and types.
void setFromImage(const I &aImg, const O &ito, const typename I::Value &aThreshold=0)
Trace trace
Definition: Common.h:154
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)