DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
freemanChainFromImage.cpp File Reference
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
#include "DGtal/io/readers/PGMReader.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/topology/helpers/Surfaces.h"
#include "DGtal/geometry/curves/FreemanChain.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/io/Color.h"

Go to the source code of this file.

Functions

int main ()
 [freemanChainFromImage-displayIncludes] More...
 

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 freemanChainFromImage.cpp.

Function Documentation

◆ main()

int main ( void  )

[freemanChainFromImage-displayIncludes]

[freemanChainFromImage-imageImport]

[freemanChainFromImage-imageImport]

[freemanChainFromImage-ksspace]

[freemanChainFromImage-ksspace]

[freemanChainFromImage-setAppend]

[freemanChainFromImage-setAppend]

[freemanChainFromImage-displaySet]

[freemanChainFromImage-displaySet]

[freemanChainFromImage-adj]

[freemanChainFromImage-adj]

[freemanChainFromImage-extraction]

[freemanChainFromImage-extraction]

[freemanChainFromImage-fcConstruction]

[freemanChainFromImage-fcConstruction] [freemanChainFromImage-fcdysplay]

[freemanChainFromImage-fcdysplay]

Definition at line 63 of file freemanChainFromImage.cpp.

64{
65
68 std::string filename = examplesPath + "samples/circleR10modif.pgm";
71
73 Z2i::KSpace ks;
74 ks.init( image.domain().lowerBound(), image.domain().upperBound(), true );
76
78 Z2i::DigitalSet set2d (image.domain());
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;
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}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
static const Color None
Definition: Color.h:412
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
static void extractAllPointContours4C(std::vector< std::vector< Point > > &aVectPointContour2D, const KSpace &aKSpace, const PointPredicate &pp, const SurfelAdjacency< 2 > &aSAdj)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
Aim: Define utilities to convert a digital set into an image.
Definition: SetFromImage.h:64
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::FreemanChain< TInteger >::className(), DGtal::Surfaces< TKSpace >::extractAllPointContours4C(), DGtal::PGMReader< TImageContainer, TFunctor >::importPGM(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::Color::None, and LibBoard::Board::saveEPS().