DGtal  1.4.beta
Typedefs | Functions
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/Viewer3D.h"
Include dependency graph for exampleMaximalSegmentSliceEstimation.cpp:

Go to the source code of this file.

Typedefs

using KSpace = Z3i::KSpace
 
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

◆ KSpace

Definition at line 43 of file exampleMaximalSegmentSliceEstimation.cpp.

◆ Point

using Point = SH3::Point

Definition at line 48 of file exampleMaximalSegmentSliceEstimation.cpp.

◆ RealPoint

Definition at line 47 of file exampleMaximalSegmentSliceEstimation.cpp.

◆ SH3

using SH3 = Shortcuts<KSpace>

Definition at line 44 of file exampleMaximalSegmentSliceEstimation.cpp.

◆ Surface

◆ Surfel

Definition at line 46 of file exampleMaximalSegmentSliceEstimation.cpp.

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 }

References DGtal::Shortcuts< TKSpace >::getPrimalVertices(), K, and DGtal::KhalimskySpaceND< dim, TInteger >::uCoords().

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

[MaximalSegmentSliceEstimationConstructionUsage]

[MaximalSegmentSliceEstimationConstructionUsage]

Definition at line 65 of file exampleMaximalSegmentSliceEstimation.cpp.

66 {
67  QApplication application(argc, argv);
68 
69  auto params = SH3::defaultParameters();
70  params("polynomial", "ellipsoid")("gridstep", "1.0");
71  auto implicit_shape = SH3::makeImplicitShape3D ( params );
72  auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
73  auto K = SH3::getKSpace( params );
74  auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
75  auto surface = SH3::makeDigitalSurface( binary_image, K, params );
76  auto surfels = SH3::getSurfelRange(surface);
77 
78  double gridstep = params["gridstep"].as<double>();
79 
80  Viewer3D<> viewer(K);
81  viewer << SetMode3D(Surfel().className(), "Basic");
82  viewer.show();
83 
85  // Instantiation
87  Estimator estimator;
88  estimator.init(gridstep, surfels.begin(), surfels.end());
89  estimator.attach(surface);
90 
91  // Usage
92  std::vector<Estimator::Quantity> quantities;
93  estimator.eval(surfels.begin(), surfels.end(), std::back_inserter(quantities));
95 
96  Color fillColor = viewer.getFillColor();
97 
98  for (std::size_t i = 0; i < surfels.size(); ++i)
99  {
100  const Surfel& s = surfels[i];
101  const Estimator::Quantity& normal = quantities[i];
102 
103  const RealPoint& n = normal.getNormalized();
104  RealPoint origin = centerSurfel(K, s);
105 
106  viewer.setFillColor(fillColor);
107  viewer << s;
108 
109  viewer.setLineColor(Color::Green);
110  viewer.addLine(origin, origin + 1.5 * n, 0.3);
111  }
112 
113  viewer << Viewer3D<>::updateDisplay;
114  application.exec();
115 
116  return 0;
117 }

References centerSurfel(), DGtal::Shortcuts< TKSpace >::defaultParameters(), DGtal::Shortcuts< TKSpace >::getKSpace(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::getNormalized(), DGtal::Shortcuts< TKSpace >::getSurfelRange(), K, DGtal::Shortcuts< TKSpace >::makeBinaryImage(), DGtal::Shortcuts< TKSpace >::makeDigitalSurface(), DGtal::Shortcuts< TKSpace >::makeDigitizedImplicitShape3D(), and DGtal::Shortcuts< TKSpace >::makeImplicitShape3D().

DGtal::PlaneProbingParallelepipedEstimator
Aim:
Definition: PlaneProbingParallelepipedEstimator.h:62
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
K
KSpace K
Definition: testCubicalComplex.cpp:62
DGtal::Shortcuts::makeDigitalSurface
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1209
DGtal::SignedKhalimskyCell
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Definition: KhalimskySpaceND.h:208
centerSurfel
RealPoint centerSurfel(KSpace const &K, SH3::SCell const &s)
Definition: exampleMaximalSegmentSliceEstimation.cpp:50
DGtal::Viewer3D
Definition: Viewer3D.h:131
DGtal::Shortcuts::defaultParameters
static Parameters defaultParameters()
Definition: Shortcuts.h:203
DGtal::Shortcuts::makeImplicitShape3D
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters &params=parametersImplicitShape3D())
Definition: Shortcuts.h:282
DGtal::PointVector::getNormalized
PointVector< dim, double, std::array< double, dim > > getNormalized() const
DGtal::KhalimskySpaceND::uCoords
Point uCoords(const Cell &c) const
Return its digital coordinates.
DGtal::MaximalSegmentSliceEstimation< Surface >
DGtal::PlaneProbingParallelepipedEstimator::Quantity
typename TetrahedronEstimator::Quantity Quantity
Definition: PlaneProbingParallelepipedEstimator.h:77
DGtal::Shortcuts::makeDigitizedImplicitShape3D
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
Definition: Shortcuts.h:523
DGtal::SetMode3D
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Definition: DrawWithDisplay3DModifier.h:73
DGtal::Shortcuts::getKSpace
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition: Shortcuts.h:332
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::Shortcuts::getPrimalVertices
static CellRange getPrimalVertices(const KSpace &K, const SCell &s)
Definition: Shortcuts.h:3180
DGtal::Shortcuts::getSurfelRange
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1547
DGtal::Shortcuts::makeBinaryImage
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:561
Point
MyPointD Point
Definition: testClone2.cpp:383
Surfel
Surface::Surfel Surfel
Definition: exampleMaximalSegmentSliceEstimation.cpp:46