DGtal  0.9.3
Functions
imageSetDT.cpp File Reference
#include <iostream>
#include <fstream>
#include <algorithm>
#include <boost/algorithm/minmax_element.hpp>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/BasicFunctors.h"
#include "DGtal/kernel/BasicPointPredicates.h"
#include "DGtal/kernel/sets/DigitalSetInserter.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/images/ImageHelper.h"
#include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
#include "DGtal/images/IntervalForegroundPredicate.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/readers/PGMReader.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/colormaps/GrayscaleColorMap.h"
#include "ConfigExamples.h"
Include dependency graph for imageSetDT.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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr)
Date
2010/12/01

An example of DT computation from a digital set extracted from an image.

This file is part of the DGtal library.

Definition in file imageSetDT.cpp.

Function Documentation

◆ main()

int main ( )

[ImageSetDT-types]

[ImageSetDT-types]

[ImageSetDT-image]

[ImageSetDT-image]

[ImageSetDT-board1]

[ImageSetDT-board1]

[ImageSetDT-DT]

[ImageSetDT-DT]

[ImageSetDT-DTvis]

[ImageSetDT-DTvis]

Definition at line 62 of file imageSetDT.cpp.

References LibBoard::Board::clear(), DGtal::Image< TImageContainer >::domain(), image(), DGtal::PGMReader< TImageContainer, TFunctor >::importPGM(), DGtal::Trace::info(), DGtal::Z2i::l2Metric, LibBoard::Board::saveSVG(), DGtal::setFromImage(), and DGtal::trace.

63 {
68 
69 
71  std::string filename = examplesPath + "samples/contourS.pgm";
72  Image image = DGtal::PGMReader<Image>::importPGM(filename);
73  DGtal::trace.info() << "Imported image: "<<image<<std::endl;
75 
76 
78  DGtal::Board2D aBoard;
79  aBoard << image.domain();
80  aBoard.saveSVG("imageDomainTuto.svg");
81  aBoard.clear();
82  Display2DFactory::drawImage<Gray>(aBoard, image, (unsigned char)0, (unsigned char)255);
83  aBoard.saveEPS("imageDomainTuto2.eps");
85 
86 
87  Z2i::DigitalSet mySet(image.domain());
88  DigitalSetInserter<Z2i::DigitalSet> inserter(mySet);
89  setFromImage(image, inserter, 1, 135);
90  aBoard.clear();
91  aBoard << mySet.domain()
92  << mySet;
93  aBoard.saveEPS("imageDomainTuto2bis.eps");
94 
95 
98  Binarizer b(image,1, 135);
100  DTL2 dt(&image.domain(),&b, &Z2i::l2Metric );
102 
103 
105  DTL2::Value maxDT = (*boost::first_max_element(dt.constRange().begin(),
106  dt.constRange().end(), std::less<DTL2::Value>() ));
108 
109  aBoard.clear();
110  Display2DFactory::drawImage<HueTwice>(aBoard, dt, (DTL2::Value)0,
111  (DTL2::Value)maxDT);
112  aBoard.saveEPS("imageDomainTuto3.eps");
114 
115  return 0;
116 
117 }
Aim: Implementation of the linear in time distance transformation for separable metrics.
Trace trace
Definition: Common.h:137
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
Aim: This class template may be used to (linearly) convert scalar values in a given range into gray l...
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void setFromImage(const I &aImg, const O &ito, const typename I::Value &aThreshold=0)
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
std::ostream & info()
ImageContainerBySTLVector< Domain, Value > Image
const Domain & domain() const
Definition: Image.h:192
Aim: Define a simple Foreground predicate thresholding image values between two constant values (the ...
Aim: this output iterator class is designed to allow algorithms to insert points in the digital set...
Image image(domain)
Aim: This class specializes a &#39;Board&#39; class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70