52#include "DGtal/base/Common.h"
53#include "DGtal/helpers/StdDefs.h"
54#include "DGtal/kernel/BasicPointPredicates.h"
55#include "DGtal/math/linalg/EigenDecomposition.h"
56#include "DGtal/topology/helpers/Surfaces.h"
57#include "DGtal/topology/DigitalSurface.h"
58#include "DGtal/topology/ImplicitDigitalSurface.h"
59#include "DGtal/images/ImageSelector.h"
60#include "DGtal/images/IntervalForegroundPredicate.h"
61#include "DGtal/geometry/volumes/distance/ExactPredicateLpSeparableMetric.h"
62#include "DGtal/geometry/surfaces/estimation/VoronoiCovarianceMeasureOnDigitalSurface.h"
63#include "DGtal/io/colormaps/GradientColorMap.h"
64#include "DGtal/io/viewers/PolyscopeViewer.h"
65#include "DGtal/io/readers/GenericReader.h"
66#include "ConfigExamples.h"
94 KernelFunction > VCMOnSurface;
95 typedef VCMOnSurface::Surfel2Normals::const_iterator S2NConstIterator;
98 string inputFilename = examplesPath +
"samples/Al.100.vol";
99 trace.
info() <<
"File = " << inputFilename << std::endl;
100 int thresholdMin = 0;
101 trace.
info() <<
"Min image thres. = " << thresholdMin << std::endl;
102 int thresholdMax = 1;
103 trace.
info() <<
"Max image thres. = " << thresholdMax << std::endl;
105 trace.
info() <<
"Big radius R = " <<
R << std::endl;
107 trace.
info() <<
"Small radius r = " << r << std::endl;
108 const double trivial_r = 3;
109 trace.
info() <<
"Trivial radius t = " << trivial_r << std::endl;
110 const double T = 0.1;
111 trace.
info() <<
"Feature thres. T = " << T << std::endl;
113 const double size = 1.0;
117 trace.
beginBlock(
"Loading image into memory and build digital surface." );
119 ThresholdedImage thresholdedImage(
image, thresholdMin, thresholdMax );
126 DigitalSurfaceContainer* container =
127 new DigitalSurfaceContainer( ks, thresholdedImage, surfAdj, bel,
false );
129 trace.
info() <<
"Digital surface has " <<
surface.size() <<
" surfels." << std::endl;
135 KernelFunction chi( 1.0, r );
136 VCMOnSurface vcm_surface(
surface, embType,
R, r,
137 chi, trivial_r, l2,
true );
145 grad.addColor(
Color( 128, 128, 255 ) );
146 grad.addColor(
Color( 255, 255, 255 ) );
147 grad.addColor(
Color( 255, 255, 0 ) );
148 grad.addColor(
Color( 255, 0, 0 ) );
150 for ( S2NConstIterator it = vcm_surface.mapSurfel2Normals().begin(),
151 itE = vcm_surface.mapSurfel2Normals().end(); it != itE; ++it )
155 RealPoint rp( 0.5 * (
double) kp[ 0 ], 0.5 * (
double) kp[ 1 ], 0.5 * (
double) kp[ 2 ] );
157 vcm_surface.getChiVCMEigenvalues( lambda, s );
158 double ratio = lambda[ 1 ] / ( lambda[ 0 ] + lambda[ 1 ] + lambda[ 2 ] );
159 viewer.drawColor( grad( ratio > T ? T : ratio ) );
165 viewer.drawLine( rp + n, rp - n );
Structure representing an RGB triple with alpha component.
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: implements separable l_p metrics with exact predicates.
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: implements association bewteen points lying in a digital domain and values.
const Domain & domain() const
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
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.
Cell unsigns(const SCell &p) const
Creates an unsigned cell from a signed one.
const Point & sKCoords(const SCell &c) const
Return its Khalimsky coordinates.
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void beginBlock(const std::string &keyword="")
Aim: This class specializes the Voronoi covariance measure for digital surfaces. It adds notably the ...
Aim: Define a simple Foreground predicate thresholding image values between two constant values (the ...
CountedPtr< SH3::DigitalSurface > surface
DGtal is the top-level namespace which contains all DGtal functions and types.
Surfel2PointEmbedding
Possible embeddings for surfel as point(s)
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
HyperRectDomain< Space > Domain
PointVector< 3, double > RealPoint