DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
freemanChainFromImage.cpp
Go to the documentation of this file.
1
16
29
37
38
40
#include "DGtal/base/Common.h"
41
#include "DGtal/helpers/StdDefs.h"
42
#include "ConfigExamples.h"
44
46
#include "DGtal/io/readers/PGMReader.h"
47
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
49
51
#include "DGtal/topology/helpers/Surfaces.h"
52
#include "DGtal/geometry/curves/FreemanChain.h"
54
56
#include "DGtal/io/boards/Board2D.h"
57
#include "DGtal/io/colormaps/GradientColorMap.h"
58
#include "DGtal/io/Color.h"
59
60
using namespace
DGtal
;
62
63
int
main
()
64
{
65
67
typedef
DGtal::ImageContainerBySTLVector< DGtal::Z2i::Domain, unsigned char>
Image
;
68
std::string filename = examplesPath +
"samples/circleR10modif.pgm"
;
69
Image
image
=
DGtal::PGMReader<Image>::importPGM
(filename);
71
73
Z2i::KSpace
ks;
74
ks.
init
(
image
.
domain
().
lowerBound
(),
image
.
domain
().
upperBound
(),
true
);
76
78
Z2i::DigitalSet
set2d (
image
.
domain
());
79
SetFromImage<Z2i::DigitalSet>::append<Image>
(set2d,
image
, 1, 255);
81
82
84
Board2D
aBoard;
85
aBoard << set2d;
86
aBoard <<
image
.
domain
();
88
90
SurfelAdjacency<2>
sAdj(
true
);
92
94
std::vector< std::vector< Z2i::Point > > vectContoursBdryPointels;
95
Surfaces<Z2i::KSpace>::extractAllPointContours4C
( vectContoursBdryPointels,
96
ks, set2d, sAdj );
98
99
100
GradientColorMap<int>
cmap_grad( 0, (
int
)vectContoursBdryPointels.size() );
101
cmap_grad.
addColor
(
Color
( 50, 50, 255 ) );
102
cmap_grad.
addColor
(
Color
( 255, 0, 0 ) );
103
cmap_grad.
addColor
(
Color
( 255, 255, 10 ) );
104
cmap_grad.
addColor
(
Color
( 25, 255, 255 ) );
105
cmap_grad.
addColor
(
Color
( 255, 25, 255 ) );
106
cmap_grad.
addColor
(
Color
( 25, 25, 25 ) );
107
109
for
(
unsigned
int
i=0; i<vectContoursBdryPointels.size(); i++){
110
// Constructing and displaying FreemanChains from contours.
111
FreemanChain<Z2i::Integer>
fc (vectContoursBdryPointels.at(i));
114
aBoard <<
SetMode
( fc.
className
(),
"InterGrid"
);
115
aBoard<<
CustomStyle
( fc.
className
(),
116
new
CustomColors
( cmap_grad(i),
Color::None
) );
117
aBoard << fc;
119
}
120
121
aBoard.
saveEPS
(
"freemanChainFromImage.eps"
);
122
return
0;
123
}
124
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::Color::None
static const Color None
Definition
Color.h:421
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::FreemanChain
Definition
FreemanChain.h:116
DGtal::FreemanChain::className
std::string className() const
DGtal::GradientColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition
GradientColorMap.h:120
DGtal::GradientColorMap::addColor
void addColor(const Color &color)
DGtal::HyperRectDomain::lowerBound
const Point & lowerBound() const
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
DGtal::ImageContainerBySTLVector
Definition
ImageContainerBySTLVector.h:127
DGtal::Image
Aim: implements association between points lying in a digital domain and values.
Definition
Image.h:70
DGtal::Image::domain
const Domain & domain() const
Definition
Image.h:192
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::Surfaces::extractAllPointContours4C
static void extractAllPointContours4C(std::vector< std::vector< Point > > &aVectPointContour2D, const KSpace &aKSpace, const PointPredicate &pp, const SurfelAdjacency< 2 > &aSAdj)
DGtal::SurfelAdjacency
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Definition
SurfelAdjacency.h:66
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
DGtal::Z2i::KSpace
KhalimskySpaceND< 2, Integer > KSpace
Definition
StdDefs.h:77
DGtal::Z2i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:100
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition
Board2D.h:279
DGtal::CustomStyle::CustomStyle
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition
Board2D.h:224
DGtal::PGMReader::importPGM
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
DGtal::SetFromImage::append
static void append(Set &aSet, const ForegroundPredicate &isForeground, typename Image::Domain::ConstIterator itBegin, typename Image::Domain::ConstIterator itEnd)
DGtal::SetMode::SetMode
SetMode(std::string classname, std::string mode)
Definition
Board2D.h:254
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
image
Image image(domain)
examples
tutorial-examples
freemanChainFromImage.cpp
Generated on
for DGtal by
1.18.0