Example of a toric distance transform construction in dimension 2 for the Euclidean metric.
#include <iostream>
#include <iomanip>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/colormaps/GrayscaleColorMap.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/colormaps/TickedColorMap.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/SimpleThresholdForegroundPredicate.h"
#include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
#include <boost/algorithm/minmax_element.hpp>
{
for ( Image::Iterator it =
image.begin(), itend =
image.end();it != itend; ++it)
(*it)=128;
trace.beginBlock (
"Example toricdomainvolumetric" );
board.
saveSVG(
"toric-inputShape.svg");
PointPredicate predicate(
image,0);
DTL2 dtL2(
image.domain(), predicate, l2Metric);
DTL2Toric dtL2Toric(
image.domain(), predicate, l2Metric, {{true, true}} );
DTL2ToricX dtL2ToricX(
image.domain(), predicate, l2Metric, {{true, false}} );
DTL2ToricY dtL2ToricY(
image.domain(), predicate, l2Metric, {{false, true}} );
const DTL2::Value maxv2 = * (boost::first_max_element(dtL2.constRange().begin(), dtL2.constRange().end()));
const DTL2Toric::Value maxvtoric = * (boost::first_max_element(dtL2Toric.constRange().begin(), dtL2Toric.constRange().end()));
const DTL2ToricX::Value maxvtoricX = * (boost::first_max_element(dtL2ToricX.constRange().begin(), dtL2ToricX.constRange().end()));
const DTL2ToricY::Value maxvtoricY = * (boost::first_max_element(dtL2ToricY.constRange().begin(), dtL2ToricY.constRange().end()));
const auto maxvall = std::max( { maxv2, maxvtoric, maxvtoricX, maxvtoricY } );
trace.warning() <<
"DT maxValue= " << maxv2 << endl;
board.clear();
board.saveSVG ( "toric-example-DT-L2.svg" );
trace.warning() <<
"Full toric maxValue= " << maxvtoric << endl;
board.clear();
board.saveSVG ( "toric-example-DT-L2-toric.svg" );
trace.warning() <<
"1th dimension periodic maxValue= " << maxvtoricX << endl;
board.clear();
board.saveSVG ( "toric-example-DT-L2-toricX.svg" );
trace.warning() <<
"2nd dimension periodic maxValue= " << maxvtoricY << endl;
board.clear();
board.saveSVG ( "toric-example-DT-L2-toricY.svg" );
ticked.addRegularTicks(3, 0.5);
ticked.finalize();
board.clear();
for ( auto it = dtL2.domain().begin(), itend = dtL2.domain().end();it != itend; ++it)
{
board << *it;
}
board.saveSVG("toric-example-DT-L2-ticked.svg");
board.clear();
for ( auto it = dtL2Toric.domain().begin(), itend = dtL2Toric.domain().end();it != itend; ++it)
{
board << *it;
}
board.saveSVG("toric-example-DT-L2-ticked-toric.svg");
board.clear();
for ( auto it = dtL2ToricX.domain().begin(), itend = dtL2ToricX.domain().end();it != itend; ++it)
{
board << *it;
}
board.saveSVG("toric-example-DT-L2-ticked-toricX.svg");
board.clear();
for ( auto it = dtL2ToricY.domain().begin(), itend = dtL2ToricY.domain().end();it != itend; ++it)
{
board << *it;
}
board.saveSVG("toric-example-DT-L2-ticked-toricY.svg");
board.clear();
board << dtL2.domain();
for ( auto it = dtL2.domain().begin(), itend = dtL2.domain().end();it != itend; ++it)
if ( dtL2.getVoronoiSite(*it) != *it )
board.saveSVG("toric-example-Voro-L2.svg");
board.clear();
board << dtL2Toric.domain();
for ( auto it = dtL2Toric.domain().begin(), itend = dtL2Toric.domain().end();it != itend; ++it)
if ( dtL2Toric.getVoronoiSite(*it) != *it )
board.saveSVG("toric-example-Voro-L2-toric.svg");
board.clear();
board << dtL2Toric.domain();
for ( auto it = dtL2Toric.domain().begin(), itend = dtL2Toric.domain().end();it != itend; ++it)
if ( dtL2Toric.getVoronoiSite(*it) != *it )
board.saveSVG("toric-example-Voro-L2-toric-projected.svg");
board.clear();
board << dtL2ToricX.domain();
for ( auto it = dtL2ToricX.domain().begin(), itend = dtL2ToricX.domain().end();it != itend; ++it)
if ( dtL2ToricX.getVoronoiSite(*it) != *it )
board.saveSVG("toric-example-Voro-L2-toricX.svg");
board.clear();
board << dtL2ToricY.domain();
for ( auto it = dtL2ToricY.domain().begin(), itend = dtL2ToricY.domain().end();it != itend; ++it)
if ( dtL2ToricY.getVoronoiSite(*it) != *it )
board.saveSVG("toric-example-Voro-L2-toricY.svg");
return 0;
}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: This class template may be used to (linearly) convert scalar values in a given range into gray l...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: This class adapts any colormap to add "ticks" in the colormap colors.
Aim: Define a simple Foreground predicate thresholding image values given a single thresold....
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
static void drawImage(DGtal::Board2D &board, const Image &i, const typename Image::Value &minV, const typename Image::Value &maxV)
static void draw(DGtal::Board2D &board, const DGtal::DiscreteExteriorCalculus< dimEmbedded, dimAmbient, TLinearAlgebraBackend, TInteger > &calculus)
ImageContainerBySTLVector< Domain, Value > Type
ImageContainerBySTLVector< Domain, Value > Image
HyperRectDomain< Space > Domain