File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
exampleMaximalSegmentSliceEstimation.cpp File Reference
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/geometry/surfaces/estimation/MaximalSegmentSliceEstimation.h"
#include "DGtal/helpers/Shortcuts.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
Include dependency graph for exampleMaximalSegmentSliceEstimation.cpp:

Go to the source code of this file.

Typedefs

using SH3 = Shortcuts<KSpace>
using Surface = SH3::DigitalSurface
using Surfel = Surface::Surfel
using RealPoint = SH3::RealPoint
using Point = SH3::Point

Functions

RealPoint centerSurfel (KSpace const &K, SH3::SCell const &s)
int main (int argc, char **argv)

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
Jocelyn Meyron (jocel.nosp@m.yn.m.nosp@m.eyron.nosp@m.@lir.nosp@m.is.cn.nosp@m.rs.f.nosp@m.r ) Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2020/12/15

An example file that shows how to construct and use a DGtal::MaximalSegmentSliceEstimation on a digital surface.

This file is part of the DGtal library.

Definition in file exampleMaximalSegmentSliceEstimation.cpp.

Typedef Documentation

◆ Point

using Point = SH3::Point

Definition at line 48 of file exampleMaximalSegmentSliceEstimation.cpp.

◆ RealPoint

◆ SH3

using SH3 = Shortcuts<KSpace>

Definition at line 44 of file exampleMaximalSegmentSliceEstimation.cpp.

◆ Surface

◆ Surfel

Function Documentation

◆ centerSurfel()

RealPoint centerSurfel ( KSpace const & K,
SH3::SCell const & s )

Definition at line 50 of file exampleMaximalSegmentSliceEstimation.cpp.

51{
52 auto pointels = SH3::getPrimalVertices(K, s, true);
53
54 Point p = K.uCoords(pointels[0]),
55 u = K.uCoords(pointels[1]) - p,
56 v = K.uCoords(pointels[3]) - p;
57
58 static const RealPoint shift(-0.5, -0.5, -0.5);
59
60 return p + 0.5 * u + 0.5 * v + shift;
61}
static CellRange getPrimalVertices(const KSpace &K, const SCell &s)
Definition Shortcuts.h:3263
KSpace K
PointVector< 3, double > RealPoint

References DGtal::Shortcuts< KSpace >::getPrimalVertices(), and K.

Referenced by main().

◆ main()

int main ( int argc,
char ** argv )

[MaximalSegmentSliceEstimationConstructionUsage]

[MaximalSegmentSliceEstimationConstructionUsage]

Definition at line 65 of file exampleMaximalSegmentSliceEstimation.cpp.

66{
67 auto params = SH3::defaultParameters();
68 params("polynomial", "ellipsoid")("gridstep", "1.0");
69 auto implicit_shape = SH3::makeImplicitShape3D ( params );
70 auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
71 auto K = SH3::getKSpace( params );
72 auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
74 auto surfels = SH3::getSurfelRange(surface);
75
76 double gridstep = params["gridstep"].as<double>();
77
78 PolyscopeViewer<> viewer(K);
79
81 // Instantiation
83 Estimator estimator;
84 estimator.init(gridstep, surfels.begin(), surfels.end());
85 estimator.attach(surface);
86
87 // Usage
88 std::vector<Estimator::Quantity> quantities;
89 estimator.eval(surfels.begin(), surfels.end(), std::back_inserter(quantities));
91
92 Color fillColor = Color::White;
93
94 for (std::size_t i = 0; i < surfels.size(); ++i)
95 {
96 const Surfel& s = surfels[i];
97 const Estimator::Quantity& normal = quantities[i];
98
99 const RealPoint& n = normal.getNormalized();
100 RealPoint origin = centerSurfel(K, s);
101
102 viewer.drawColor(fillColor);
103 viewer << s;
104
105 viewer.drawColor(Color::Green);
106 viewer.drawLine(origin, origin + 1.5 * n);
107 }
108
109 viewer.show();
110 return 0;
111}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
static const Color Green
Definition Color.h:426
static const Color White
Definition Color.h:424
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition Shortcuts.h:333
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
Definition Shortcuts.h:524
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1548
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition Shortcuts.h:1210
static Parameters defaultParameters()
Definition Shortcuts.h:204
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition Shortcuts.h:562
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters &params=parametersImplicitShape3D())
Definition Shortcuts.h:283
CountedPtr< SH3::DigitalSurface > surface
CountedPtr< SH3::BinaryImage > binary_image
RealPoint centerSurfel(KSpace const &K, SH3::SCell const &s)
PlaneProbingParallelepipedEstimator< DigitalPlane, ProbingMode::R1 > Estimator

References binary_image, centerSurfel(), DGtal::Shortcuts< KSpace >::defaultParameters(), DGtal::Shortcuts< KSpace >::getKSpace(), DGtal::Shortcuts< KSpace >::getSurfelRange(), DGtal::Color::Green, K, DGtal::Shortcuts< KSpace >::makeBinaryImage(), DGtal::Shortcuts< KSpace >::makeDigitalSurface(), DGtal::Shortcuts< KSpace >::makeDigitizedImplicitShape3D(), DGtal::Shortcuts< KSpace >::makeImplicitShape3D(), surface, and DGtal::Color::White.