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/Viewer3D.h"
65#include "DGtal/io/readers/GenericReader.h"
66#include "ConfigExamples.h"
75int main(
int argc,
char** argv )
77 QApplication application(argc,argv);
96 KernelFunction > VCMOnSurface;
97 typedef VCMOnSurface::Surfel2Normals::const_iterator S2NConstIterator;
100 string inputFilename = examplesPath +
"samples/Al.100.vol";
101 trace.
info() <<
"File = " << inputFilename << std::endl;
102 int thresholdMin = 0;
103 trace.
info() <<
"Min image thres. = " << thresholdMin << std::endl;
104 int thresholdMax = 1;
105 trace.
info() <<
"Max image thres. = " << thresholdMax << std::endl;
107 trace.
info() <<
"Big radius R = " <<
R << std::endl;
109 trace.
info() <<
"Small radius r = " << r << std::endl;
110 const double trivial_r = 3;
111 trace.
info() <<
"Trivial radius t = " << trivial_r << std::endl;
112 const double T = 0.1;
113 trace.
info() <<
"Feature thres. T = " << T << std::endl;
115 const double size = 1.0;
119 trace.
beginBlock(
"Loading image into memory and build digital surface." );
121 ThresholdedImage thresholdedImage( image, thresholdMin, thresholdMax );
124 ks.
init( image.domain().lowerBound(),
125 image.domain().upperBound(),
true );
128 DigitalSurfaceContainer* container =
129 new DigitalSurfaceContainer( ks, thresholdedImage, surfAdj, bel,
false );
131 trace.
info() <<
"Digital surface has " <<
surface.size() <<
" surfels." << std::endl;
137 KernelFunction chi( 1.0, r );
138 VCMOnSurface vcm_surface(
surface, embType,
R, r,
139 chi, trivial_r, l2,
true );
145 viewer.setWindowTitle(
"3D VCM viewer");
150 grad.addColor(
Color( 128, 128, 255 ) );
151 grad.addColor(
Color( 255, 255, 255 ) );
152 grad.addColor(
Color( 255, 255, 0 ) );
153 grad.addColor(
Color( 255, 0, 0 ) );
155 for ( S2NConstIterator it = vcm_surface.mapSurfel2Normals().begin(),
156 itE = vcm_surface.mapSurfel2Normals().end(); it != itE; ++it )
160 RealPoint rp( 0.5 * (
double) kp[ 0 ], 0.5 * (
double) kp[ 1 ], 0.5 * (
double) kp[ 2 ] );
162 vcm_surface.getChiVCMEigenvalues( lambda, s );
163 double ratio = lambda[ 1 ] / ( lambda[ 0 ] + lambda[ 1 ] + lambda[ 2 ] );
164 viewer.setFillColor( grad( ratio > T ? T : ratio ) );
168 viewer.addLine( rp + n, rp - n, 0.1 );
170 viewer << Viewer3D<>::updateDisplay;
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.
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 >())
std::string className() const
Return the style name used for drawing this object.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
ImageContainerBySTLVector< Domain, Value > Image
HyperRectDomain< Space > Domain
PointVector< 3, double > RealPoint