DGtal  1.2.0
Functions
freemanChainDisplay.cpp File Reference
#include <iostream>
#include <fstream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/base/BasicTypes.h"
#include "DGtal/geometry/curves/FreemanChain.h"
#include "DGtal/io/readers/MagickReader.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
Include dependency graph for freemanChainDisplay.cpp:

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2010/12/01

An example of FreemanChain display with background source image.

This file is part of the DGtal library.

Definition in file freemanChainDisplay.cpp.

Function Documentation

◆ main()

int main ( void  )

Definition at line 59 of file freemanChainDisplay.cpp.

60 {
61 
62  typedef SpaceND<2> Space2;
63  typedef HyperRectDomain<Space2> TDomain;
64 
65  //Default image selector = STLVector
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);
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 }
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
void saveFIG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0, bool includeFIGHeader=true) const
Definition: Board.cpp:907
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
void drawImage(std::string filename, double x, double y, double width, double height, int depthValue=-1, double alpha=1.0)
Definition: Board.cpp:428
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
Aim: implements methods to read a 2D image using the ImageMagick library.
Definition: MagickReader.h:112
static ImageContainer importImage(const std::string &filename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
ImageContainerBySTLVector< Domain, Value > Image

References LibBoard::Board::drawImage(), DGtal::MagickReader< TImageContainer, TFunctor >::importImage(), LibBoard::Board::saveEPS(), LibBoard::Board::saveFIG(), and LibBoard::Board::saveSVG().