Example of use the FMM (fast marching method) class in 2D.
#include <iostream>
#include <iomanip>
#include <functional>
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/kernel/sets/DigitalSetFromMap.h"
#include "DGtal/images/ImageContainerBySTLMap.h"
#include "DGtal/topology/SCellsFunctors.h"
#include "DGtal/shapes/ShapeFactory.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/helpers/Surfaces.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/geometry/volumes/distance/FMM.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/boards/Board2D.h"
template< typename TImage >
void draw(
const TImage aImg,
const double& aMaxValue, std::string aBasename)
{
typedef typename TImage::Domain::ConstIterator ConstIteratorOnPoints;
typedef typename TImage::Domain::Point
Point;
for (ConstIteratorOnPoints it = aImg.domain().begin(), itEnd = aImg.domain().end();
it != itEnd; ++it)
{
b << p;
}
{
std::stringstream s;
s << aBasename << ".eps";
b.saveEPS(s.str().c_str());
}
#ifdef WITH_CAIRO
{
std::stringstream s;
s << aBasename << ".png";
b.saveCairo(s.str().c_str(), Board2D::CairoPNG);
}
#endif
}
{
int size = 25;
Z2i::Point::diagonal(size) );
DistanceImage distanceImage(
domain );
AcceptedPointSet set( distanceImage );
set.insert( origin );
distanceImage.setValue( origin, 0.0 );
FMM fmm( distanceImage, set,
domain.predicate() );
trace.
info() <<
"Init: " << fmm << std::endl;
fmm.compute();
trace.
info() <<
"End: " << fmm << std::endl;
std::stringstream s;
s << "DTbyFMM-" << size;
draw(distanceImage, fmm.max(), s.str());
}
int main (
int argc,
char** argv )
{
for ( int i = 0; i < argc; ++i )
return 1;
}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: An adapter for viewing an associative image container like ImageContainerBySTLMap as a simple di...
Aim: Fast Marching Method (FMM) for nd distance transforms.
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void beginBlock(const std::string &keyword="")
void example()
We use FMM to compute a distance field from a given point.
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
void draw(const Iterator &itb, const Iterator &ite, Board &aBoard)