DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
freemanChainDisplay.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include <fstream>
33
#include "DGtal/base/Common.h"
35
#include "DGtal/kernel/domains/HyperRectDomain.h"
36
#include "DGtal/images/ImageSelector.h"
37
#include "DGtal/kernel/SpaceND.h"
38
#include "DGtal/base/BasicTypes.h"
39
#include "DGtal/geometry/curves/FreemanChain.h"
40
#include "DGtal/io/readers/STBReader.h"
41
#include "DGtal/io/boards/Board2D.h"
42
#include "DGtal/helpers/StdDefs.h"
43
44
#include "ConfigExamples.h"
45
46
using namespace
std
;
47
using namespace
DGtal
;
48
using namespace
Z2i
;
50
51
int
main
()
52
{
53
54
typedef
SpaceND<2>
Space2;
55
typedef
HyperRectDomain<Space2>
TDomain;
56
57
//Default image selector = STLVector
58
typedef
ImageSelector<TDomain, unsigned char>::Type
Image
;
59
60
// Creating FreemanChain from file
61
std::string freemanChainFilename = examplesPath +
"samples/contourS.fc"
;
62
fstream fst;
63
fst.open (freemanChainFilename.c_str(), ios::in);
64
FreemanChain<Space::Integer>
fc(fst);
65
fst.close();
66
67
// Importing image with MagickReader
68
STBReader<Image>
reader;
69
std::string filenameImage = examplesPath +
"samples/contourS.png"
;
70
Image
img = reader.
import
( filenameImage );
71
72
Point
ptInf = img.
domain
().
lowerBound
();
73
Point
ptSup = img.
domain
().
upperBound
();
74
unsigned
int
width = abs(ptSup[0]-ptInf[0]+1);
75
unsigned
int
height = abs(ptSup[1]-ptInf[1]+1);
76
77
// Draw the freemanchain and the contour
78
Board2D
dgBoard;
79
80
dgBoard.
drawImage
(filenameImage, 0,height-1, width, height );
81
dgBoard << fc;
82
83
dgBoard.
saveEPS
(
"freemanChainDisplay.eps"
);
84
dgBoard.
saveSVG
(
"freemanChainDisplay.svg"
);
85
dgBoard.
saveFIG
(
"freemanChainDisplay.fig"
);
86
87
return
0;
88
}
89
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::FreemanChain
Definition
FreemanChain.h:116
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition
HyperRectDomain.h:100
DGtal::HyperRectDomain::lowerBound
const Point & lowerBound() const
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
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::STBReader
Aim: Image reader using the stb_image.h header only code.
Definition
STBReader.h:62
DGtal::STBReader::import
static ImageContainer import(const std::string &filename, const Functor &aFunctor=Functor())
DGtal::SpaceND
Definition
SpaceND.h:96
LibBoard::Board::saveFIG
void saveFIG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0, bool includeFIGHeader=true) const
Definition
Board.cpp:906
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
LibBoard::Board::drawImage
void drawImage(std::string filename, double x, double y, double width, double height, int depthValue=-1, double alpha=1.0)
Definition
Board.cpp:427
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:1011
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
DGtal::ImageSelector::Type
ImageContainerBySTLVector< Domain, Value > Type
Definition
ImageSelector.h:84
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
geometry
curves
freemanChainDisplay.cpp
Generated on
for DGtal by
1.18.0