31#include "DGtal/base/Common.h"
32#include "ConfigTest.h"
33#include "DGtalCatch.h"
34#include "DGtal/helpers/StdDefs.h"
35#include "DGtal/helpers/Shortcuts.h"
36#include "DGtal/helpers/ShortcutsGeometry.h"
37#include "DGtal/geometry/surfaces/DigitalSurfaceRegularization.h"
55 params(
"polynomial",
"goursat" )(
"gridstep", 1.0)(
"verbose", 0);
61 SECTION(
"Basic Construction using Trivial Normals and regular/clamped advection")
72 REQUIRE( energy == Approx(1684.340));
76 REQUIRE( finalenergy == Approx( 4.7763 ) );
94 REQUIRE( original[0] == regularizedPosition[0] );
95 REQUIRE( original[123] == regularizedPosition[123] );
101 normals,
SH3::Colors(),
"regularizedSurfClamped.obj");
102 REQUIRE( finalenergyClamped == Approx(12.1914) );
103 REQUIRE( finalenergy < finalenergyClamped );
106 auto aPointelIndex = cellIndex.begin();
110 SECTION(
"Basic Construction with II Normal Vectors")
124 REQUIRE( energy == Approx(1588.649));
144 auto secondenergy = regul.
regularize(10,1.0,0.1);
145 auto thirdenergy = regul.
regularize(10,1.0,0.1);
150 REQUIRE( energy > secondenergy );
151 REQUIRE( secondenergy > thirdenergy );
165 std::vector<double> alphas(original.size(),0.001);
166 std::vector<double> betas(original.size(),1.0);
167 std::vector<double> gammas(original.size(), 0.05);
171 regul2.
init(alphas,betas,gammas);
173 auto energybis = regul2.
regularize(10,1.0,0.1);
174 REQUIRE( energy == energybis );
181 normals,
SH3::Colors(),
"regularizedSurf-local.obj");
186 for(
size_t i = 0 ; i < original.size(); ++i)
187 if (original[i][0]<0.0)
190 betas[i] = 0.0000001;
193 regul3.init(alphas,betas,gammas);
194 regul3.attachConvolvedTrivialNormalVectors(params);
195 energybis = regul3.regularize();
198 regularizedPosition = regul3.getRegularizedPositions();
200 normals,
SH3::Colors(),
"regularizedSurf-localsplit.obj");
Aim: Implements Digital Surface Regularization as described in coeurjolly17regdgci.
void init(const double alpha=0.001, const double beta=1.0, const double gamma=0.05)
Initialize the parameters of the energy function.
void attachConvolvedTrivialNormalVectors(const Parameters someParams=SH3::defaultParameters()|SHG3::defaultParameters())
void attachNormalVectors(const std::function< SHG3::RealVector(SH3::SCell &)> &normalFunc)
const Positions & getRegularizedPositions() const
SHG3::RealPoint getRegularizedPosition(const SH3::Cell &aPointel)
const Normals & getNormalVectors() const
const SH3::Cell2Index & getCellIndex() const
const SH3::Surfel2Index & getSurfelIndex() const
double regularize(const unsigned int nbIters, const double dt, const double epsilon, const AdvectionFunction &advectionFunc)
Main regularization loop.
const Positions & getOriginalPositions() const
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static RealVectors getIINormalVectors(CountedPtr< BinaryImage > bimage, const SurfelRange &surfels, const Parameters ¶ms=parametersGeometryEstimation()|parametersKSpace())
static Parameters defaultParameters()
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
LightDigitalSurface::Cell Cell
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
std::vector< Color > Colors
LightDigitalSurface::SCell SCell
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters ¶ms=parametersDigitalSurface())
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static Parameters defaultParameters()
static bool saveOBJ(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > digsurf, const TCellEmbedder &embedder, const RealVectors &normals, const Colors &diffuse_colors, std::string objfile, const Color &ambient_color=Color(32, 32, 32), const Color &diffuse_color=Color(200, 200, 255), const Color &specular_color=Color::White)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
CountedPtr< SH3::DigitalSurface > surface
DGtal is the top-level namespace which contains all DGtal functions and types.
TEST_CASE("Testing DigitalSurfaceRegularization")
ShortcutsGeometry< Z3i::KSpace > SHG3
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))