DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
freemanChainDisplay.cpp
1 
30 
31 #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  typedef TDomain::Vector Vector;
65 
66  //Default image selector = STLVector
68 
69 
70  // Creating FreemanChain from file
71  std::string freemanChainFilename = examplesPath + "samples/contourS.fc";
72  fstream fst;
73  fst.open (freemanChainFilename.c_str(), ios::in);
75  fst.close();
76 
77 
78  // Importing image with MagickReader
79  MagickReader<Image> reader;
80  std::string filenameImage = examplesPath + "samples/contourS.gif";
81  Image img = reader.importImage( filenameImage );
82 
83  Point ptInf = img.domain().lowerBound();
84  Point ptSup = img.domain().upperBound();
85  unsigned int width = abs(ptSup.at(0)-ptInf.at(0)+1);
86  unsigned int height = abs(ptSup.at(1)-ptInf.at(1)+1);
87 
88  // Draw the freemanchain and the contour
89  Board2D dgBoard;
90 
91  dgBoard.drawImage(filenameImage, 0,height-1, width, height );
92  dgBoard << fc;
93 
94  dgBoard.saveEPS("freemanChainDisplay.eps");
95  dgBoard.saveSVG("freemanChainDisplay.svg");
96  dgBoard.saveFIG("freemanChainDisplay.fig");
97 
98 
99  return 0;
100 }
101 // //