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>
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 )
315 std::tie( loo, l2 ) =
322 trace.
info() <<
"[Shrouds iteration " << nb
324 <<
"] dx <= " << loo <<
" l2=" << l2 << std::endl;
327 }
while ( loo > max_loo && nb < maxNb );
328 return std::make_pair( loo, l2 );
406 (
const double alpha = 1.0,
const double beta = 1.0,
const double randomization = 0.0 );
463 (
const double randomization = 0.0 );
479 typedef typename Container::Tracker Tracker;
490 for (
Vertex v = 0; v <
myT.size(); ++v )
497 if ( k == i )
continue;
500 Slice slice( tracker, i );
501 if ( ! slice.isClosed() ) {
502 trace.
error() <<
"[ShroudsRegularization::precomputeTopology]"
503 <<
" Shrouds works solely on closed surfaces."
507 auto start = slice.cstart();
523 while (
prev != start );
584 template <
typename TDigitalSurfaceContainer >
588 double eps = 0.00001 )
598 #include "DGtal/geometry/surfaces/ShroudsRegularization.ih"
604 #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
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::tuple< Scalar, Scalar, Scalar > c2_all(const std::pair< Vertex, Dimension > &v_i) const
std::vector< Vertex > myNext[3]
for each vertex, its successor on the slice of given axis direction.
std::pair< double, double > oneStepSquaredCurvatureMinimization(const double randomization=0.0)
std::vector< Vertex > myPrev[3]
for each vertex, its predessor on the slice of given axis direction.
Dimension orthDir(const Vertex v) const
double energy(const Regularization reg=Regularization::SQUARED_CURVATURE)
std::pair< double, double > oneStepAreaMinimization(const double randomization=0.0)
CountedPtr< IdxDigitalSurface > myPtrIdxSurface
the indexed digital surface (internal surface representation).
RealPoints positions() const
std::pair< Vertex, Dimension > next(const std::pair< Vertex, Dimension > &v_i) const
std::vector< RealPoint > RealPoints
std::pair< double, double > oneStepSnakeMinimization(const double alpha=1.0, const double beta=1.0, const double randomization=0.0)
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
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)
Scalar myBeta
The beta parameter for Snake second order regularization (~ curvature)
std::pair< Vertex, Dimension > prev(const std::pair< Vertex, Dimension > &v_i) const
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
RealVector::Component Scalar
ShroudsRegularization()
Default constructor. The object is not valid.
CountedPtr< SH3::DigitalSurface > surface
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
ShroudsRegularization< TDigitalSurfaceContainer > makeShroudsRegularization(CountedPtr< IndexedDigitalSurface< TDigitalSurfaceContainer > > surface, double eps=0.00001)
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...