DGtal 2.1.0
Loading...
Searching...
No Matches
DGtal::functions Namespace Reference

functions namespace gathers all DGtal functionsxs. More...

Namespaces

namespace  Hull2D
 Hull2D namespace gathers useful functions to compute and return the convex hull or the alpha-shape of a range of 2D points.
 
namespace  setops
 

Functions

template<typename T >
constexpr T const_pow (T b, unsigned int e)
 
template<typename T >
constexpr T const_middle (T K, unsigned int e)
 
template<typename Container , bool ordered>
bool isEqual (const Container &S1, const Container &S2)
 
template<typename Container >
bool isEqual (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
bool isSubset (const Container &S1, const Container &S2)
 
template<typename Container >
bool isSubset (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container & assignDifference (Container &S1, const Container &S2)
 
template<typename Container >
Container & assignDifference (Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container makeDifference (const Container &S1, const Container &S2)
 
template<typename Container >
Container makeDifference (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container & assignUnion (Container &S1, const Container &S2)
 
template<typename Container >
Container & assignUnion (Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container makeUnion (const Container &S1, const Container &S2)
 
template<typename Container >
Container makeUnion (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container & assignIntersection (Container &S1, const Container &S2)
 
template<typename Container >
Container & assignIntersection (Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container makeIntersection (const Container &S1, const Container &S2)
 
template<typename Container >
Container makeIntersection (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container & assignSymmetricDifference (Container &S1, const Container &S2)
 
template<typename Container >
Container & assignSymmetricDifference (Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container makeSymmetricDifference (const Container &S1, const Container &S2)
 
template<typename Container >
Container makeSymmetricDifference (const Container &S1, const Container &S2)
 
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool checkOnePoint (const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &aDSS)
 
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool checkPointsPosition (const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &aDSS)
 
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool checkPointsRemainder (const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &aDSS)
 
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool checkAll (const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &aDSS)
 
template<typename Position , typename Coordinate , typename PointVector , typename OutputIterator , typename PositionFunctor , typename TruncationFunctor1 , typename TruncationFunctor2 >
bool smartCHNextVertex (const Position &positionBound, const Coordinate &remainderBound, PointVector &X, Coordinate &rX, const PointVector &Y, const Coordinate &rY, PointVector &V, Coordinate &rV, OutputIterator ito, const PositionFunctor &pos, const TruncationFunctor1 &f1, const TruncationFunctor2 &f2)
 Procedure that computes the next (lower or upper) vertex of the left hull of a DSS.
 
template<typename PointVector , typename Coordinate , typename Position , typename PositionFunctor , typename OutputIterator >
PointVector smartCH (const PointVector &aFirstPoint, const Coordinate &aRemainderBound, const Position &aPositionBound, const PointVector &aStep, const Coordinate &aRStep, const PointVector &aShift, const Coordinate &aRShift, const PositionFunctor &aPositionFunctor, OutputIterator uIto, OutputIterator lIto)
 Procedure that computes the lower and upper left hull of a DSS of first point aFirstPoint, length aPositionBound, contained in a digital straight line described by aRStep, aRShift and aRemainderBound.
 
template<typename DSL , typename OutputIterator >
DSL::Vector smartCH (const DSL &aDSL, const typename DSL::Point &aFirstPoint, const typename DSL::Position &aLength, OutputIterator uIto, OutputIterator lIto)
 Procedure that computes the lower and upper left hull of a DSS of first point aFirstPoint, length aLength, contained in a DSL aDSL [Roussillon 2014 : [108]].
 
template<typename PointVector , typename Position , typename OutputIterator , typename TruncationFunctor1 , typename TruncationFunctor2 , typename PositionFunctor >
bool smartCHPreviousVertex (PointVector &X, const PointVector &Y, PointVector &V, const Position &aFirstPosition, const Position &aLastPosition, OutputIterator ito, const PositionFunctor &pos, const TruncationFunctor1 &f1, const TruncationFunctor2 &f2)
 Procedure that computes the previous vertex of the left hull of a DSS of main direction vector V , first upper leaning point U and first positive Bezout point L. The computation stops as soon as a computed vertex is located before aLastPosition.

 
template<typename PointVector , typename Position , typename PositionFunctor , typename OutputIterator >
PointVector reversedSmartCH (PointVector U, PointVector L, PointVector V, const Position &aFirstPosition, const Position &aLastPosition, const PositionFunctor &aPositionFunctor, OutputIterator uIto, OutputIterator lIto)
 Procedure that computes the lower and upper left hull of the left subsegment of a greater DSS characterized by the first upper leaning point U, the first positive Bezout point L and its direction vector V. Note that the so-called left subsegment is bounded on the one hand by the first point of the DSS located at aFirstPosition and on the other hand by the point located at position aLastPosition.
 
template<typename DSS , typename OutputIterator >
DSS::Vector reversedSmartCH (const DSS &aDSS, const typename DSS::Position &aPositionBound, OutputIterator uIto, OutputIterator lIto)
 Procedure that computes the lower and upper left hull of the left subsegment of a greater DSS aDSS. Note that the so-called left subsegment is bounded on the one hand by the first point of aDSS and on the other hand by the point located at position aPositionBound [Roussillon 2014 : [108]].
 
template<typename TPoint >
DGtal::int64_t computeAffineDimension (const std::vector< TPoint > &X, const double tolerance=1e-12)
 
template<typename TPoint >
std::vector< std::size_t > computeAffineSubset (const std::vector< TPoint > &X, const double tolerance=1e-12)
 
template<typename TPoint , typename TIndexRange >
static std::vector< std::size_t > computeAffineSubset (const std::vector< TPoint > &X, const TIndexRange &I, const double tolerance=1e-12)
 
template<typename TPoint , typename TInputPoint >
void getAffineBasis (TInputPoint &o, std::vector< TPoint > &basis, const std::vector< TInputPoint > &X, const double tolerance=1e-12)
 
template<typename TPoint , typename TInputPoint , typename TIndexRange >
static void getAffineBasis (TInputPoint &o, std::vector< TPoint > &basis, const std::vector< TInputPoint > &X, const TIndexRange &I, const double tolerance=1e-12)
 
template<typename TPoint >
TPoint computeIndependentVector (const std::vector< TPoint > &basis, const double tolerance=1e-12)
 
template<typename TPoint >
static void getCompleteBasis (std::vector< TPoint > &basis, bool normal_vector, const double tolerance=1e-12)
 
template<typename TPoint >
static TPoint computeOrthogonalVectorToBasis (const std::vector< TPoint > &basis)
 
template<typename TPoint , typename TInputPoint , typename TIndexRange >
static void getOrthogonalVector (TPoint &w, const std::vector< TInputPoint > &X, const TIndexRange &I, const double tolerance=1e-12)
 
template<typename TPoint , typename TInputPoint >
static void getOrthogonalVector (TPoint &w, const std::vector< TInputPoint > &X, const double tolerance=1e-12)
 
template<typename TPoint , typename TInputPoint >
static void getOrthogonalLatticeBasis (std::vector< TPoint > &B, const TInputPoint &N, bool shortened=false)
 
template<typename TPoint >
TPoint computeSimplifiedVector (const TPoint &v)
 
template<typename T >
power (const T &aVal, const unsigned int exponent)
 
template<typename T >
roundToUpperPowerOfTwo (const T &n)
 
template<typename T >
abs (const T &a)
 
template<typename T >
square (T x)
 
template<typename T >
cube (T x)
 
template<typename TComponent >
void negate (std::vector< TComponent > &V)
 
template<typename TComponent >
bool equals (const std::vector< TComponent > &a, const std::vector< TComponent > &b)
 
template<typename T , typename U >
DGtal::ArithmeticConversionTraits< T, U >::type dotProduct (const std::vector< T > &a, const std::vector< U > &b)
 
double dotProduct (const std::vector< BigInteger > &a, const std::vector< double > &b)
 
double dotProduct (const std::vector< double > &a, const std::vector< BigInteger > &b)
 
template<typename T , typename U >
std::vector< typename DGtal::ArithmeticConversionTraits< T, U >::type > crossProduct (const std::vector< T > &a, const std::vector< U > &b)
 
template<typename T , typename U , typename Op2 >
std::vector< typename DGtal::ArithmeticConversionTraits< T, U >::type > apply (const std::vector< T > &a, const std::vector< U > &b, Op2 op2)
 
template<typename T >
squaredNormL2 (const std::vector< T > &a)
 
template<typename T >
normL1 (const std::vector< T > &a)
 
template<typename T >
normLoo (const std::vector< T > &a)
 
template<typename TOutput , typename T >
void getSquaredNormL2 (TOutput &n, const std::vector< T > &a)
 
template<typename TOutput , DGtal::Dimension dim, typename TEuclideanRing , typename TContainer >
void getSquaredNormL2 (TOutput &n, const DGtal::PointVector< dim, TEuclideanRing, TContainer > &a)
 
template<typename TComponent , DGtal::Dimension TN, typename TInternalNumber >
void getDeterminantBareiss (TInternalNumber &result, const SimpleMatrix< TComponent, TN, TN > &matrix)
 
template<typename TComponent , typename TInternalNumber >
void getDeterminantBareiss (TInternalNumber &result, const std::vector< std::vector< TComponent > > &matrix)
 
template<typename TComponent >
std::vector< std::vector< TComponent > > matrixAsVectorVector (std::size_t m, std::size_t n, const std::vector< TComponent > &c)
 
template<typename TComponent , DGtal::Dimension TM, DGtal::Dimension TN>
std::vector< std::vector< TComponent > > matrixAsVectorVector (const SimpleMatrix< TComponent, TM, TN > &M)
 
template<typename TComponent , typename TDouble = long double>
std::vector< std::vector< TComponent > > computeLLLBasis (const std::vector< std::vector< TComponent > > &B, TDouble delta=0.75)
 
template<typename TComponent , typename TDouble = long double>
void reduceBasisWithLLL (std::vector< std::vector< TComponent > > &B, TDouble delta=0.75)
 
template<typename TComponent >
TComponent makePrimitive (std::vector< TComponent > &N)
 
template<typename TComponent >
TComponent extendedGcd (TComponent &x, TComponent &y, TComponent a, TComponent b)
 
template<typename TComponent >
TComponent extendedGcd (std::vector< TComponent > &C, const std::vector< TComponent > &A)
 
template<typename TComponent >
std::vector< std::vector< TComponent > > computeOrthogonalLattice (std::vector< TComponent > N)
 
template<typename TComponent >
bool shortenVectors (std::vector< TComponent > &u, std::vector< TComponent > &v)
 
template<typename TComponent >
std::size_t shortenBasis (std::vector< std::vector< TComponent > > &B)
 
template<typename TKSpace , typename TCellContainer , typename CellConstIterator , typename CellMapIteratorPriority >
uint64_t collapse (CubicalComplex< TKSpace, TCellContainer > &K, CellConstIterator S_itB, CellConstIterator S_itE, const CellMapIteratorPriority &priority, bool hintIsSClosed=false, bool hintIsKClosed=false, bool verbose=false)
 
template<typename TKSpace , typename TCellContainer , typename BdryCellOutputIterator , typename InnerCellOutputIterator >
void filterCellsWithinBounds (const CubicalComplex< TKSpace, TCellContainer > &K, const typename TKSpace::Point &kLow, const typename TKSpace::Point &kUp, BdryCellOutputIterator itBdry, InnerCellOutputIterator itInner)
 
template<typename TObject , typename TKSpace , typename TCellContainer >
std::unique_ptr< TObject > objectFromSpels (const CubicalComplex< TKSpace, TCellContainer > &C)
 
template<typename TComplex >
NeighborhoodConfiguration getSpelNeighborhoodConfigurationOccupancy (const TComplex &input_complex, const typename TComplex::Point &center, const std::unordered_map< typename TComplex::Point, NeighborhoodConfiguration > &mapPointToMask)
 
DGtal::CountedPtr< boost::dynamic_bitset<> > loadTable (const std::string &input_filename, const unsigned int known_size, const bool compressed=true)
 
template<unsigned int dimension = 3>
DGtal::CountedPtr< boost::dynamic_bitset<> > loadTable (const std::string &input_filename, const bool compressed=true)
 
template<typename TPoint >
DGtal::CountedPtr< std::unordered_map< TPoint, NeighborhoodConfiguration > > mapZeroPointNeighborhoodToConfigurationMask ()
 
template<typename TObject , typename TMap >
void generateSimplicityTable (const typename TObject::DigitalTopology &dt, TMap &map)
 
template<typename TVoxelComplex , typename TMap >
void generateVoxelComplexTable (TMap &map, std::function< bool(const TVoxelComplex &, const typename TVoxelComplex::Cell &) > skelFunction)
 
template<typename TComplex >
TComplex asymetricThinningScheme (TComplex &vc, std::function< std::pair< typename TComplex::Cell, typename TComplex::Data >(const typename TComplex::Clique &) > Select, std::function< bool(const TComplex &, const typename TComplex::Cell &) > Skel, bool verbose=false)
 
template<typename TComplex >
TComplex persistenceAsymetricThinningScheme (TComplex &vc, std::function< std::pair< typename TComplex::Cell, typename TComplex::Data >(const typename TComplex::Clique &) > Select, std::function< bool(const TComplex &, const typename TComplex::Cell &) > Skel, uint32_t persistence, bool verbose=false)
 
template<typename TComplex >
std::pair< typename TComplex::Cell, typename TComplex::Data > selectFirst (const typename TComplex::Clique &clique)
 
template<typename TComplex >
std::pair< typename TComplex::Cell, typename TComplex::Data > selectRandom (const typename TComplex::Clique &clique)
 
template<typename TComplex , typename TRandomGenerator >
std::pair< typename TComplex::Cell, typename TComplex::Data > selectRandom (const typename TComplex::Clique &clique, TRandomGenerator &gen)
 
template<typename TDistanceTransform , typename TComplex >
std::pair< typename TComplex::Cell, typename TComplex::Data > selectMaxValue (const TDistanceTransform &dist_map, const typename TComplex::Clique &clique)
 
template<typename TComplex >
bool skelUltimate (const TComplex &vc, const typename TComplex::Cell &cell)
 
template<typename TComplex >
bool skelEnd (const TComplex &vc, const typename TComplex::Cell &cell)
 
template<typename TComplex >
bool skelSimple (const TComplex &vc, const typename TComplex::Cell &cell)
 
template<typename TComplex >
bool skelIsthmus (const TComplex &vc, const typename TComplex::Cell &cell)
 
template<typename TComplex >
bool oneIsthmus (const TComplex &vc, const typename TComplex::Cell &cell)
 
template<typename TComplex >
bool twoIsthmus (const TComplex &vc, const typename TComplex::Cell &cell)
 
template<typename TComplex >
bool skelWithTable (const boost::dynamic_bitset<> &table, const std::unordered_map< typename TComplex::Point, unsigned int > &pointToMaskMap, const TComplex &vc, const typename TComplex::Cell &cell)
 
template<typename TObject >
bool isZeroSurface (const TObject &small_obj)
 
template<typename TObject >
bool isOneSurface (const TObject &small_obj)
 
template<typename TObject >
std::vector< TObject > connectedComponents (const TObject &input_obj, bool verbose)
 
template<typename TComplex , typename TDistanceTransform = DistanceTransformation<Z3i::Space, Z3i::DigitalSet, ExactPredicateLpSeparableMetric<Z3i::Space, 3>>>
TComplex thinningVoxelComplex (TComplex &vc, const std::string &skel_type_str, const std::string &skel_select_type_str, const std::string &tables_folder, const int &persistence=0, const TDistanceTransform *distance_transform=nullptr, const bool profile=false, const bool verbose=false)
 

Detailed Description

functions namespace gathers all DGtal functionsxs.

Function Documentation

◆ abs()

template<typename T >
T DGtal::functions::abs ( const T &  a)

Return the absolute value of an instance of type T.

Template Parameters
Tthe type of elements to compare (model of boost::LessThanComparable).
Parameters
afirst value
Returns
the absolute value |a|.

Definition at line 116 of file BasicMathFunctions.h.

117 {
118 BOOST_CONCEPT_ASSERT((boost::LessThanComparable<T>));
119 if (a<0)
120 return -a;
121 else
122 return a;
123 }
Go to http://www.sgi.com/tech/stl/LessThanComparable.html.
Definition Boost.dox:48

◆ apply()

template<typename T , typename U , typename Op2 >
std::vector< typename DGtal::ArithmeticConversionTraits< T, U >::type > DGtal::functions::apply ( const std::vector< T > &  a,
const std::vector< U > &  b,
Op2  op2 
)

Applies the binary operation op2 to every pair of elements (a[i],b[i]) and returns the resulting range of values op2([a[0],b[0]), ..., op2([a[n-1],b[n-1]).

Template Parameters
Tthe number type of the left operand vector.
Uthe number type of the right operand vector.
Op2the type for the binary operator.
Parameters
athe range of values acting as left operands.
bthe range of values acting as rights operands.
op2the binary operator (T,U) -> V, where V is the best possible type combining T and U.

◆ assignDifference() [1/2]

template<typename Container , bool ordered>
Container & DGtal::functions::assignDifference ( Container &  S1,
const Container &  S2 
)

Set difference operation. Updates the set S1 as S1 - S2.

Parameters
[in,out]S1an input set, S1 - S2 as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 896 of file SetFunctions.h.

897 {
898 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
899 BOOST_STATIC_CONSTANT
900 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
901 BOOST_STATIC_CONSTANT
902 ( bool, isOrdered = ordered
904
906 ::assignDifference( S1, S2 );
907 }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...

Referenced by makeDifference(), and DGtal::functions::setops::operator-=().

◆ assignDifference() [2/2]

template<typename Container >
Container & DGtal::functions::assignDifference ( Container &  S1,
const Container &  S2 
)

Set difference operation. Updates the set S1 as S1 - S2.

Parameters
[in,out]S1an input set, S1 - S2 as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 918 of file SetFunctions.h.

919 {
920 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
921 BOOST_STATIC_CONSTANT
922 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
923 BOOST_STATIC_CONSTANT
924 ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
925
927 ::assignDifference( S1, S2 );
928 }

◆ assignIntersection() [1/2]

template<typename Container , bool ordered>
Container & DGtal::functions::assignIntersection ( Container &  S1,
const Container &  S2 
)

Set intersection operation. Updates the set S1 as \( S1 \cap S2 \).

Parameters
[in,out]S1an input set, \( S1 \cap S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1082 of file SetFunctions.h.

1083 {
1084 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1085 BOOST_STATIC_CONSTANT
1086 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1087 BOOST_STATIC_CONSTANT
1088 ( bool, isOrdered = ordered
1089 || ( isAssociative && IsOrderedAssociativeContainer< Container >::value ) );
1090
1092 ::assignIntersection( S1, S2 );
1093 }

Referenced by makeIntersection(), and DGtal::functions::setops::operator&=().

◆ assignIntersection() [2/2]

template<typename Container >
Container & DGtal::functions::assignIntersection ( Container &  S1,
const Container &  S2 
)

Set intersection operation. Updates the set S1 as \( S1 \cap S2 \).

Parameters
[in,out]S1an input set, \( S1 \cap S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1104 of file SetFunctions.h.

1105 {
1106 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1107 BOOST_STATIC_CONSTANT
1108 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1109 BOOST_STATIC_CONSTANT
1110 ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
1111
1113 ::assignIntersection( S1, S2 );
1114 }

◆ assignSymmetricDifference() [1/2]

template<typename Container , bool ordered>
Container & DGtal::functions::assignSymmetricDifference ( Container &  S1,
const Container &  S2 
)

Set symmetric difference operation. Updates the set S1 as \( S1 \Delta S2 \).

Parameters
[in,out]S1an input set, \( S1 \Delta S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1176 of file SetFunctions.h.

1177 {
1178 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1179 BOOST_STATIC_CONSTANT
1180 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1181 BOOST_STATIC_CONSTANT
1182 ( bool, isOrdered = ordered
1183 || ( isAssociative && IsOrderedAssociativeContainer< Container >::value ) );
1184
1187 }

Referenced by makeSymmetricDifference(), and DGtal::functions::setops::operator^=().

◆ assignSymmetricDifference() [2/2]

template<typename Container >
Container & DGtal::functions::assignSymmetricDifference ( Container &  S1,
const Container &  S2 
)

Set symmetric difference operation. Updates the set S1 as \( S1 \Delta S2 \).

Parameters
[in,out]S1an input set, \( S1 \Delta S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1198 of file SetFunctions.h.

1199 {
1200 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1201 BOOST_STATIC_CONSTANT
1202 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1203 BOOST_STATIC_CONSTANT
1204 ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
1205
1208 }

◆ assignUnion() [1/2]

template<typename Container , bool ordered>
Container & DGtal::functions::assignUnion ( Container &  S1,
const Container &  S2 
)

Set union operation. Updates the set S1 as \( S1 \cup S2 \).

Parameters
[in,out]S1an input set, \( S1 \cup S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 990 of file SetFunctions.h.

991 {
992 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
993 BOOST_STATIC_CONSTANT
994 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
995 BOOST_STATIC_CONSTANT
996 ( bool, isOrdered = ordered
998
1000 ::assignUnion( S1, S2 );
1001 }

Referenced by makeUnion(), and DGtal::functions::setops::operator|=().

◆ assignUnion() [2/2]

template<typename Container >
Container & DGtal::functions::assignUnion ( Container &  S1,
const Container &  S2 
)

Set union operation. Updates the set S1 as \( S1 \cup S2 \).

Parameters
[in,out]S1an input set, \( S1 \cup S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1012 of file SetFunctions.h.

1013 {
1014 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1015 BOOST_STATIC_CONSTANT
1016 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1017 BOOST_STATIC_CONSTANT
1018 ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
1019
1021 ::assignUnion( S1, S2 );
1022 }

◆ asymetricThinningScheme()

template<typename TComplex >
TComplex DGtal::functions::asymetricThinningScheme ( TComplex &  vc,
std::function< std::pair< typename TComplex::Cell, typename TComplex::Data >(const typename TComplex::Clique &) >  Select,
std::function< bool(const TComplex &, const typename TComplex::Cell &) >  Skel,
bool  verbose = false 
)

◆ checkAll()

template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool DGtal::functions::checkAll ( const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &  aDSS)

Checks whether a DSS is valid or not. NB: in logarithmic time (in order to check that a and b are relatively prime)

Parameters
aDSSany DSS
Returns
'true' if valid, 'false' otherwise.

◆ checkOnePoint()

template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool DGtal::functions::checkOnePoint ( const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &  aDSS)

Checks the validity of the DSS when it contains only one point.

Parameters
aDSSany DSS
Precondition
the DSS contains only one point
Returns
'true' if the DSS is valid, 'false' otherwise.

◆ checkPointsPosition()

template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool DGtal::functions::checkPointsPosition ( const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &  aDSS)

Checks that the difference between two extremal upper (resp. lower) leaning points is equal to the direction vector (a,b) scaled by an integer. Checks that there is no pattern between end points and extremal leaning points.

Parameters
aDSSany DSS
Precondition
the DSS contains more than one point, ie a and b are not both null.
Returns
'true' if ok, 'false' otherwise.

◆ checkPointsRemainder()

template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool DGtal::functions::checkPointsRemainder ( const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &  aDSS)

Checks the consistency between the parameters and the leaning points: first and last upper leaning points should have a remainder equal to mu while firsta and last lower leaning points should have a remainder equal to mu + omega - 1. Moreover, front and back points should have a remainder lying within the range [mu, mu+omega[.

Parameters
aDSSany DSS
Precondition
the DSS contains more than one point, ie a and b are not both null.
Returns
'true' if this property is fulfilled, 'false' otherwise.

◆ collapse()

template<typename TKSpace , typename TCellContainer , typename CellConstIterator , typename CellMapIteratorPriority >
uint64_t DGtal::functions::collapse ( CubicalComplex< TKSpace, TCellContainer > &  K,
CellConstIterator  S_itB,
CellConstIterator  S_itE,
const CellMapIteratorPriority &  priority,
bool  hintIsSClosed = false,
bool  hintIsKClosed = false,
bool  verbose = false 
)

Collapse a user-specified part of complex K, collapsing cells following priority [priority], in a decreasing sequence until no more collapse is feasible. The range [S_itb,S_itE) provides the starting cells, generally (but not compulsory) maximal cells. The resulting complex is guaranteed to keep the same homotopy type (a kind of topology equivalence).

Note
Cells whose data has been marked as FIXED are not removed.
Only cells that are in the closure of [S_itb,S_itE) may be removed, and only if they are not marked as FIXED.
Advanced:
If you use a DefaultCellMapIteratorPriority object as priority, then the VALUE part of each cell data defines the priority (the highest value the soonest are these cells collapsed). You may thus fill these cell values before calling this method.
Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
CellConstIteratorany forward const iterator on Cell.
CellMapIteratorPriorityany type defining a method 'bool operator()( const Cell&, const Cell&) const'. Defines the order in which cells are collapsed.
See also
DefaultCellMapIteratorPriority
Parameters
[in,out]Kthe complex that is collapsed.
S_itBthe start of a range of cells which is included in [K].
S_itEthe end of a range of cells which is included in [K].
prioritythe object that assign a priority to each cell.
hintIsSClosedindicates if [S_itb,S_ite) is a closed set (faster in this case).
hintIsKClosedindicates that complex K is closed.
verboseoutputs some information during processing when 'true'.
Returns
the number of cells removed from complex K.
See also
topology/cubical-complex-collapse.cpp

Referenced by main(), main(), SCENARIO(), and SCENARIO().

◆ computeAffineDimension()

template<typename TPoint >
DGtal::int64_t DGtal::functions::computeAffineDimension ( const std::vector< TPoint > &  X,
const double  tolerance = 1e-12 
)

Given a range of points X, returns the affine dimension of its spanned affine subspace.

Template Parameters
TPointany type of lattice point or real point.
Parameters
Xthe range of input points (may be lattice points or not).
tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).
Returns
the affine dimension of X.
Note
Complexity is \(O( m n^2 )\), where m=Cardinal(X) and n=dimension.

Definition at line 1068 of file AffineGeometry.h.

1069 {
1070 return AffineGeometry<TPoint>::affineDimension( X, tolerance );
1071 }
Aim: Utility class to determine the affine geometry of an input set of points. It provides exact resu...

References DGtal::AffineGeometry< TPoint >::affineDimension().

Referenced by checkAffineGeometry(), SCENARIO(), and SCENARIO().

◆ computeAffineSubset() [1/2]

template<typename TPoint >
std::vector< std::size_t > DGtal::functions::computeAffineSubset ( const std::vector< TPoint > &  X,
const double  tolerance = 1e-12 
)

Given a range of points X, returns a subset of these points that form an affine basis of X. Equivalently it is a simplex whose affine space spans all the points of X.

Template Parameters
TPointany type of lattice point or real point.
Parameters
Xthe range of input points (may be lattice points or not).
tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).
Returns
a subset of these points as a range of indices.
Note
Complexity is \(O( m n^2 )\), where m=Cardinal(X) and n=dimension.

Definition at line 1089 of file AffineGeometry.h.

1090 {
1091 return AffineGeometry<TPoint>::affineSubset( X, tolerance );
1092 }

References DGtal::AffineGeometry< TPoint >::affineSubset().

Referenced by checkAffineGeometry(), SCENARIO(), and SCENARIO().

◆ computeAffineSubset() [2/2]

template<typename TPoint , typename TIndexRange >
static std::vector< std::size_t > DGtal::functions::computeAffineSubset ( const std::vector< TPoint > &  X,
const TIndexRange &  I,
const double  tolerance = 1e-12 
)
static

Given a range of points X and a subset of it given by indices I, returns a subset of these points that form an affine basis of X[I]. Equivalently it is a simplex whose affine space spans all the points of X[I].

Template Parameters
TPointany type of lattice point or real point.
TIndexRangeany type of range of indices that specifies the subset of points of interest.
Parameters
[in]Xthe range of input points (may be lattice points or not).
[in]Ithe range of indices specifying the subset of interest.
[in]tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).
Returns
a subset of these points as a range of indices.
Note
Complexity is \(O( m n^2 )\), where m=Cardinal(X) and n=dimension.

Definition at line 1117 of file AffineGeometry.h.

1120 {
1121 return AffineGeometry<TPoint>::affineSubset( X, I, tolerance );
1122 }

References DGtal::AffineGeometry< TPoint >::affineSubset().

◆ computeIndependentVector()

template<typename TPoint >
TPoint DGtal::functions::computeIndependentVector ( const std::vector< TPoint > &  basis,
const double  tolerance = 1e-12 
)

Given a partial basis of vectors, returns a canonic unit vector that is independent.

Template Parameters
TPointany type of lattice point or real point.
Parameters
[in]basisa range of independent vectors that defines a partial basis of the space.
[in]tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).
Returns
a canonic unit vector independent of all vectors of basis, or the null vector if the basis was not partial.

Definition at line 1202 of file AffineGeometry.h.

1204 {
1205 return AffineGeometry<TPoint>::independentVector( basis, tolerance );
1206 }

References DGtal::AffineGeometry< TPoint >::independentVector().

Referenced by checkAffineGeometry(), SCENARIO(), and SCENARIO().

◆ computeLLLBasis()

template<typename TComponent , typename TDouble = long double>
std::vector< std::vector< TComponent > > DGtal::functions::computeLLLBasis ( const std::vector< std::vector< TComponent > > &  B,
TDouble  delta = 0.75 
)

Computes the \( \delta \)-LLL-reduced lattice of the input lattice B (represented as an integer matrix B whose rows are the lattice vectors), using the LLL algorithm.

Such lattice has "almost" orthogonal vectors, while minimizing their norm at most as possible.

Note
A lattice \((b_1,...,b_m)\) is \( \delta \)-LLL-reduced if (1), for any \( i>j, |\mu_{i,j}| \le 1/2 \), and (2), for any \( i<m , \delta |b^*_i|^2 \le |b^*_{i+1}+mu_{i+1,i} b^*_i|^2 \). Here \( \mu_{i,j} := \langle b_i, b_j^* \rangle / \langle b_j^*, b_j^* \rangle \) and \( b^*_i \) is the i-th vector of the Gram-Schmidt orthogonalisation of \( (b_1, ..., b_m) \).
Template Parameters
TComponentthe integer type of each coefficient of the integer matrix B.
TDoublethe floating-point number type used for the Gram-Schmidt orthogonalisation of B.
Parameters
[in]Bthe lattice of m vectors in Z^n represented as a mxn matrix.
[in]deltathe parameter \( \delta \) of LLL-algorithm, which should be between 0.25 and 1 (value 0.99 is default in sagemath).
Returns
the \( delta \)-LLL-reduced lattice of B.
Warning
Computations requiring Gram-Schmidt orthogonalisation uses the floating-point number type TDouble.

Referenced by testLLL().

◆ computeOrthogonalLattice()

template<typename TComponent >
std::vector< std::vector< TComponent > > DGtal::functions::computeOrthogonalLattice ( std::vector< TComponent >  N)

Computes a basis of the orthogonal lattice to the vector N, i.e. it has n-1 vectors if N had n components. It essentially follows https://math.stackexchange.com/questions/1049608/lattice-generated-by-vectors-orthogonal-to-an-integer-vector

Note
If N is a primitive 3D vector, then the returned basis has two vectors, whose cross product is N or -N.
Template Parameters
TComponentthe integer type for the input vector and for computations.
Parameters
[in]Nthe input normal vector, which should be non null. Even if N is not primitive, it is considered primitive in the function.
Returns
a basis \( (u_1, \dots, u_{n-1}) \) such that \( u_i \cdot N = 0 \). Because N is made primitive, the orthogonal lattice is the finest possible for the d-1 dimensional space. The returned basis is in echelon form.

Referenced by DGtal::AffineGeometry< TPoint >::orthogonalLatticeBasis(), and testOrthogonalLattice().

◆ computeOrthogonalVectorToBasis()

template<typename TPoint >
static TPoint DGtal::functions::computeOrthogonalVectorToBasis ( const std::vector< TPoint > &  basis)
static

Given d-1 independent vectors in dD, outputs a vector that is orthogonal to each of them. This function signature allows automatic internal type computations deduction.

Note
In 3D, given two independent vectors as input, then the added vector is the (reduced for integers, normalized with 1 squared L2-norm for floats) cross product of these two vectors. In nD, it is thus a generalization of the cross product.
Template Parameters
TPointany type of lattice point or real point.
Parameters
[in]basisa range of independent vectors of size dimension-1.
Returns
an orthogonal vector to every vector of basis (reduced or normalized depending on integer/floating-point number type).

Definition at line 1262 of file AffineGeometry.h.

1263 {
1264 if ( ( basis.size() + 1 ) != TPoint::dimension ) return TPoint::zero;
1266 }

References DGtal::AffineGeometry< TPoint >::orthogonalVector().

Referenced by checkAffineGeometry(), SCENARIO(), and SCENARIO().

◆ computeSimplifiedVector()

template<typename TPoint >
TPoint DGtal::functions::computeSimplifiedVector ( const TPoint &  v)

Given a vector, returns the aligned vector with its component simplified by the gcd of all components (when the components are integers) or the aligned vector with a squared L2-norm of 1 (when the components are floating-point numbers).

Template Parameters
TPointany type of lattice point or real point.
Parameters
[in]vany vector.
Returns
a simplified vector aligned with v.

Definition at line 1394 of file AffineGeometry.h.

1395 {
1397 }

References DGtal::AffineGeometry< TPoint >::simplifiedVector().

Referenced by checkAffineGeometry(), SCENARIO(), and SCENARIO().

◆ connectedComponents()

template<typename TObject >
std::vector< TObject > DGtal::functions::connectedComponents ( const TObject &  input_obj,
bool  verbose 
)

Get all connected components of the input object.

Template Parameters
TObjectObject Type
Parameters
input_objinput object
verboseflag to be verbose at execution
Returns
vector of TObject containing the different connected components of the object.
See also
ObjectBoostGraphInterface.h

◆ const_middle()

template<typename T >
constexpr T DGtal::functions::const_middle ( K,
unsigned int  e 
)
constexpr
Template Parameters
Tany model of bounded number.
Parameters
Ka non negative number
ea non negative integer
Returns
the index of the middle element in the e-dimensional array of width \( 2K+1 \), computed at compile time.
auto m1 = functions::const_middle( 1, 2 ); // 4, dans le tableau 3x3
auto m2 = functions::const_middle( 2, 2 ); // 12, dans le tableau 5x5
auto m3 = functions::const_middle( 1, 3 ); // 13, dans le tableau 3x3x3
constexpr T const_middle(T K, unsigned int e)

Definition at line 75 of file ConstExpressions.h.

75 {
76 return e <= 1
77 ? T( K )
78 : K * const_pow( 2 * K + 1, e - 1 ) + const_middle( K, e - 1 );
79 }
constexpr T const_pow(T b, unsigned int e)
KSpace K

References const_middle(), const_pow(), and K.

Referenced by const_middle().

◆ const_pow()

template<typename T >
constexpr T DGtal::functions::const_pow ( b,
unsigned int  e 
)
constexpr
Template Parameters
Tany model of bounded number.
Parameters
ba number
ea non negative integer
Returns
the constant expression \( b^e \), computed at compile time.
auto v = functions::const_pow( 5, 3 ); // 5^3

Definition at line 60 of file ConstExpressions.h.

60 {
61 return e == 0 ? T(1) : b * const_pow( b, e - 1 );
62 }

References const_pow().

Referenced by const_middle(), and const_pow().

◆ crossProduct()

template<typename T , typename U >
std::vector< typename DGtal::ArithmeticConversionTraits< T, U >::type > DGtal::functions::crossProduct ( const std::vector< T > &  a,
const std::vector< U > &  b 
)

Overloaded cross product operator for vector of numbers.

Template Parameters
Tthe number type of the left operand vector.
Uthe number type of the right operand vector.
Parameters
[in]athe left vector (must be of size 3 )
[in]bthe right vector (must be of size 3 )
Returns
the cross product of a and b (a vector of size 3 ).

Referenced by testOrthogonalLattice().

◆ cube()

template<typename T >
T DGtal::functions::cube ( x)
inline

Returns the value x * x * x

Template Parameters
Ta type with the multiply operator.
Parameters
xany value
Returns
the value x * x * x

Definition at line 144 of file BasicMathFunctions.h.

145 { return x * x * x; }

◆ dotProduct() [1/3]

double DGtal::functions::dotProduct ( const std::vector< BigInteger > &  a,
const std::vector< double > &  b 
)

Overloaded dot product operator for vector of big integers with vector of doubles.

Parameters
[in]athe left vector
[in]bthe right vector
Returns
the dot product of a and b.

◆ dotProduct() [2/3]

double DGtal::functions::dotProduct ( const std::vector< double > &  a,
const std::vector< BigInteger > &  b 
)

Overloaded dot product operator for vector of big integers with vector of doubles.

Parameters
[in]athe left vector
[in]bthe right vector
Returns
the dot product of a and b.

◆ dotProduct() [3/3]

template<typename T , typename U >
DGtal::ArithmeticConversionTraits< T, U >::type DGtal::functions::dotProduct ( const std::vector< T > &  a,
const std::vector< U > &  b 
)

Overloaded dot product operator for vector of numbers.

Template Parameters
Tthe number type of the left operand vector.
Uthe number type of the right operand vector.
Parameters
[in]athe left vector
[in]bthe right vector
Returns
the dot product of a and b, a scalar value in the "best possible type" according to T and U.

Referenced by testOrthogonalLattice().

◆ equals()

template<typename TComponent >
bool DGtal::functions::equals ( const std::vector< TComponent > &  a,
const std::vector< TComponent > &  b 
)

Returns 'true' iff all the components of the two vectors are equal.

Template Parameters
TComponentthe scalar type of each component.
Parameters
[in]athe left vector (same size)
[in]bthe right vector (same size)
Returns
'true' iff all the components of the two vectors are equal.

Referenced by testOrthogonalLattice().

◆ extendedGcd() [1/2]

template<typename TComponent >
TComponent DGtal::functions::extendedGcd ( std::vector< TComponent > &  C,
const std::vector< TComponent > &  A 
)

Extended Eucliden algorithm to compute the gcd g of n integers A as will as the vector of integers C such that C[0]*A[0]+...+C[n-1]*A[n-1]=g, where g is the gcd of A[0],...,A[n-1].

Parameters
[out]Cthe array of integers such that C[0]*A[0]+...+C[n-1]*A[n-1]=g
[in]Athe array of input integers.
Returns
the greatest common divisor g of A, i.e. gcd( A[0], gcd( A[1], ... )).

◆ extendedGcd() [2/2]

template<typename TComponent >
TComponent DGtal::functions::extendedGcd ( TComponent &  x,
TComponent &  y,
TComponent  a,
TComponent  b 
)

Extended Eucliden algorithm to compute the gcd g of two integers a and b as well as two other integers x and y such that a*x+b*y=g, where g the gcd of a and b.

Parameters
[out]x,ytwo integers x and y such that a*x+b*y=g.
[in]a,bany pair of integers.
Returns
the greatest common divisor g of a and b, i.e. gcd( a, b ).

◆ filterCellsWithinBounds()

template<typename TKSpace , typename TCellContainer , typename BdryCellOutputIterator , typename InnerCellOutputIterator >
void DGtal::functions::filterCellsWithinBounds ( const CubicalComplex< TKSpace, TCellContainer > &  K,
const typename TKSpace::Point &  kLow,
const typename TKSpace::Point &  kUp,
BdryCellOutputIterator  itBdry,
InnerCellOutputIterator  itInner 
)

Computes the cells of the given complex K that lies on the boundary or inside the parallelepiped specified by bounds kLow and kUp.

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
BdryCellOutputIteratorany output iterator on TCubicalComplex::Cell.
InnerCellOutputIteratorany output iterator on TCubicalComplex::Cell.
Parameters
[in]Kany cubical complex.
[in]kLowany Khalimsky coordinate representing the lowest possible cell.
[in]kUpany Khalimsky coordinate representing the uppermost possible cell.
[in,out]itBdryAn output iterator on Cell that outputs all the cells of K that lie on the boundary of the parallelepiped specified by bounds kLow and kUp.
[in,out]itInnerAn output iterator on Cell that outputs all the cells of K that lie in the interior of the parallelepiped specified by bounds kLow and kUp.
Note
Complexity is linear in the number of cells of K (but the constant is also linear in the dimension of K).

◆ generateSimplicityTable()

template<typename TObject , typename TMap >
void DGtal::functions::generateSimplicityTable ( const typename TObject::DigitalTopology &  dt,
TMap &  map 
)

Given a digital topology dt, generates tables that tells if the central point is simple for the specified configuration. The configuration is determined by a sequence of bits, the first bit for the point in the neighborhood, the second bit for the second point, etc. When set to one, the point is in the neighborhood.

Template Parameters
TObjectthe type of object whose simpleness we wish to precompute. Includes the topology.
TMapthe type used to store the mapping configuration -> bool.
Parameters
dtan instance of the digital topology.
map(modified) the mapping configuration -> bool.

Definition at line 71 of file NeighborhoodTablesGenerators.h.

74 {
75 typedef typename TObject::DigitalSet DigitalSet;
76 typedef typename TObject::Point Point;
77 typedef typename DigitalSet::Domain Domain;
78 typedef typename Domain::ConstIterator DomainConstIterator;
79
80 Point p1 = Point::diagonal( -1 );
81 Point p2 = Point::diagonal( 1 );
82 Point c = Point::diagonal( 0 );
83 Domain domain( p1, p2 );
84 DigitalSet shapeSet( domain );
85 TObject shape( dt, shapeSet );
86 unsigned int k = 0;
87 for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
88 if ( *it != c ) ++k;
89 ASSERT( ( k < 32 )
90 && "[generateSimplicityTable] number of configurations is too high." );
91 unsigned int nbCfg = 1 << k;
92 for ( NeighborhoodConfiguration cfg = 0; cfg < nbCfg; ++cfg )
93 {
94 if ( ( cfg % 1000 ) == 0 )
95 {
96 trace.progressBar( (double) cfg, (double) nbCfg );
97 }
98 shape.pointSet().clear();
99 shape.pointSet().insert( c );
101 for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
102 {
103 if ( *it != c )
104 {
105 if ( cfg & mask ) shape.pointSet().insert( *it );
106 mask <<= 1;
107 }
108 }
109 bool simple = shape.isSimple( c );
110 map[ cfg ] = simple;
111 }
112 }
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
void progressBar(const double currentValue, const double maximalValue)
Trace trace
MyPointD Point
Domain domain
HyperRectDomain< Space > Domain
Z2i::DigitalSet DigitalSet

References domain, dt, DGtal::Trace::progressBar(), and DGtal::trace.

◆ generateVoxelComplexTable()

template<typename TVoxelComplex , typename TMap >
void DGtal::functions::generateVoxelComplexTable ( TMap &  map,
std::function< bool(const TVoxelComplex &, const typename TVoxelComplex::Cell &) >  skelFunction 
)

Generates a table mapping the number of configuration of a 26 topology voxel neighborhood, and the boolean result of a predicate function applied to the central point for each configuration. The configuration is determined by a sequence of bits, the first bit for the point in the neighborhood, the second bit for the second point, etc. When set to one, the point is in the neighborhood.

Template Parameters
TVoxelComplexthe type of the VoxelComplex whose property we wish to precompute.
TMapthe type used to store the mapping configuration -> bool.
Parameters
map(modified) the mapping configuration -> bool.
skelFunctiona predicate function related to the property we want to check.

Definition at line 132 of file NeighborhoodTablesGenerators.h.

139 {
141 using Point = typename Domain::Point ;
143 Domain, std::unordered_set< Point > >;
144 using DomainConstIterator = typename Domain::ConstIterator ;
145 using KSpace = typename TVoxelComplex::KSpace;
146
147 Point p1 = Point::diagonal( -1 );
148 Point p2 = Point::diagonal( 1 );
149 Point c = Point::diagonal( 0 );
150 Domain domain( p1, p2 );
151 DigitalSet shapeSet( domain );
152 unsigned int k = 0;
153 for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
154 if ( *it != c ) ++k;
155 ASSERT( ( k < 32 )
156 && "[generateVoxelComplexTable] number of configurations is too high." );
157 unsigned int nbCfg = 1 << k;
158
159 KSpace ks;
160 // Pad KSpace domain.
161 ks.init(domain.lowerBound() + Point::diagonal( -1 ) ,
162 domain.upperBound() + Point::diagonal( 1 ),
163 true);
164 TVoxelComplex vc(ks);
165 vc.construct(shapeSet);
166 for ( unsigned int cfg = 0; cfg < nbCfg; ++cfg ){
167 if ( ( cfg % 1000 ) == 0 )
168 trace.progressBar( (double) cfg, (double) nbCfg );
169 vc.clear();
170 vc.insertVoxelPoint(c);
171 unsigned int mask = 1;
172 for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it ){
173 if ( *it != c ) {
174 if ( cfg & mask ) vc.insertVoxelPoint( *it );
175 mask <<= 1;
176 }
177 }
178 const auto &kcell = vc.space().uSpel(c);
179 bool predicate_output = skelFunction(vc, kcell);
180 map[ cfg ] = predicate_output;
181 }
182 }
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
HyperRectDomain< Space > Domain
Definition StdDefs.h:172

References domain, DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::Trace::progressBar(), and DGtal::trace.

◆ getAffineBasis() [1/2]

template<typename TPoint , typename TInputPoint >
void DGtal::functions::getAffineBasis ( TInputPoint &  o,
std::vector< TPoint > &  basis,
const std::vector< TInputPoint > &  X,
const double  tolerance = 1e-12 
)

Given a range of points X, returns a point and a range of vectors forming an affine basis containing X.

Template Parameters
TPointany type of lattice point or real point (but one may choose a more precise type than TInputPoint.
TInputPointany type of lattice point or real point.
Parameters
[out]othe origin point
[out]basisa range of vectors forming an affine basis containing X.
[in]Xthe range of input points (may be lattice points or not).
[in]tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).
Note
Complexity is O( m n^2 ), where m=Cardinal(X) and n=dimension.

Definition at line 1145 of file AffineGeometry.h.

1149 {
1150 std::tie( o, basis ) = AffineGeometry<TPoint>::affineBasis( X, tolerance );
1151 }

References DGtal::AffineGeometry< TPoint >::affineBasis().

Referenced by checkAffineGeometry(), SCENARIO(), SCENARIO(), and SCENARIO().

◆ getAffineBasis() [2/2]

template<typename TPoint , typename TInputPoint , typename TIndexRange >
static void DGtal::functions::getAffineBasis ( TInputPoint &  o,
std::vector< TPoint > &  basis,
const std::vector< TInputPoint > &  X,
const TIndexRange &  I,
const double  tolerance = 1e-12 
)
static

Given a range of points X, returns a point and a range of vectors forming an affine basis containing X.

Template Parameters
TPointany type of lattice point or real point (but one may choose a more precise type than TInputPoint.
TInputPointany type of lattice point or real point.
TIndexRangeany type of range of indices.
Parameters
[out]othe origin point
[out]basisa range of vectors forming an affine basis containing X.
[in]Xthe range of input points (may be lattice points or not).
[in]Ithe range of indices within X that specifies the subset of interest.
[in]tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).
Note
Complexity is O( m n^2 ), where m=Cardinal(I) and n=dimension.

Definition at line 1178 of file AffineGeometry.h.

1183 {
1184 std::tie( o, basis ) = AffineGeometry<TPoint>::affineBasis( X, I, tolerance );
1185 }

References DGtal::AffineGeometry< TPoint >::affineBasis().

◆ getCompleteBasis()

template<typename TPoint >
static void DGtal::functions::getCompleteBasis ( std::vector< TPoint > &  basis,
bool  normal_vector,
const double  tolerance = 1e-12 
)
static

Complete the vectors basis with independent vectors so as to form a basis of the space. When normal_vector is true, the last added vector is guaranteed to be orthogonal to all the previous vectors, otherwise it is just an independent canonic vector.

Note
In 3D, given two independent vectors as input, then the added vector is the (reduced for integers, normalized with 1 squared L2-norm for floats) cross product of these two vectors. In nD, it is thus a generalization of the cross product.
Template Parameters
TPointany type of lattice point or real point.
Parameters
[in,out]basisa range of independent vectors of size less than dimension, which is completed so as to be a basis of the full space.
[in]normal_vectorwhen 'true', the last vector of the basis is orthogonal to all the other vectors of the basis, otherwise it is just an independent canonic vector.
[in]tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).

Definition at line 1235 of file AffineGeometry.h.

1238 {
1239 AffineGeometry<TPoint>::completeBasis( basis, normal_vector, tolerance );
1240 }

References DGtal::AffineGeometry< TPoint >::completeBasis().

◆ getDeterminantBareiss() [1/2]

template<typename TComponent , DGtal::Dimension TN, typename TInternalNumber >
void DGtal::functions::getDeterminantBareiss ( TInternalNumber &  result,
const SimpleMatrix< TComponent, TN, TN > &  matrix 
)

Computes the determinant of a squared matrix with integer or floating-point coefficients using Bareiss method. Complexity is in O(n^3) if you assume O(1) for each arithmetic operation.

Template Parameters
TComponentthe number type.
TNthe order of the squared matrix.
TInternalNumberthe number type used for internal computations and for the output.
Parameters
[out]resultthe determinant of this matrix.
[in]matrixa squared matrix.
Note
In case of integer coefficients, intermediate integer values may grow quickly. Use int64_t or even boost::multiprecision::cpp_int to get robust result.

Referenced by DGtal::AffineGeometry< TPoint >::orthogonalVector(), testBareissDeterminant(), and testLLL().

◆ getDeterminantBareiss() [2/2]

template<typename TComponent , typename TInternalNumber >
void DGtal::functions::getDeterminantBareiss ( TInternalNumber &  result,
const std::vector< std::vector< TComponent > > &  matrix 
)

Computes the determinant of a squared matrix with integer or floating-point coefficients using Bareiss method. Complexity is in O(n^3) if you assume O(1) for each arithmetic operation.

Template Parameters
TComponentthe number type.
TInternalNumberthe number type used for internal computations and for the output.
Parameters
[in]matrixa squared matrix, represented as a vector of row vectors.
[out]resultthe determinant of this matrix.
Note
In case of integer coefficients, intermediate integer values may grow quickly. Use int64_t or even boost::multiprecision::cpp_int to get robust result.

◆ getOrthogonalLatticeBasis()

template<typename TPoint , typename TInputPoint >
static void DGtal::functions::getOrthogonalLatticeBasis ( std::vector< TPoint > &  B,
const TInputPoint &  N,
bool  shortened = false 
)
static

Given a primitive lattice vector N, returns a possible basis for its orthogonal d-1 dimensional lattice.

Template Parameters
TPointany type of lattice point (type for computations and output).
TInputPointany type of lattice point
Parameters
[out]Bthe d-1 dimension basis of the orthognal lattice to N.
[in]Na non null primitive lattice vector
[in]shortenedwhen 'false', the basis is in row echelon form, when 'true', the basis is shortened (with pairwise shortenings, may not be optimal, except in 3D).

Definition at line 1375 of file AffineGeometry.h.

References DGtal::AffineGeometry< TPoint >::orthogonalLatticeBasis().

◆ getOrthogonalVector() [1/2]

template<typename TPoint , typename TInputPoint >
static void DGtal::functions::getOrthogonalVector ( TPoint &  w,
const std::vector< TInputPoint > &  X,
const double  tolerance = 1e-12 
)
static

Given a range of points X, returns a vector that is orthogonal to this affine set, if it is d-1-dimensional.

Template Parameters
TPointany type of lattice point or real point (type for computations and output).
TInputPointany type of lattice point or real point.
Parameters
[out]wan orthogonal vector to every vector of the affine subset (reduced or normalized depending on integer/floating-point number type).
[in]Xthe range of input points (may be lattice points or not).
[in]tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).
Note
The orthogonal vector is computed as follows: (i) identifies an affine subset J of maximal affine dimension, (ii) computes the basis (X_J_k - X_J_0), k>0, (iii) computes the cofactors using Bareiss determinant. This method induces smaller integers than (i) reducing the basis, (ii) using cofactors with Bareiss determinant, or the method that solely cofactors with standard determinant computation.

Definition at line 1344 of file AffineGeometry.h.

1347 {
1348 typedef AffineGeometry<TPoint> Affine;
1349 w = TPoint::zero;
1350 TInputPoint o;
1351 auto subset = AffineGeometry<TPoint>::affineSubset( X, tolerance );
1352 if ( ( subset.size() ) != TPoint::dimension ) return;
1353 std::vector<TPoint> basis( TPoint::dimension - 1);
1354 for ( auto i = 0; i < basis.size(); i++ )
1355 basis[ i ] = Affine::transform( X[ subset[ i+1 ] ] - X[ subset[ 0 ] ] );
1356 w = Affine::orthogonalVector( basis );
1357 }

References DGtal::AffineGeometry< TPoint >::affineSubset().

◆ getOrthogonalVector() [2/2]

template<typename TPoint , typename TInputPoint , typename TIndexRange >
static void DGtal::functions::getOrthogonalVector ( TPoint &  w,
const std::vector< TInputPoint > &  X,
const TIndexRange &  I,
const double  tolerance = 1e-12 
)
static

Given a range of points X, a range of indices I specifying the affine subset of interest, returns a vector that is orthogonal to this affine subset, if it is d-1-dimensional.

Template Parameters
TPointany type of lattice point or real point.
TInputPointany type of lattice point or real point.
TIndexRangeany type of range of indices that specifies the subset of points of interest.
Parameters
[out]wan orthogonal vector to every vector of the affine subset (reduced or normalized depending on integer/floating-point number type).
[in]Xthe range of input points (may be lattice points or not).
[in]Ithe range of indices within X that specifies the subset of interest.
[in]tolerancethe accepted squared L2-norm below which the vector is null (used only for points with float/double coordinates).
Note
The orthogonal vector is computed as follows: (i) identifies an affine subset J of maximal affine dimension, (ii) computes the basis (X_J_k - X_J_0), k>0, (iii) computes the cofactors using Bareiss determinant. This method induces smaller integers than (i) reducing the basis, (ii) using cofactors with Bareiss determinant, or the method that solely cofactors with standard determinant computation.

Definition at line 1301 of file AffineGeometry.h.

1305 {
1306 typedef AffineGeometry<TPoint> Affine;
1307 w = TPoint::zero;
1308 TInputPoint o;
1309 auto subset = Affine::affineSubset( X, I, tolerance );
1310 if ( ( subset.size() ) != TPoint::dimension ) return;
1311 std::vector<TPoint> basis( TPoint::dimension - 1);
1312 for ( auto i = 0; i < basis.size(); i++ )
1313 basis[ i ] = Affine::transform( X[ subset[ i+1 ] ] - X[ subset[ 0 ] ] );
1314 w = Affine::orthogonalVector( basis );
1315 }

Referenced by DGtal::ConvexHullCommonKernel< dim, TCoordinateInteger, TInternalInteger >::compute(), DGtal::detail::GenericLatticeConvexHullComputers< dim, TCoordinateInteger, TInternalInteger, K >::compute(), and SCENARIO().

◆ getSpelNeighborhoodConfigurationOccupancy()

template<typename TComplex >
NeighborhoodConfiguration DGtal::functions::getSpelNeighborhoodConfigurationOccupancy ( const TComplex &  input_complex,
const typename TComplex::Point &  center,
const std::unordered_map< typename TComplex::Point, NeighborhoodConfiguration > &  mapPointToMask 
)

Get the occupancy configuration of the neighborhood of a point in a cubical complex. The neighborhood size is considered 3^D for dimension D of the point (ie 3x3x3 cube for 3D point).

Template Parameters
TComplexComplex type.
Parameters
input_complexinput complex. Used to check what points are occupied.
centerof the neighborhood. It doesn't matter if center belongs or not to input_complex.
mapPointToMaskmap[Point]->configuration, where Point is inside a DxD cube centered in {0,0,..} in ND.
Note
This doesn't work with KSpace coordinates, these must be converted to digital coordinates before:
See also
KhalimskySpaceND::uCoords(3,cell)
mapPointToBitMask
Returns
bit configuration

◆ getSquaredNormL2() [1/2]

template<typename TOutput , DGtal::Dimension dim, typename TEuclideanRing , typename TContainer >
void DGtal::functions::getSquaredNormL2 ( TOutput &  n,
const DGtal::PointVector< dim, TEuclideanRing, TContainer > &  a 
)

Overloaded squared L2-norm operator for a vector of numbers.

Template Parameters
TOutputthe desired number type for output.
dimstatic constant of type DGtal::Dimension that specifies the static dimension of the space and thus the number of elements of the Point or Vector.
TEuclideanRingspeficies the number type assoicated to an Euclidean domain (or Euclidean ring) algebraic structure (commutative unitary ring with no zero divisors and with a division operator but not necessarily an inverse for the multiplication operator). This type is used to represent PointVector elements (Coordinate for Point and Component for Vector) and define operations on Point or Vectors.
TContainerspecifies the container to be used to store the point coordinates. At this point, such container must be a random access bidirectionnal a-la STL containers (e.g. vector, boost/array). If TContainer implements comparison operators == != < <= > <=, then PointVector will also implements it and with the exact same behaviour.
Parameters
[out]nthe dot product a.a, i.e. the squared L2-norm of a.
[in]athe vector of numbers.

◆ getSquaredNormL2() [2/2]

template<typename TOutput , typename T >
void DGtal::functions::getSquaredNormL2 ( TOutput &  n,
const std::vector< T > &  a 
)

Overloaded squared L2-norm operator for a vector of numbers.

Template Parameters
TOutputthe desired number type for output.
Tthe number type of the input vector.
Parameters
[out]nthe dot product a.a, i.e. the squared L2-norm of a.
[in]athe vector of numbers.

Referenced by DGtal::AffineGeometry< TPoint >::addIfIndependent(), DGtal::AffineGeometry< TPoint >::independentVector(), and DGtal::AffineGeometry< TPoint >::simplifiedVector().

◆ isEqual() [1/2]

template<typename Container , bool ordered>
bool DGtal::functions::isEqual ( const Container &  S1,
const Container &  S2 
)

Equality test.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is equal to S2 (i.e. S1 is a subset of S2 and S2 is a subset of S1).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 789 of file SetFunctions.h.

790 {
791 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
792 BOOST_STATIC_CONSTANT
793 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
794 BOOST_STATIC_CONSTANT
795 ( bool, isOrdered = ordered
797
799 ::isEqual( S1, S2 );
800 }

Referenced by DGtal::operator!=(), and DGtal::operator==().

◆ isEqual() [2/2]

template<typename Container >
bool DGtal::functions::isEqual ( const Container &  S1,
const Container &  S2 
)

Equality test.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is equal to S2 (i.e. S1 is a subset of S2 and S2 is a subset of S1).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 815 of file SetFunctions.h.

816 {
817 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
818 BOOST_STATIC_CONSTANT
819 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
820 BOOST_STATIC_CONSTANT
821 ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
822
824 ::isEqual( S1, S2 );
825 }

◆ isOneSurface()

template<typename TObject >
bool DGtal::functions::isOneSurface ( const TObject &  small_obj)

Check if input object is a simple closed curve. Object must be:

See also
isZeroSurface
Template Parameters
TObjectObject Type
Parameters
small_objinput object
Returns
bool

◆ isSubset() [1/2]

template<typename Container , bool ordered>
bool DGtal::functions::isSubset ( const Container &  S1,
const Container &  S2 
)

Inclusion test.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is a subset of S2.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 845 of file SetFunctions.h.

846 {
847 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
848 BOOST_STATIC_CONSTANT
849 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
850 BOOST_STATIC_CONSTANT
851 ( bool, isOrdered = ordered
853
855 ::isSubset( S1, S2 );
856 }

Referenced by DGtal::operator<=(), and DGtal::operator>=().

◆ isSubset() [2/2]

template<typename Container >
bool DGtal::functions::isSubset ( const Container &  S1,
const Container &  S2 
)

Inclusion test.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is a subset of S2.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 869 of file SetFunctions.h.

870 {
871 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
872 BOOST_STATIC_CONSTANT
873 ( bool, isAssociative = IsAssociativeContainer< Container >::value );
874 BOOST_STATIC_CONSTANT
875 ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
876
878 ::isSubset( S1, S2 );
879 }

◆ isZeroSurface()

template<typename TObject >
bool DGtal::functions::isZeroSurface ( const TObject &  small_obj)

Check if the object contains, exclusively, two disconnected voxels.

See also
Object::computeConnectedness
Template Parameters
TObjectObject Type
Parameters
small_objinput object
Returns
bool

◆ loadTable() [1/2]

template<unsigned int dimension = 3>
DGtal::CountedPtr< boost::dynamic_bitset<> > DGtal::functions::loadTable ( const std::string &  input_filename,
const bool  compressed = true 
)
inline

Load existing look up table existing in file_name, precalculated tables can be accessed including the header: "DGtal/topology/tables/NeighborhoodTables.h"

Template Parameters
dimensionof the space input_filename table refers. 2 or 3
Parameters
input_filenameplain text containing the bool table.
compressedtrue if table to read has been compressed with zlib.
Returns
smart ptr of map[neighbor_configuration] -> bool
See also
NeighborhoodConfigurations::loadTable

◆ loadTable() [2/2]

DGtal::CountedPtr< boost::dynamic_bitset<> > DGtal::functions::loadTable ( const std::string &  input_filename,
const unsigned int  known_size,
const bool  compressed = true 
)
inline

Load existing look up table existing in file_name, precalculated tables can be accessed including the header: "DGtal/topology/tables/NeighborhoodTables.h"

Parameters
input_filenameplain text containing the bool table.
known_sizeof the bitset, for 2D = 256 (2^8), 3D = 67108864 (2^26)
compressedtrue if table to read has been compressed with zlib.
Returns
smart ptr of map[neighbor_configuration] -> bool
Note
The tables were calculated using the generateTableXXX examples. Compressed files of the tables are distributed in the source code. At build or install time, the header "DGtal/topology/tables/NeighborhoodTables.h" is generated. It has const strings variables with the file names of the tables.

Referenced by SCENARIO(), SCENARIO(), TEST_CASE_METHOD(), TEST_CASE_METHOD(), TEST_CASE_METHOD(), TEST_CASE_METHOD(), TEST_CASE_METHOD(), and thinningVoxelComplex().

◆ makeDifference() [1/2]

template<typename Container , bool ordered>
Container DGtal::functions::makeDifference ( const Container &  S1,
const Container &  S2 
)

Set difference operation. Returns the difference of S1 - S2.

Parameters
[in]S1an input set
[in]S2another input set.
Returns
the set S1 - S2.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 946 of file SetFunctions.h.

947 {
948 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
949 Container S( S1 );
950 assignDifference<Container, ordered>( S, S2 );
951 return S;
952 }

Referenced by DGtal::functions::setops::operator-().

◆ makeDifference() [2/2]

template<typename Container >
Container DGtal::functions::makeDifference ( const Container &  S1,
const Container &  S2 
)

Set difference operation. Returns the difference of S1 - S2.

Parameters
[in]S1an input set
[in]S2another input set.
Returns
the set S1 - S2.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 965 of file SetFunctions.h.

966 {
967 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
968 Container S( S1 );
969 assignDifference( S, S2 );
970 return S;
971 }
Container & assignDifference(Container &S1, const Container &S2)

References assignDifference().

◆ makeIntersection() [1/2]

template<typename Container , bool ordered>
Container DGtal::functions::makeIntersection ( const Container &  S1,
const Container &  S2 
)

Set intersection operation. Returns the set \( S1 \cap S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \cap S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1131 of file SetFunctions.h.

1132 {
1133 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1134 Container S( S1 );
1135 assignIntersection<Container, ordered>( S, S2 );
1136 return S;
1137 }

Referenced by DGtal::functions::setops::operator&().

◆ makeIntersection() [2/2]

template<typename Container >
Container DGtal::functions::makeIntersection ( const Container &  S1,
const Container &  S2 
)

Set intersection operation. Returns the set \( S1 \cap S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \cap S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1149 of file SetFunctions.h.

1150 {
1151 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1152 Container S( S1 );
1153 assignIntersection( S, S2 );
1154 return S;
1155 }
Container & assignIntersection(Container &S1, const Container &S2)

References assignIntersection().

◆ makePrimitive()

template<typename TComponent >
TComponent DGtal::functions::makePrimitive ( std::vector< TComponent > &  N)

Makes a lattice vector primitive.

Template Parameters
TComponentthe integer type for the input vector and for computations.
Parameters
[in,out]Nthe input vector, that is modified to be N/g, where g is the gcd of its components.
Returns
the gcd of the components.

Referenced by testOrthogonalLattice().

◆ makeSymmetricDifference() [1/2]

template<typename Container , bool ordered>
Container DGtal::functions::makeSymmetricDifference ( const Container &  S1,
const Container &  S2 
)

Set symmetric difference operation. Returns the set \( S1 \Delta S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \Delta S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1225 of file SetFunctions.h.

1226 {
1227 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1228 Container S( S1 );
1229 assignSymmetricDifference<Container, ordered>( S, S2 );
1230 return S;
1231 }

Referenced by DGtal::functions::setops::operator^().

◆ makeSymmetricDifference() [2/2]

template<typename Container >
Container DGtal::functions::makeSymmetricDifference ( const Container &  S1,
const Container &  S2 
)

Set symmetric difference operation. Returns the set \( S1 \Delta S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \Delta S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1243 of file SetFunctions.h.

1244 {
1245 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1246 Container S( S1 );
1248 return S;
1249 }
Container & assignSymmetricDifference(Container &S1, const Container &S2)

References assignSymmetricDifference().

◆ makeUnion() [1/2]

template<typename Container , bool ordered>
Container DGtal::functions::makeUnion ( const Container &  S1,
const Container &  S2 
)

Set union operation. Returns the set \( S1 \cup S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \cup S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1039 of file SetFunctions.h.

1040 {
1041 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1042 Container S( S1 );
1043 assignUnion<Container, ordered>( S, S2 );
1044 return S;
1045 }

Referenced by DGtal::functions::setops::operator|().

◆ makeUnion() [2/2]

template<typename Container >
Container DGtal::functions::makeUnion ( const Container &  S1,
const Container &  S2 
)

Set union operation. Returns the set \( S1 \cup S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \cup S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1057 of file SetFunctions.h.

1058 {
1059 BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1060 Container S( S1 );
1061 assignUnion( S, S2 );
1062 return S;
1063 }
Container & assignUnion(Container &S1, const Container &S2)

References assignUnion().

◆ mapZeroPointNeighborhoodToConfigurationMask()

template<typename TPoint >
DGtal::CountedPtr< std::unordered_map< TPoint, NeighborhoodConfiguration > > DGtal::functions::mapZeroPointNeighborhoodToConfigurationMask ( )
inline

Maps any point in the neighborhood of point Zero (0,..,0) to its corresponding configuration bit mask. This is a helper to use with tables. The order of the configuration is lexicographic, starting in {-1, -1, ...}.

Note
the neighborhood is considered to be all points p which ||p-zero|| <= 1

Example: Point{ -1, -1, -1 } = 1; // corresponding to mask x x 0000 0001 Point{ 0, -1, -1 } = 2; // corresponding to mask x x 0000 0010 Point{ 1, 1, 1 } = 2^26; // x 0010 x x x x x x

Note
NeighborhoodConfiguration is type uint 32 bits, so the max dimension supported is 3.
See also
HyperRectDomain_Iterator::nextLexicographicOrder
testNeighborhoodConfigurations.cpp shows the complete mapping.
Template Parameters
TPointtype of point to create map and input the desired dimension.
Returns
map[Point]->configuration smart pointer.

◆ matrixAsVectorVector() [1/2]

template<typename TComponent , DGtal::Dimension TM, DGtal::Dimension TN>
std::vector< std::vector< TComponent > > DGtal::functions::matrixAsVectorVector ( const SimpleMatrix< TComponent, TM, TN > &  M)

Outputs the matrix of size m x n with coefficients c, as a vector of vector representation.

Template Parameters
TComponentthe number type.
TNthe number of rows
TMthe number of columns
Parameters
[in]Many matrix
Returns
the m x n matrix cloning the coefficients of M.

◆ matrixAsVectorVector() [2/2]

template<typename TComponent >
std::vector< std::vector< TComponent > > DGtal::functions::matrixAsVectorVector ( std::size_t  m,
std::size_t  n,
const std::vector< TComponent > &  c 
)

Outputs the matrix M of size m x n with coefficients c, as a vector of vector representation.

Template Parameters
TComponentthe number type.
Parameters
[in]m,nthe number of rows and columns of the matrix M.
[in]cthe coefficients of the matrix in order c_00, c01, etc.
Returns
the m x n matrix with coefficients c filled row per row, and potentially completed with zero.

Referenced by testBareissDeterminant().

◆ negate()

template<typename TComponent >
void DGtal::functions::negate ( std::vector< TComponent > &  V)

Negates the components of the input vector.

Template Parameters
TComponentthe scalar type of each component.
Parameters
[in,out]Vthe vector as input, outputed as -V.

Referenced by testOrthogonalLattice().

◆ normL1()

template<typename T >
T DGtal::functions::normL1 ( const std::vector< T > &  a)

Overloaded L1-norm operator for a vector of numbers.

Template Parameters
Tthe number type of the input vector.
Parameters
[in]athe vector of numbers
Returns
the L1-norm of a, i.e. \( \sum_i |a_i| \), sometimes called block distance.

Referenced by testLLL().

◆ normLoo()

template<typename T >
T DGtal::functions::normLoo ( const std::vector< T > &  a)

Overloaded Loo-norm operator for a vector of numbers.

Template Parameters
Tthe number type of the input vector.
Parameters
[in]athe vector of numbers
Returns
the \( L_\infinity \)-norm of a, i.e. \( \max_i |a_i| \).

◆ objectFromSpels()

template<typename TObject , typename TKSpace , typename TCellContainer >
std::unique_ptr< TObject > DGtal::functions::objectFromSpels ( const CubicalComplex< TKSpace, TCellContainer > &  C)

Create object from the spels in the complex.

User has to provide a 3D TObject type with its associated DigitalSet and DigitalTopology.

Given a dimension n, spels are the n-cells, equivalently, spels are the grid-points in Z^n.

Template Parameters
TObjectwith its associdated DigitalSet and DigitalTopology
TKSpacekspace type of the input CubicalComplex.
TCellContainercell container type of the input CubicalComplex
Parameters
Cinput CubicalComplex
Returns
unique_ptr of created object with the pointset containing the spels of the complex.

◆ oneIsthmus()

template<typename TComplex >
bool DGtal::functions::oneIsthmus ( const TComplex &  vc,
const typename TComplex::Cell &  cell 
)

Check if input cell is a 1-isthmus. A voxel is a 1-isthmus if, after a thinning, its proper neighborhood is made only by two voxels, ie, it is a 0-Surface isZeroSurface.

See also
isZeroSurface
Object::properNeighborhood
Template Parameters
TComplexVoxelComplex.
Parameters
vcinput complex.
cellapply function on input cell.
Returns
bool

◆ persistenceAsymetricThinningScheme()

template<typename TComplex >
TComplex DGtal::functions::persistenceAsymetricThinningScheme ( TComplex &  vc,
std::function< std::pair< typename TComplex::Cell, typename TComplex::Data >(const typename TComplex::Clique &) >  Select,
std::function< bool(const TComplex &, const typename TComplex::Cell &) >  Skel,
uint32_t  persistence,
bool  verbose = false 
)

◆ power()

template<typename T >
T DGtal::functions::power ( const T &  aVal,
const unsigned int  exponent 
)

Compute exponentiation by squaring of a scalar aVal of type T by the exponent exponent (unsigned int). The computation is done in \( O(\log(exponent))\) multiplications.

Note
This function is better than std::pow on unsigned int exponents and integer value type since it performs exact computations (no cast to float or doubles).
Parameters
aValthe value
exponentthe exponent
Template Parameters
Tscalar value type (must have '*' operator).
Returns
aVal^exponent
See also
square, cube

Definition at line 73 of file BasicMathFunctions.h.

74 {
75 unsigned int q=exponent;
76 T p(aVal);
77
78 if (exponent == 0) { return 1; }
79
80 T result = NumberTraits<T>::ONE;
81 while (q != 0)
82 {
83 if (q % 2 == 1) { // q is odd
84 result *= p;
85 q--;
86 }
87 p *= p;
88 q /= 2;
89 }
90 return result;
91 }
Aim: The traits class for all models of Cinteger.

Referenced by testBasicMathFunctions().

◆ reduceBasisWithLLL()

template<typename TComponent , typename TDouble = long double>
void DGtal::functions::reduceBasisWithLLL ( std::vector< std::vector< TComponent > > &  B,
TDouble  delta = 0.75 
)

Computes the \( \delta \)-LLL-reduced lattice of the input lattice B (represented as an integer matrix B whose rows are the lattice vectors), using the LLL algorithm.

Such lattice has "almost" orthogonal vectors, while minimizing their norm at most as possible.

Note
A lattice \((b_1,...,b_m)\) is \( \delta \)-LLL-reduced if (1), for any \( i>j, |\mu_{i,j}| \le 1/2 \), and (2), for any \( i<m , \delta |b^*_i|^2 \le |b^*_{i+1}+mu_{i+1,i} b^*_i|^2 \). Here \( \mu_{i,j} := \langle b_i, b_j^* \rangle / \langle b_j^*, b_j^* \rangle \) and \( b^*_i \) is the i-th vector of the Gram-Schmidt orthogonalisation of \( (b_1, ..., b_m) \).
Template Parameters
TComponentthe integer type of each coefficient of the integer matrix B.
TDoublethe floating-point number type used for the Gram-Schmidt orthogonalisation of B.
Parameters
[in,out]Bas input, the lattice of m vectors in Z^n represented as a mxn matrix, as output the \( delta \)-LLL-reduced lattice of B.
[in]deltathe parameter \( \delta \) of LLL-algorithm, which should be between 0.25 and 1 (value 0.99 is default in sagemath).
Warning
Computations requiring Gram-Schmidt orthogonalisation uses the floating-point number type TDouble.

Referenced by DGtal::AffineBasis< TPoint >::reduceAsLLL().

◆ reversedSmartCH() [1/2]

template<typename DSS , typename OutputIterator >
DSS::Vector DGtal::functions::reversedSmartCH ( const DSS &  aDSS,
const typename DSS::Position &  aPositionBound,
OutputIterator  uIto,
OutputIterator  lIto 
)
inline

Procedure that computes the lower and upper left hull of the left subsegment of a greater DSS aDSS. Note that the so-called left subsegment is bounded on the one hand by the first point of aDSS and on the other hand by the point located at position aPositionBound [Roussillon 2014 : [108]].

Parameters
aDSSbounding DSS
aPositionBoundposition of the last point of the subsegment (should be located after the first point of aDSS).
uItooutput iterator used to store the vertices of the upper convex hull
lItooutput iterator used to store the vertices of the lower convex hull
Template Parameters
DSSa model of arithmetical DSS
OutputIteratora model of output iterator
Returns
last direction vector, ie. the rational slope of minimal denominator

◆ reversedSmartCH() [2/2]

template<typename PointVector , typename Position , typename PositionFunctor , typename OutputIterator >
PointVector DGtal::functions::reversedSmartCH ( PointVector  U,
PointVector  L,
PointVector  V,
const Position &  aFirstPosition,
const Position &  aLastPosition,
const PositionFunctor &  aPositionFunctor,
OutputIterator  uIto,
OutputIterator  lIto 
)
inline

Procedure that computes the lower and upper left hull of the left subsegment of a greater DSS characterized by the first upper leaning point U, the first positive Bezout point L and its direction vector V. Note that the so-called left subsegment is bounded on the one hand by the first point of the DSS located at aFirstPosition and on the other hand by the point located at position aLastPosition.

Parameters
Ulast upper convex hull vertex
Llast lower convex hull vertex
Vlast valid Bezout vector (main direction vector)
aFirstPositionposition of the first point of the subsegment
aLastPositionposition of the last point of the subsegment
aPositionFunctorposition functor, which returns the position of any given point/vector
uItooutput iterator used to store the vertices of the upper convex hull
lItooutput iterator used to store the vertices of the lower convex hull
Template Parameters
PointVectora model of 2d point/vector
Positiona model of integer for the position of the point in the bounding DSS
PositionFunctora model of unary functor that returns the position of a point/vector
OutputIteratora model of output iterator
Returns
last direction vector, ie. the rational slope of minimal denominator

Referenced by basicTest2(), and reversedSmartCHSubsegment().

◆ roundToUpperPowerOfTwo()

template<typename T >
T DGtal::functions::roundToUpperPowerOfTwo ( const T &  n)

Compute the next higher power of two of the given argument n of type T.

Template Parameters
Tthe type of the element T
Parameters
nan element of type T (casted to unsigned integer).
Returns
the next higher power of two.

Definition at line 102 of file BasicMathFunctions.h.

102 {
103 return (T) 1 << (1+DGtal::Bits::mostSignificantBit( (unsigned int) n-1 ) );
104 }
static unsigned int mostSignificantBit(DGtal::uint8_t n)
Definition Bits.h:341

References DGtal::Bits::mostSignificantBit().

Referenced by testBasicMathFunctions().

◆ selectFirst()

template<typename TComplex >
std::pair< typename TComplex::Cell, typename TComplex::Data > DGtal::functions::selectFirst ( const typename TComplex::Clique &  clique)

Select first voxel of input clique.

Template Parameters
TComplexinput CubicalComplex
Parameters
cliquefrom where cell is chosen.
Returns
first voxel of clique.

◆ selectMaxValue()

template<typename TDistanceTransform , typename TComplex >
std::pair< typename TComplex::Cell, typename TComplex::Data > DGtal::functions::selectMaxValue ( const TDistanceTransform &  dist_map,
const typename TComplex::Clique &  clique 
)

Select cell from clique that has max value looking at the input dist_map. The points in the dist_map and in the clique must refer to the same position.

If you need to have a std::function<bool(const Clique &)> signature (for using it in thinning algorithms), use a lambda: subsitute skelRandom (for example) for:

auto selectDistMax =
[&dist_map](const Clique & clique){
return selectMaxDistance<TDistMap, TComplex>(dist_map, clique);
}
Template Parameters
TDistanceTransformContainer type for the distance map.
TComplexinput CubicalComplex
Parameters
dist_mapcontainer holding the values.
cliquefrom where cell is chosen.
Returns
cell from input clique with highest value.
See also
DistanceTransformation.h

◆ selectRandom() [1/2]

template<typename TComplex >
std::pair< typename TComplex::Cell, typename TComplex::Data > DGtal::functions::selectRandom ( const typename TComplex::Clique &  clique)

Select random voxel from input clique.

Template Parameters
TComplexinput CubicalComplex
Parameters
cliquefrom where cell is chosen.
Returns
random voxel from input clique.

◆ selectRandom() [2/2]

template<typename TComplex , typename TRandomGenerator >
std::pair< typename TComplex::Cell, typename TComplex::Data > DGtal::functions::selectRandom ( const typename TComplex::Clique &  clique,
TRandomGenerator &  gen 
)

Select random voxel from input clique.

Template Parameters
TComplexCubicalComplex
TRandomGeneratorRandomGenerator
Parameters
cliquefrom where cell is chosen
genrandom generator
Returns
random voxel from input clique.

◆ shortenBasis()

template<typename TComponent >
std::size_t DGtal::functions::shortenBasis ( std::vector< std::vector< TComponent > > &  B)

Shortens the vectors of the basis B (by pairwise shortenings) until no further shortening pairs are found, and returns the number of shortening operations.

Template Parameters
TComponentthe integer type for the input vector and for computations.
Parameters
[in,out]Ba range of vectors forming a basis, which is shorten as much as possible in terms of L2-norm. Note that the output basis is not in echelon form in general.
Returns
the number of pairwise shortenings done.

Referenced by DGtal::AffineGeometry< TPoint >::orthogonalLatticeBasis(), testLLL(), and testOrthogonalLattice().

◆ shortenVectors()

template<typename TComponent >
bool DGtal::functions::shortenVectors ( std::vector< TComponent > &  u,
std::vector< TComponent > &  v 
)

Tries to shorten u and v while preserving their vector span by trying u+v and u-v.

Template Parameters
TComponentthe integer type for the input vector and for computations.
Parameters
[in,out]uany vector
[in,out]vany vector
Returns
'true' if one shortening was possible, then at least one of u and v is modified.

◆ skelEnd()

template<typename TComplex >
bool DGtal::functions::skelEnd ( const TComplex &  vc,
const typename TComplex::Cell &  cell 
)

Check if input cell only has one neighbor, using Object::topology.

Template Parameters
TComplexVoxelComplex
Parameters
vcinput voxel complex.
cellc apply function on this voxel cell.
Returns
true if voxel cell only has neighbor.

◆ skelIsthmus()

template<typename TComplex >
bool DGtal::functions::skelIsthmus ( const TComplex &  vc,
const typename TComplex::Cell &  cell 
)

Check if input cell is a 1 or 2 Isthmus.

Template Parameters
TComplexVoxelComplex.
Parameters
vcinput complex.
cellapply function on input cell.
Returns
oneIsthmus || twoIsthmus
See also
oneIsthmus
twoIsthmus

◆ skelSimple()

template<typename TComplex >
bool DGtal::functions::skelSimple ( const TComplex &  vc,
const typename TComplex::Cell &  cell 
)

Check if input cell is simple using VoxelComplex::isSimple interface to Object::isSimple.

See also
VoxelComplex::isSimple
Object::isSimple
Template Parameters
TComplexVoxelComplex.
Parameters
vcinput complex.
cellapply function on input cell.
Returns
true if voxel is simple.

◆ skelUltimate()

template<typename TComplex >
bool DGtal::functions::skelUltimate ( const TComplex &  vc,
const typename TComplex::Cell &  cell 
)

Always returns false. Used in thinning schemes to calculate an ultimate skeleton. An ultimate skeleton only keeps voxels that don't change the topology.

Note
The number of cells of a thinning using this function is the same as the number of connected components of an object.
See also
asymetricThinningScheme
Template Parameters
TComplexVoxelComplex
Parameters
vcinput voxel complex.
cellc apply function on this voxel cell.
Returns
always false.

◆ skelWithTable()

template<typename TComplex >
bool DGtal::functions::skelWithTable ( const boost::dynamic_bitset<> &  table,
const std::unordered_map< typename TComplex::Point, unsigned int > &  pointToMaskMap,
const TComplex &  vc,
const typename TComplex::Cell &  cell 
)

Generic predicate to use external tables[configuration]->bool with skel functions. Can be adapted to any table using lambdas.

See also
LookUpTableFunctions.h
tests/topology/testVoxelComplex.h

If you need to have a std::function<bool(const Complex & vc, const Cell & c )> signature (for using it in thinning algorithms), use a lambda to capture values: subsitute skelIsthmus (for example) for:

auto skelWithTableIsthmus =
[&table, &pointToMaskMap](const Complex & vc, const Cell & cell){
return skelWithTable<TComplex>(table, pointToMaskMap, vc, cell);
}
Template Parameters
TComplexinput CubicalComplex type.
Parameters
table[configuration]->bool
See also
VoxelComplex::loadTable
LookUpTableFunctions.h::loadTable
Parameters
pointToMaskMapmap[neighborhood points] to a bit mask. Used to get the neighborhood configuration.
See also
VoxelComplex::pointToMask
LookUpTableFunctions.h::mapPointToBitMask
Parameters
vcinput complex.
cellinput cell, center from where the neighborhood [configuration] will be checked. Note that only neighborhood are checked to belong to the complex, not the input cell.
Returns
bool from selected table[configuration].

Referenced by thinningVoxelComplex().

◆ smartCH() [1/2]

template<typename DSL , typename OutputIterator >
DSL::Vector DGtal::functions::smartCH ( const DSL &  aDSL,
const typename DSL::Point &  aFirstPoint,
const typename DSL::Position &  aLength,
OutputIterator  uIto,
OutputIterator  lIto 
)
inline

Procedure that computes the lower and upper left hull of a DSS of first point aFirstPoint, length aLength, contained in a DSL aDSL [Roussillon 2014 : [108]].

Parameters
aDSLbounding DSL
aFirstPointfirst point of the DSS
aLength(strictly positive) length of the DSS
uItooutput iterator used to store the vertices of the upper convex hull
lItooutput iterator used to store the vertices of the lower convex hull
Returns
last direction vector, ie. the rational slope of minimal denominator
Template Parameters
DSLa model of arithmetical DSL
OutputIteratora model of output iterator

◆ smartCH() [2/2]

template<typename PointVector , typename Coordinate , typename Position , typename PositionFunctor , typename OutputIterator >
PointVector DGtal::functions::smartCH ( const PointVector aFirstPoint,
const Coordinate &  aRemainderBound,
const Position &  aPositionBound,
const PointVector aStep,
const Coordinate &  aRStep,
const PointVector aShift,
const Coordinate &  aRShift,
const PositionFunctor &  aPositionFunctor,
OutputIterator  uIto,
OutputIterator  lIto 
)
inline

Procedure that computes the lower and upper left hull of a DSS of first point aFirstPoint, length aPositionBound, contained in a digital straight line described by aRStep, aRShift and aRemainderBound.

Parameters
aFirstPointfirst point of the DSS
aRemainderBounddifference between the intercept mu of the bounding DSL and the remainder of the first point.
aPositionBound(strictly positive) length of the DSS
aStepfirst step of the DSL
aRStepremainder of the first step, ie. parameter \( a \) of the bounding DSL
aShiftshift vector of the DSL
aRShiftremainder of the shift vector, ie. parameter \( omega \) of the bounding DSL.
aPositionFunctorposition functor, which returns the position of any given point/vector
uItooutput iterator used to store the vertices of the upper convex hull
lItooutput iterator used to store the vertices of the lower convex hull
Returns
last direction vector, ie. the rational slope of minimal denominator of the DSS
Template Parameters
PointVectora model of 2d point/vector
Coordinatea model of integer for the coordinates of the point/vector
Positiona model of integer for locating points in the DSS
PositionFunctora model of unary functor that returns the position of a point/vector
OutputIteratora model of output iterator

Referenced by basicTest(), comparisonLeftHull(), and smartCHSubsegment().

◆ smartCHNextVertex()

template<typename Position , typename Coordinate , typename PointVector , typename OutputIterator , typename PositionFunctor , typename TruncationFunctor1 , typename TruncationFunctor2 >
bool DGtal::functions::smartCHNextVertex ( const Position &  positionBound,
const Coordinate &  remainderBound,
PointVector X,
Coordinate &  rX,
const PointVector Y,
const Coordinate &  rY,
PointVector V,
Coordinate &  rV,
OutputIterator  ito,
const PositionFunctor &  pos,
const TruncationFunctor1 &  f1,
const TruncationFunctor2 &  f2 
)
inline

Procedure that computes the next (lower or upper) vertex of the left hull of a DSS.

Parameters
positionBoundposition of the last point of the DSS
remainderBoundremainder of the lower leaning points contained in the DSS
X(returned) last vertex of the considered side
rX(returned) remainder of X
Ylast vertex of the opposite side
rYremainder of Y
V(returned) last direction vector (unimodular with (X - Y))
rV(returned) remainder of V (not null)
itooutput iterator used to store the new vertex lying on the same side as X
posposition functor, which returns the position of any given point/vector
f1first floor function (for the vertex)
f2second floor function (for the direction vector)
Returns
'true' if the last vertex of the left hull has been reached, 'false' otherwise.
Template Parameters
Positiona model of integer for locating points in the DSS
PointVectora model of 2d point/vector
Coordinatea model of integer for the coordinates of the point/vector
OutputIteratora model of output iterator
PositionFunctora model of unary functor that returns the position of a point/vector
TruncationFunctor1a model of unary functor that implements an integer division
TruncationFunctor2a model of unary functor that implements an integer division

◆ smartCHPreviousVertex()

template<typename PointVector , typename Position , typename OutputIterator , typename TruncationFunctor1 , typename TruncationFunctor2 , typename PositionFunctor >
bool DGtal::functions::smartCHPreviousVertex ( PointVector X,
const PointVector Y,
PointVector V,
const Position &  aFirstPosition,
const Position &  aLastPosition,
OutputIterator  ito,
const PositionFunctor &  pos,
const TruncationFunctor1 &  f1,
const TruncationFunctor2 &  f2 
)
inline

Procedure that computes the previous vertex of the left hull of a DSS of main direction vector V , first upper leaning point U and first positive Bezout point L. The computation stops as soon as a computed vertex is located before aLastPosition.

Parameters
X(returned) first vertex of the left hull on the considered side
Yfirst vertex of the left hull on the opposite side
V(returned) previous direction vector
aFirstPositionposition of the first point of the subsegment
aLastPositionposition of the last point of the subsegment
itooutput iterator used to store the vertices of the left hull lying on the same side as X
posposition functor, which returns the position of any given point/vector
f1integer divisor for the direction vector update
f2integer divisor for the vertex update
Template Parameters
PointVectora model of couple of coordinates
Positiona model of integer for the position of the points
OutputIteratora model of output iterator
TruncationFunctor1a model of functor for the integer division
TruncationFunctor2a model of functor for the integer division
PositionFunctora model of functor returning the position of a point
Returns
'true' if the last vertex has been reached, 'false' otherwise

◆ square()

template<typename T >
T DGtal::functions::square ( x)
inline

Returns the value x * x

Template Parameters
Ta type with the multiply operator.
Parameters
xany value
Returns
the value x * x

Definition at line 133 of file BasicMathFunctions.h.

134 { return x * x; }

Referenced by DGtal::functors::HatPointFunction< TPoint, TScalar >::operator()(), and DGtal::functors::BallConstantPointFunction< TPoint, TScalar >::operator()().

◆ squaredNormL2()

template<typename T >
T DGtal::functions::squaredNormL2 ( const std::vector< T > &  a)

Overloaded squared L2-norm operator for a vector of numbers.

Template Parameters
Tthe number type of the input vector.
Parameters
[in]athe vector of numbers
Returns
the dot product a.a, i.e. the squared L2-norm of a.
See also
getSquaredNormL2 if you wish to use another type for computation.

◆ thinningVoxelComplex()

template<typename TComplex , typename TDistanceTransform = DistanceTransformation<Z3i::Space, Z3i::DigitalSet, ExactPredicateLpSeparableMetric<Z3i::Space, 3>>>
TComplex DGtal::functions::thinningVoxelComplex ( TComplex &  vc,
const std::string &  skel_type_str,
const std::string &  skel_select_type_str,
const std::string &  tables_folder,
const int &  persistence = 0,
const TDistanceTransform *  distance_transform = nullptr,
const bool  profile = false,
const bool  verbose = false 
)

Definition at line 92 of file VoxelComplexThinning.h.

101{
102 if(verbose) {
103 using DGtal::trace;
104 trace.beginBlock("thin_function parameters:");
105 trace.info() << "skel_type_str: " << skel_type_str << std::endl;
106 trace.info() << "skel_select_type_str: " << skel_select_type_str << std::endl;
107 if(distance_transform) {
108 trace.info() << " -- provided distance_transform." << std::endl;
109 }
110 trace.info() << "persistence: " << persistence << std::endl;
111 trace.info() << "profile: " << profile << std::endl;
112 trace.info() << "verbose: " << verbose << std::endl;
113 trace.info() << "----------" << std::endl;
114 trace.endBlock();
115 }
116
117 // Validate input skel method and skel_select
118 const bool skel_type_str_is_valid =
119 skel_type_str == "ultimate" ||
120 skel_type_str == "end" ||
121 skel_type_str == "isthmus" ||
122 skel_type_str == "1isthmus" ||
123 skel_type_str == "isthmus1";
124 if(!skel_type_str_is_valid) {
125 throw std::runtime_error("skel_type_str is not valid: \"" + skel_type_str + "\"");
126 }
127
128 const bool skel_select_type_str_is_valid =
129 skel_select_type_str == "first" ||
130 skel_select_type_str == "random" ||
131 skel_select_type_str == "dmax";
132 if(!skel_select_type_str_is_valid) {
133 throw std::runtime_error("skel_select_type_str is not valid: \"" + skel_select_type_str + "\"");
134 }
135 // // No filesystem to check the tables folder exist. If incorrect, it will fail loading the table.
136 // const fs::path tables_folder_path{tables_folder};
137 // if(!fs::exists(tables_folder_path)) {
138 // throw std::runtime_error("tables_folder " + tables_folder_path.string() +
139 // " doesn't exist in the filesystem.\n"
140 // "tables_folder should point to the folder "
141 // "where DGtal tables are: i.e simplicity_table26_6.zlib");
142 // }
143
144 // Create a VoxelComplex from the set
145 using Complex = TComplex;
146 using ComplexCell = typename Complex::Cell;
147 using ComplexClique = typename Complex::Clique;
148 using Point = DGtal::Z3i::Point;
149
150 if(verbose) { DGtal::trace.beginBlock("load isthmus table"); }
151 boost::dynamic_bitset<> isthmus_table;
152 auto &sk = skel_type_str;
153 if(sk == "isthmus") {
154 const std::string tableIsthmus = tables_folder + "/isthmusicity_table26_6.zlib";
155 isthmus_table = *DGtal::functions::loadTable(tableIsthmus);
156 } else if(sk == "isthmus1" || sk == "1ishtmus") {
157 const std::string tableOneIsthmus = tables_folder + "/isthmusicityOne_table26_6.zlib";
158 isthmus_table = *DGtal::functions::loadTable(tableOneIsthmus);
159 }
160 if(verbose) { DGtal::trace.endBlock(); }
161
162
163 // SKEL FUNCTION:
164 // Load a look-up-table for the neighborgood of a point
165 auto pointMap =
166 *DGtal::functions::mapZeroPointNeighborhoodToConfigurationMask<Point>();
167 std::function<bool(const Complex&, const ComplexCell&)> Skel;
168 if(sk == "ultimate") {
169 Skel = DGtal::functions::skelUltimate<Complex>;
170 } else if(sk == "end") {
171 Skel = DGtal::functions::skelEnd<Complex>;
172 // else if (sk == "1is") Skel = oneIsthmus<Complex>;
173 // else if (sk == "is") Skel = skelIsthmus<Complex>;
174 } else if(sk == "isthmus1" || sk == "1ishtmus") {
175 Skel = [&isthmus_table, &pointMap](const Complex& fc,
176 const ComplexCell& c) {
177 return DGtal::functions::skelWithTable(isthmus_table, pointMap, fc, c);
178 };
179 } else if(sk == "isthmus") {
180 Skel = [&isthmus_table, &pointMap](const Complex& fc,
181 const ComplexCell& c) {
182 return DGtal::functions::skelWithTable(isthmus_table, pointMap, fc, c);
183 };
184 } else {
185 throw std::runtime_error("Invalid skel string");
186 }
187
188 // SELECT FUNCTION
189 std::function<std::pair<typename Complex::Cell, typename Complex::Data>(
190 const ComplexClique&)>
191 Select;
192
193 // profile
194 auto start = std::chrono::system_clock::now();
195
196 // If dmax is chosen, but no distance_transform is provided, create one.
197 using DT = TDistanceTransform;
198 using DTDigitalSet = typename DT::PointPredicate;
199 using DTDigitalSetDomain = typename DTDigitalSet::Domain;
200 using Metric = typename DT::SeparableMetric;
201 Metric l3;
202 auto &sel = skel_select_type_str;
203 const bool compute_distance_transform = !distance_transform && sel == "dmax";
204 DTDigitalSetDomain vc_domain = compute_distance_transform ?
205 DTDigitalSetDomain(vc.space().lowerBound(), vc.space().upperBound()) :
206 // dummy domain
207 DTDigitalSetDomain(Z3i::Point::zero, Z3i::Point::diagonal(1));
208
209 DTDigitalSet image_set = DTDigitalSet(vc_domain);
210 if(compute_distance_transform) {
211 vc.dumpVoxels(image_set);
212 }
213 // Create the distance map here (computationally expensive if not dummy).
214 DT dist_map(vc_domain, image_set, l3);
215 if(compute_distance_transform) {
216 distance_transform = &dist_map;
217 }
218
219 if(sel == "random") {
220 Select = DGtal::functions::selectRandom<Complex>;
221 } else if(sel == "first") {
222 Select = DGtal::functions::selectFirst<Complex>;
223 } else if(sel == "dmax") {
224 Select = [&distance_transform](const ComplexClique& clique) {
225 return selectMaxValue<TDistanceTransform, Complex>(*distance_transform, clique);
226 };
227 } else {
228 throw std::runtime_error("Invalid skel select type");
229 }
230
231 // Perform the thin/skeletonization
232 Complex vc_new(vc.space());
233 if(persistence == 0) {
234 vc_new = DGtal::functions::asymetricThinningScheme<Complex>(vc, Select, Skel, verbose);
235 } else {
236 vc_new = DGtal::functions::persistenceAsymetricThinningScheme<Complex>(vc, Select, Skel,
237 persistence, verbose);
238 }
239
240 // profile
241 auto end = std::chrono::system_clock::now();
242 auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(end - start);
243 if(profile) {
244 std::cout << "Time elapsed: " << elapsed.count() << std::endl;
245 }
246
247 return vc_new;
248}
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
Space::Point Point
Definition StdDefs.h:168
DGtal::LinearOperator< Calculus, dim, duality, dim, duality > diagonal(const DGtal::KForm< Calculus, dim, duality > &kform)
Definition DECHelpers.h:60
bool skelWithTable(const boost::dynamic_bitset<> &table, const std::unordered_map< typename TComplex::Point, unsigned int > &pointToMaskMap, const TComplex &vc, const typename TComplex::Cell &cell)
DGtal::CountedPtr< boost::dynamic_bitset<> > loadTable(const std::string &input_filename, const unsigned int known_size, const bool compressed=true)

References DGtal::Trace::beginBlock(), DGtal::PointVector< dim, Integer >::diagonal(), DGtal::Trace::endBlock(), DGtal::Trace::info(), loadTable(), skelWithTable(), DGtal::trace, and DGtal::PointVector< dim, Integer >::zero.

◆ twoIsthmus()

template<typename TComplex >
bool DGtal::functions::twoIsthmus ( const TComplex &  vc,
const typename TComplex::Cell &  cell 
)

Check if input cell is a 2-isthmus. A voxel is a 2-isthmus if, after a thinning, its proper neighborhood is a 1-Surface isOneSurface.

See also
isOneSurface
Object::properNeighborhood
Template Parameters
TComplexVoxelComplex.
Parameters
vcinput complex.
cellapply function on input cell.
Returns
bool