DGtal
1.3.beta
examples
geometry
curves
freemanChainDisplay.cpp
Go to the documentation of this file.
1
30
#include <iostream>
32
#include <fstream>
33
#include "DGtal/base/Common.h"
35
36
37
#include "DGtal/kernel/domains/HyperRectDomain.h"
38
#include "DGtal/images/ImageSelector.h"
39
#include "DGtal/kernel/SpaceND.h"
40
#include "DGtal/base/BasicTypes.h"
41
#include "DGtal/geometry/curves/FreemanChain.h"
42
#include "DGtal/io/readers/MagickReader.h"
43
#include "DGtal/io/boards/Board2D.h"
44
#include "DGtal/helpers/StdDefs.h"
45
46
47
48
#include "ConfigExamples.h"
49
50
51
using namespace
std;
52
using namespace
DGtal
;
53
using namespace
Z2i;
54
55
56
58
59
int
main
()
60
{
61
62
typedef
SpaceND<2>
Space2;
63
typedef
HyperRectDomain<Space2>
TDomain;
64
65
//Default image selector = STLVector
66
typedef
ImageSelector<TDomain, unsigned char>::Type
Image
;
67
68
69
// Creating FreemanChain from file
70
std::string freemanChainFilename = examplesPath +
"samples/contourS.fc"
;
71
fstream fst;
72
fst.open (freemanChainFilename.c_str(), ios::in);
73
FreemanChain<Space::Integer>
fc(fst);
74
fst.close();
75
76
77
// Importing image with MagickReader
78
MagickReader<Image>
reader;
79
std::string filenameImage = examplesPath +
"samples/contourS.gif"
;
80
Image
img = reader.
importImage
( filenameImage );
81
82
Point
ptInf = img.
domain
().lowerBound();
83
Point
ptSup = img.domain().upperBound();
84
unsigned
int
width = abs(ptSup[0]-ptInf[0]+1);
85
unsigned
int
height = abs(ptSup[1]-ptInf[1]+1);
86
87
// Draw the freemanchain and the contour
88
Board2D
dgBoard;
89
90
dgBoard.
drawImage
(filenameImage, 0,height-1, width, height );
91
dgBoard << fc;
92
93
dgBoard.
saveEPS
(
"freemanChainDisplay.eps"
);
94
dgBoard.
saveSVG
(
"freemanChainDisplay.svg"
);
95
dgBoard.
saveFIG
(
"freemanChainDisplay.fig"
);
96
97
98
return
0;
99
}
100
// //
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition:
HyperRectDomain.h:99
DGtal::Image::domain
const Domain & domain() const
Definition:
Image.h:192
DGtal::ImageContainerBySTLVector
Definition:
ImageContainerBySTLVector.h:126
DGtal::FreemanChain
Definition:
FreemanChain.h:113
DGtal::SpaceND
Definition:
SpaceND.h:95
DGtal::MagickReader
Aim: implements methods to read a 2D image using the ImageMagick library.
Definition:
MagickReader.h:111
Image
ImageContainerBySTLVector< Domain, Value > Image
Definition:
testSimpleRandomAccessRangeFromPoint.cpp:45
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:428
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition:
Board.cpp:1012
DGtal::MagickReader::importImage
static ImageContainer importImage(const std::string &filename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
LibBoard::Board::saveFIG
void saveFIG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0, bool includeFIGHeader=true) const
Definition:
Board.cpp:907
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition:
Board2D.h:70
DGtal::Image
Aim: implements association bewteen points lying in a digital domain and values.
Definition:
Image.h:69
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition:
Board.cpp:805
main
int main()
Definition:
freemanChainDisplay.cpp:59
Point
MyPointD Point
Definition:
testClone2.cpp:383
Generated on Thu May 19 2022 18:08:17 for DGtal by
1.8.17