31#if defined(ShroudsRegularization_RECURSES)
32#error Recursive header files inclusion detected in ShroudsRegularization.h
35#define ShroudsRegularization_RECURSES
37#if !defined ShroudsRegularization_h
39#define ShroudsRegularization_h
44#include "DGtal/base/Common.h"
45#include "DGtal/base/ConstAlias.h"
46#include "DGtal/topology/CanonicSCellEmbedder.h"
47#include "DGtal/topology/IndexedDigitalSurface.h"
48#include "DGtal/topology/DigitalSurface2DSlice.h"
72 template <
typename TDigitalSurfaceContainer>
81 typedef typename Container::KSpace
KSpace;
115 myPtrK( &surface->container().space() ),
140 for (
Vertex v = 0; v <
myT.size(); ++v )
143 const auto k =
myPtrK->sOrthDir( s );
144 myInsV[ v ] = embedder(
myPtrK->sDirectIncident( s, k ) );
145 myOutV[ v ] = embedder(
myPtrK->sIndirectIncident( s, k ) );
154 void setParams(
double eps,
double alpha = 1.0,
double beta = 1.0 )
191 const auto t =
myT[ v ];
199 for (
Vertex v = 0; v <
myT.size(); ++v )
216 std::pair<Vertex,Dimension>
next(
const std::pair<Vertex,Dimension> & v_i )
const
221 return std::make_pair( vn, in );
227 std::pair<Vertex,Dimension>
prev(
const std::pair<Vertex,Dimension> &v_i )
const
232 return std::make_pair( vp, ip );
248 for (
Vertex v = 0; v <
myT.size(); ++v )
261 Scalar c1(
const std::pair<Vertex,Dimension> &v_i )
const
265 return 1.0 / (din + dip);
271 std::tuple<Scalar,Scalar,Scalar>
c2_all(
const std::pair<Vertex,Dimension> &v_i )
const
275 return std::make_tuple( 2.0 / ( din * ( din + dip ) ),
277 2.0 / ( dip * ( din + dip ) ) );
303 std::pair<double,double>
305 const double randomization = 0.0,
306 const double max_loo = 0.0001,
307 const int maxNb = 100 )
314 std::tie( loo, l2 ) =
321 trace.
info() <<
"[Shrouds iteration " << nb
323 <<
"] dx <= " << loo <<
" l2=" << l2 << std::endl;
326 }
while ( loo > max_loo && nb < maxNb );
327 return std::make_pair( loo, l2 );
405 (
const double alpha = 1.0,
const double beta = 1.0,
const double randomization = 0.0 );
462 (
const double randomization = 0.0 );
478 typedef typename Container::Tracker Tracker;
489 for (
Vertex v = 0; v <
myT.size(); ++v )
496 if ( k == i )
continue;
499 Slice slice( tracker, i );
500 if ( ! slice.isClosed() ) {
501 trace.
error() <<
"[ShroudsRegularization::precomputeTopology]"
502 <<
" Shrouds works solely on closed surfaces."
506 auto start = slice.cstart();
522 while (
prev != start );
583 template <
typename TDigitalSurfaceContainer >
587 double eps = 0.00001 )
597#include "DGtal/geometry/surfaces/ShroudsRegularization.ih"
603#undef ShroudsRegularization_RECURSES
Aim: Smart pointer based on reference counts.
Aim: Represents a 2-dimensional slice in a DigitalSurface. In a sense, it is a 4-connected contour,...
Aim: Represents a digital surface with the topology of its dual surface. Its aim is to mimick the sta...
Aim: Implements basic operations that will be used in Point and Vector classes.
TEuclideanRing Component
Type for Vector elements.
Aim: Implements the Shrouds Regularization algorithm of Nielson et al .
ShroudsRegularization(CountedPtr< IdxDigitalSurface > surface)
std::vector< RealVector > RealVectors
Regularization
The enum class specifying the possible shrouds regularization.
double energySquaredCurvature()
std::tuple< double, double, double > getParams() const
std::pair< Vertex, Dimension > prev(const std::pair< Vertex, Dimension > &v_i) const
std::pair< double, double > oneStepAreaMinimization(const double randomization=0.0)
RealPoint position(const Vertex v) const
RealPoint position(const Vertex v, const double t) const
Vertex myInvalid
the index of the invalid vertex.
std::vector< IdxSurfel > IdxSurfelRange
Scalar myAlpha
The alpha parameter for Snake first order regularization (~ area)
void precomputeTopology()
Space::RealVector RealVector
std::vector< Vertex > myNext[3]
for each vertex, its successor on the slice of given axis direction.
std::tuple< Scalar, Scalar, Scalar > c2_all(const std::pair< Vertex, Dimension > &v_i) const
std::vector< Vertex > myPrev[3]
for each vertex, its predessor on the slice of given axis direction.
Dimension orthDir(const Vertex v) const
std::pair< double, double > regularize(const Regularization reg=Regularization::SQUARED_CURVATURE, const double randomization=0.0, const double max_loo=0.0001, const int maxNb=100)
double energy(const Regularization reg=Regularization::SQUARED_CURVATURE)
CountedPtr< IdxDigitalSurface > myPtrIdxSurface
the indexed digital surface (internal surface representation).
RealPoints positions() const
std::vector< RealPoint > RealPoints
const KSpace * myPtrK
A const pointer to the cellular space in which lives the digital surface.
void parameterize()
Computes the distances between the vertices along slices.
ShroudsRegularization< Container > Self
std::vector< Scalar > Scalars
Scalar myBeta
The beta parameter for Snake second order regularization (~ curvature)
void setParams(double eps, double alpha=1.0, double beta=1.0)
void enforceBounds()
Forces t to stay in ]0,1[.
Scalar c1(const std::pair< Vertex, Dimension > &v_i) const
BOOST_CONCEPT_ASSERT((concepts::CDigitalSurfaceContainer< TDigitalSurfaceContainer >))
std::vector< Dimension > myOrthDir
the direction axis of each dual edge.
IdxDigitalSurface::Surfel IdxSurfel
IndexedDigitalSurface< Container > IdxDigitalSurface
TDigitalSurfaceContainer Container
Space::RealPoint RealPoint
IdxDigitalSurface::Vertex IdxVertex
std::pair< double, double > oneStepSquaredCurvatureMinimization(const double randomization=0.0)
RealVector::Component Scalar
std::pair< Vertex, Dimension > next(const std::pair< Vertex, Dimension > &v_i) const
std::pair< double, double > oneStepSnakeMinimization(const double alpha=1.0, const double beta=1.0, const double randomization=0.0)
ShroudsRegularization()
Default constructor. The object is not valid.
DGtal is the top-level namespace which contains all DGtal functions and types.
ShroudsRegularization< TDigitalSurfaceContainer > makeShroudsRegularization(CountedPtr< IndexedDigitalSurface< TDigitalSurfaceContainer > > surface, double eps=0.00001)
DGtal::uint32_t Dimension
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: The digital surface container concept describes a minimal set of inner types and methods so as t...