DGtal  1.3.beta
Public Types | Static Public Attributes | Protected Types | Protected Attributes | Private Member Functions
DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K > Class Template Reference

Aim: A class that models a \( (2k+1)^d \) neighborhood and that provides services to analyse the convexity properties of a digital set within this neighborhood. More...

#include <DGtal/geometry/volumes/NeighborhoodConvexityAnalyzer.h>

Public Types

typedef NeighborhoodConvexityAnalyzer< TKSpace, KSelf
 
typedef TKSpace KSpace
 
typedef KSpace::Space Space
 
typedef KSpace::Integer Integer
 
typedef KSpace::Point Point
 
typedef KSpace::Vector Vector
 
typedef KSpace::Cell Cell
 
typedef std::vector< PointPointRange
 
typedef HyperRectDomain< SpaceDomain
 
typedef std::size_t Size
 
typedef std::bitset< functions::const_pow(2 *K+1, dimension) > Configuration
 
typedef std::bitset< 9 > BasicConfiguration
 

Static Public Attributes

static const Dimension dimension = KSpace::dimension
 
static const Size neigh_size = functions::const_pow( 2*K+1, dimension )
 
static const Size middle = functions::const_middle( K, dimension )
 
static const bool false_positive = ( dimension > 2 ) || ( K > 1 )
 

Protected Types

enum  Computation {
  FullConvexity_X_with_center = 0x1, FullConvexity_X_without_center = 0x2, FullConvexity_CompX_with_center = 0x4, FullConvexity_CompX_without_center = 0x8,
  Convexity_X_with_center = 0x10, Convexity_X_without_center = 0x20, Convexity_CompX_with_center = 0x40, Convexity_CompX_without_center = 0x80
}
 Enum types indicating the possible type of local computations. More...
 

Protected Attributes

Domain myDomain
 The bounded domain in which computations are carried out. More...
 
DigitalConvexity< KSpacemyDigConv
 The digital convexity that is used for checking full convexity. More...
 
Point myCenter
 The current center of the neighborhood. More...
 
TimeStampMemoizer< Configuration, bool > myMemoizer
 The memoizer. More...
 
bool myCenterInX
 tells if the center belongs to X More...
 
Size myNbInX
 The number of points of the neighborhood that belongs to X (center omitted). More...
 
Configuration myCfgX
 Stores the local configuration for X (without the center) More...
 
std::vector< BasicConfigurationmyBasicCfgX
 Stores the basic local configurations associated to myCfgX, for speed-up. More...
 
std::bitset< 512 > myBasicFullConvexityTable
 Stores the full convexity property of the basic 3x3 neighborhood configurations. More...
 
std::bitset< 512 > myBasic0ConvexityTable
 Stores the 0-convexity property of the basic 3x3 neighborhood configurations. More...
 
int myComputations
 Stores which properties have already been computed. More...
 
int myResults
 Stores the properties boolean values. More...
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CCellularGridSpaceND< TKSpace >))
 
void computeBasicFullConvexityTable ()
 
bool checkBasicConfigurationsFullConvexity (bool compX, bool with_center) const
 
bool checkBasicConfigurations0Convexity (bool compX, bool with_center) const
 
void computeBasicConfigurations (Configuration cfg, std::vector< BasicConfiguration > &result) const
 
BasicConfiguration computeCentralBasicConfiguration (Configuration cfg, Dimension i, Dimension j) const
 

Standard services (construction, initialization, assignment)

 ~NeighborhoodConvexityAnalyzer ()=default
 
 NeighborhoodConvexityAnalyzer ()=default
 
 NeighborhoodConvexityAnalyzer (const Self &other)=default
 
 NeighborhoodConvexityAnalyzer (Clone< KSpace > aKSpace, Size memoizer_size=0)
 
 NeighborhoodConvexityAnalyzer (Point lo, Point hi, Size memoizer_size=0)
 
Selfoperator= (const Self &other)=default
 
const KSpacespace () const
 
const Domaindomain () const
 
static int radius ()
 
static Size size ()
 

Neighborhood and convexity services

template<typename PointPredicate >
void setCenter (Point c, const PointPredicate &X)
 
Point center () const
 
Configuration configuration () const
 
bool isCenterInX () const
 Tells if the current center belongs to the shape X. More...
 
bool isFullyConvexCollapsible ()
 
bool isLikelyNoise ()
 
bool is0ConvexCollapsible ()
 
bool isFullyConvex (bool with_center)
 
bool isComplementaryFullyConvex (bool with_center)
 
bool is0Convex (bool with_center)
 
bool isComplementary0Convex (bool with_center)
 
void getLocalX (std::vector< Point > &localX, bool with_center) const
 
void getLocalCompX (std::vector< Point > &localCompX, bool with_center) const
 
static Configuration makeConfiguration (Configuration current, bool complement, bool with_center)
 

Detailed Description

template<typename TKSpace, int K>
class DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >

Aim: A class that models a \( (2k+1)^d \) neighborhood and that provides services to analyse the convexity properties of a digital set within this neighborhood.

Description of template class 'NeighborhoodConvexityAnalyzer'

It is a model of boost::CopyConstructible, boost::DefaultConstructible, boost::Assignable.

Template Parameters
TKSpacean arbitrary model of CCellularGridSpaceND.
Kthe parameter that determines the size of the neighborhood along all dimensions (spans 2K+1 points in each direction, hence the neighborhood cardinal is \( (2K+1)^d \)).
Note
This quite a heavy class since it tries to optimize computations in several ways:
  • it builds look-up tables for 0-convexity and full convexity for the 2D 3x3 neighborhood case, and uses them afterwards.
  • it memorizes convexity computations (w/o center, w/o complement) while you stay at the same center point;
  • it checks full convexity on small 3x3 2D slices before checking global nD full convexity.
  • it memoizes the full convexity result, so frequent configurations are not recomputed.
  • you can switch on/off the memoizer at object construction (e.g. it is useless in 2D).
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp, geometry/volumes/fullConvexityCollapsiblePoints2D.cpp, geometry/volumes/fullConvexityLUT2D.cpp, and geometry/volumes/fullConvexityThinning3D.cpp.

Definition at line 94 of file NeighborhoodConvexityAnalyzer.h.

Member Typedef Documentation

◆ BasicConfiguration

template<typename TKSpace , int K>
typedef std::bitset< 9 > DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::BasicConfiguration

Definition at line 116 of file NeighborhoodConvexityAnalyzer.h.

◆ Cell

template<typename TKSpace , int K>
typedef KSpace::Cell DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Cell

Definition at line 105 of file NeighborhoodConvexityAnalyzer.h.

◆ Configuration

template<typename TKSpace , int K>
typedef std::bitset< functions::const_pow( 2*K+1, dimension ) > DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Configuration

Definition at line 115 of file NeighborhoodConvexityAnalyzer.h.

◆ Domain

template<typename TKSpace , int K>
typedef HyperRectDomain<Space> DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Domain

Definition at line 107 of file NeighborhoodConvexityAnalyzer.h.

◆ Integer

template<typename TKSpace , int K>
typedef KSpace::Integer DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Integer

Definition at line 102 of file NeighborhoodConvexityAnalyzer.h.

◆ KSpace

template<typename TKSpace , int K>
typedef TKSpace DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::KSpace

Definition at line 100 of file NeighborhoodConvexityAnalyzer.h.

◆ Point

template<typename TKSpace , int K>
typedef KSpace::Point DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Point

Definition at line 103 of file NeighborhoodConvexityAnalyzer.h.

◆ PointRange

template<typename TKSpace , int K>
typedef std::vector<Point> DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::PointRange

Definition at line 106 of file NeighborhoodConvexityAnalyzer.h.

◆ Self

template<typename TKSpace , int K>
typedef NeighborhoodConvexityAnalyzer<TKSpace,K> DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Self

Definition at line 99 of file NeighborhoodConvexityAnalyzer.h.

◆ Size

template<typename TKSpace , int K>
typedef std::size_t DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Size

Definition at line 108 of file NeighborhoodConvexityAnalyzer.h.

◆ Space

template<typename TKSpace , int K>
typedef KSpace::Space DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Space

Definition at line 101 of file NeighborhoodConvexityAnalyzer.h.

◆ Vector

template<typename TKSpace , int K>
typedef KSpace::Vector DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::Vector

Definition at line 104 of file NeighborhoodConvexityAnalyzer.h.

Member Enumeration Documentation

◆ Computation

template<typename TKSpace , int K>
enum DGtal::NeighborhoodConvexityAnalyzer::Computation
protected

Enum types indicating the possible type of local computations.

Enumerator
FullConvexity_X_with_center 
FullConvexity_X_without_center 
FullConvexity_CompX_with_center 
FullConvexity_CompX_without_center 
Convexity_X_with_center 
Convexity_X_without_center 
Convexity_CompX_with_center 
Convexity_CompX_without_center 

Definition at line 528 of file NeighborhoodConvexityAnalyzer.h.

Constructor & Destructor Documentation

◆ ~NeighborhoodConvexityAnalyzer()

template<typename TKSpace , int K>
DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::~NeighborhoodConvexityAnalyzer ( )
default

Destructor.

◆ NeighborhoodConvexityAnalyzer() [1/4]

template<typename TKSpace , int K>
DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::NeighborhoodConvexityAnalyzer ( )
default

Constructor. Invalid object.

◆ NeighborhoodConvexityAnalyzer() [2/4]

template<typename TKSpace , int K>
DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::NeighborhoodConvexityAnalyzer ( const Self other)
default

Copy constructor.

Parameters
otherthe object to clone.

◆ NeighborhoodConvexityAnalyzer() [3/4]

template<typename TKSpace , int K>
DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::NeighborhoodConvexityAnalyzer ( Clone< KSpace aKSpace,
Size  memoizer_size = 0 
)
inline

◆ NeighborhoodConvexityAnalyzer() [4/4]

template<typename TKSpace , int K>
DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::NeighborhoodConvexityAnalyzer ( Point  lo,
Point  hi,
Size  memoizer_size = 0 
)
inline

Constructor from lower and upper points.

Parameters
lothe lowest point of the domain (bounding box for computations).
hithe highest point of the domain (bounding box for computations).
memoizer_sizeif 0, no memoizer is used (useless in 2D), otherwise it is the maximal number of memoized elements.

Definition at line 166 of file NeighborhoodConvexityAnalyzer.h.

168  : myDomain( lo, hi ), myDigConv( lo, hi ), myMemoizer( memoizer_size )
169  {
170  myComputations = 0;
171  myResults = 0;
173  trace.info() << "Size=" << size() << " middle=" << middle << std::endl;
174  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::computeBasicFullConvexityTable(), DGtal::Trace::info(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::middle, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myComputations, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myResults, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::size(), and DGtal::trace.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TKSpace , int K>
DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::BOOST_CONCEPT_ASSERT ( (concepts::CCellularGridSpaceND< TKSpace >)  )
private

◆ center()

template<typename TKSpace , int K>
Point DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::center ( ) const
inline
Returns
the current center.

Definition at line 225 of file NeighborhoodConvexityAnalyzer.h.

226  {
227  return myCenter;
228  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myCenter.

◆ checkBasicConfigurations0Convexity()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::checkBasicConfigurations0Convexity ( bool  compX,
bool  with_center 
) const
private

For the current configuration, checks if all the 2D slices of the configuration are 0-convex (for speed-up). They must be all true for the global nD configuration to be 0-convex.

Parameters
compXwhen 'true', complements the configuration.
with_centerwhen 'true', makes the center point part of the configuration
Returns
'true' if they are all 0-convex.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::is0Convex(), and DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementary0Convex().

◆ checkBasicConfigurationsFullConvexity()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::checkBasicConfigurationsFullConvexity ( bool  compX,
bool  with_center 
) const
private

For the current configuration, checks if all the 2D slices of the configuration are fully convex (for speed-up). They must be all true for the global nD configuration to be fully convex.

Parameters
compXwhen 'true', complements the configuration.
with_centerwhen 'true', makes the center point part of the configuration
Returns
'true' if they are all fully convex.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementaryFullyConvex(), and DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isFullyConvex().

◆ computeBasicConfigurations()

template<typename TKSpace , int K>
void DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::computeBasicConfigurations ( Configuration  cfg,
std::vector< BasicConfiguration > &  result 
) const
private

Given a configuration cfg, outputs all the 2D slice configurations in result.

Parameters
[in]cfgany configuration in nD
[out]resultthe vector of all basic configurations (i.e. 3x3) within each possible 2D local slice.

◆ computeBasicFullConvexityTable()

template<typename TKSpace , int K>
void DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::computeBasicFullConvexityTable ( )
private

Precomputes the table storing for each basic configuration if it is fully convex.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::NeighborhoodConvexityAnalyzer().

◆ computeCentralBasicConfiguration()

template<typename TKSpace , int K>
BasicConfiguration DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::computeCentralBasicConfiguration ( Configuration  cfg,
Dimension  i,
Dimension  j 
) const
private

Given a configuration cfg, returns the central 3x3 configuration of the 2D slice along coordinates i and j.

Parameters
[in]cfgany configuration in nD
[in]iany dimension
[in]jany other dimension
Returns
the central 3x3 configuration of the 2D slice along coordinates i and j.

◆ configuration()

template<typename TKSpace , int K>
Configuration DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::configuration ( ) const
inline
Returns
the current configuration.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp.

Definition at line 231 of file NeighborhoodConvexityAnalyzer.h.

232  {
233  return myCfgX;
234  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myCfgX.

◆ domain()

template<typename TKSpace , int K>
const Domain& DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::domain ( ) const
inline
Returns
a const reference to the domain used by this object.

Definition at line 190 of file NeighborhoodConvexityAnalyzer.h.

191  {
192  return myDomain;
193  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myDomain.

◆ getLocalCompX()

template<typename TKSpace , int K>
void DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::getLocalCompX ( std::vector< Point > &  localCompX,
bool  with_center 
) const
Parameters
[in,out]localCompXas output, the set of points of the neighborhood not belonging to the shape
[in]with_centerif 'true' adds the center point.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementary0Convex(), and DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementaryFullyConvex().

◆ getLocalX()

template<typename TKSpace , int K>
void DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::getLocalX ( std::vector< Point > &  localX,
bool  with_center 
) const
Parameters
[in,out]localXas output, the set of points of the neighborhood belonging to the shape
[in]with_centerif 'true' adds the center point.
Examples
geometry/volumes/fullConvexityThinning3D.cpp.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::is0Convex(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isFullyConvex(), and main().

◆ is0Convex()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::is0Convex ( bool  with_center)
inline

Tells if the shape is locally digitally 0-convex.

Parameters
with_centerif 'true' add the center to the digital set.
Returns
'true' iff the local neighborhood of X (with/without the center) is 0 convex

Definition at line 424 of file NeighborhoodConvexityAnalyzer.h.

425  {
426  int mask = with_center
428  if ( myComputations & mask ) return bool( myResults & mask );
429  // Need to compute full convexity property
430  bool ok = checkBasicConfigurations0Convexity( false, with_center );
431  if ( ok && false_positive )
432  { // need to do the true computation.
433  std::vector< Point > localX;
434  getLocalX( localX, with_center );
435  ok = myDigConv.is0Convex( localX );
436  }
437  myComputations |= mask;
438  if ( ok ) myResults |= mask;
439  return ok;
440  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::checkBasicConfigurations0Convexity(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::false_positive, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::FullConvexity_X_with_center, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::FullConvexity_X_without_center, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::getLocalX(), DGtal::DigitalConvexity< TKSpace >::is0Convex(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myComputations, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myDigConv, and DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myResults.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::is0ConvexCollapsible().

◆ is0ConvexCollapsible()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::is0ConvexCollapsible ( )
inline
Returns
'true' iff the center is locally 0-convex collapsible.
Examples
geometry/volumes/fullConvexityThinning3D.cpp.

Definition at line 271 of file NeighborhoodConvexityAnalyzer.h.

272  {
273  if ( isCenterInX() )
274  return ( myNbInX >= 1 ) // ( ! myLocalX.empty() )
275  && is0Convex( true )
276  && is0Convex( false );
277  else
278  return ( size() - myNbInX >= 2 ) // ( ! myLocalCompX.empty() )
279  && isComplementary0Convex( true )
280  && isComplementary0Convex( false );
281  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::is0Convex(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isCenterInX(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementary0Convex(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myNbInX, and DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::size().

Referenced by main().

◆ isCenterInX()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isCenterInX ( ) const
inline

◆ isComplementary0Convex()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementary0Convex ( bool  with_center)
inline

Tells if the complementary of the shape is locally digitally 0-convex.

Parameters
with_centerif 'true' add the center to the digital set.
Returns
'true' iff the local neighborhood of the complementary of X (with/without the center) is 0 convex

Definition at line 447 of file NeighborhoodConvexityAnalyzer.h.

448  {
449  int mask = with_center
451  if ( myComputations & mask ) return bool( myResults & mask );
452  // Need to compute full convexity property
453  bool ok = checkBasicConfigurations0Convexity( true, with_center );
454  if ( ok && false_positive )
455  { // need to do the true computation.
456  std::vector< Point > localCompX;
457  getLocalCompX( localCompX, with_center );
458  ok = myDigConv.is0Convex( localCompX );
459  }
460  myComputations |= mask;
461  if ( ok ) myResults |= mask;
462  return ok;
463  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::checkBasicConfigurations0Convexity(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::false_positive, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::FullConvexity_CompX_with_center, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::FullConvexity_CompX_without_center, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::getLocalCompX(), DGtal::DigitalConvexity< TKSpace >::is0Convex(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myComputations, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myDigConv, and DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myResults.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::is0ConvexCollapsible().

◆ isComplementaryFullyConvex()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementaryFullyConvex ( bool  with_center)
inline

Tells if the complementary of the shape is locally fully convex.

Parameters
with_centerif 'true' add the center to the digital set.
Returns
'true' iff the local neighborhood of the complementary of X (with/without the center) is fully convex
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp.

Definition at line 355 of file NeighborhoodConvexityAnalyzer.h.

356  {
357  int mask = with_center
359  if ( myComputations & mask ) return bool( myResults & mask );
360  bool ok;
361  // Check memoizer
362  if ( myMemoizer.isValid() )
363  {
364  auto cfg = makeConfiguration( myCfgX, true, with_center );
365  auto p = myMemoizer.get( cfg );
366  ok = p.first; // may not be correct
367  bool memoized = p.second;
368  if ( ! memoized )
369  {
370  // Need to compute full convexity property
371  ok = checkBasicConfigurationsFullConvexity( true, with_center );
372  if ( ok && false_positive )
373  { // need to do the true computation.
374  std::vector< Point > localCompX;
375  getLocalCompX( localCompX, with_center );
376  ok = myDigConv.isFullyConvex( localCompX );
377  }
378  myMemoizer.set( cfg, ok );
379  }
380  }
381  else
382  {
383  // Need to compute full convexity property
384  ok = checkBasicConfigurationsFullConvexity( true, with_center );
385  if ( ok && false_positive )
386  { // need to do the true computation.
387  std::vector< Point > localCompX;
388  getLocalCompX( localCompX, with_center );
389  ok = myDigConv.isFullyConvex( localCompX );
390  }
391  }
392  // bool memoized = false;
393  // auto cfg = makeConfiguration( myCfgX, true, with_center );
394  // // Check memoizer
395  // if ( myMemoizer.isValid() )
396  // {
397  // auto p = myMemoizer.get( cfg );
398  // ok = p.first; // may not be correct
399  // memoized = p.second;
400  // }
401  // if ( ! memoized )
402  // {
403  // // Need to compute full convexity property
404  // ok = checkBasicConfigurationsFullConvexity( true, with_center );
405  // if ( ok && false_positive )
406  // { // need to do the true computation.
407  // std::vector< Point > localCompX;
408  // getLocalCompX( localCompX, with_center );
409  // ok = myDigConv.isFullyConvex( localCompX );
410  // }
411  // if ( myMemoizer.isValid() )
412  // myMemoizer.set( cfg, ok );
413  // }
414  myComputations |= mask;
415  if ( ok ) myResults |= mask;
416  return ok;
417  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::checkBasicConfigurationsFullConvexity(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::false_positive, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::FullConvexity_CompX_with_center, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::FullConvexity_CompX_without_center, DGtal::TimeStampMemoizer< TKey, TValue >::get(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::getLocalCompX(), DGtal::DigitalConvexity< TKSpace >::isFullyConvex(), DGtal::TimeStampMemoizer< TKey, TValue >::isValid(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::makeConfiguration(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myCfgX, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myComputations, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myDigConv, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myMemoizer, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myResults, and DGtal::TimeStampMemoizer< TKey, TValue >::set().

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isFullyConvexCollapsible(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isLikelyNoise(), and main().

◆ isFullyConvex()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isFullyConvex ( bool  with_center)
inline

Tells if the shape X is locally fully convex.

Parameters
with_centerif 'true' add the center to the digital set.
Returns
'true' iff the local neighborhood of X (with/without the center) is fully convex
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp.

Definition at line 288 of file NeighborhoodConvexityAnalyzer.h.

289  {
290  int mask = with_center
292  if ( myComputations & mask ) return bool( myResults & mask );
293  bool ok;
294  // Check memoizer
295  if ( myMemoizer.isValid() )
296  {
297  auto cfg = makeConfiguration( myCfgX, false, with_center );
298  auto p = myMemoizer.get( cfg );
299  ok = p.first; // may not be correct
300  bool memoized = p.second;
301  if ( ! memoized )
302  {
303  // Need to compute full convexity property
304  ok = checkBasicConfigurationsFullConvexity( false, with_center );
305  if ( ok && false_positive )
306  { // need to do the true computation.
307  std::vector< Point > localX;
308  getLocalX( localX, with_center );
309  ok = myDigConv.isFullyConvex( localX );
310  }
311  myMemoizer.set( cfg, ok );
312  }
313  }
314  else
315  {
316  ok = checkBasicConfigurationsFullConvexity( false, with_center );
317  if ( ok && false_positive )
318  { // need to do the true computation.
319  std::vector< Point > localX;
320  getLocalX( localX, with_center );
321  ok = myDigConv.isFullyConvex( localX );
322  }
323  }
324  // auto cfg = makeConfiguration( myCfgX, false, with_center );
325  // // Check memoizer
326  // if ( myMemoizer.isValid() )
327  // {
328  // auto p = myMemoizer.get( cfg );
329  // ok = p.first; // may not be correct
330  // memoized = p.second;
331  // }
332  // if ( ! memoized )
333  // {
334  // // Need to compute full convexity property
335  // ok = checkBasicConfigurationsFullConvexity( false, with_center );
336  // if ( ok && false_positive )
337  // { // need to do the true computation.
338  // std::vector< Point > localX;
339  // getLocalX( localX, with_center );
340  // ok = myDigConv.isFullyConvex( localX );
341  // }
342  // if ( myMemoizer.isValid() )
343  // myMemoizer.set( cfg, ok );
344  // }
345  myComputations |= mask;
346  if ( ok ) myResults |= mask;
347  return ok;
348  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::checkBasicConfigurationsFullConvexity(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::false_positive, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::FullConvexity_X_with_center, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::FullConvexity_X_without_center, DGtal::TimeStampMemoizer< TKey, TValue >::get(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::getLocalX(), DGtal::DigitalConvexity< TKSpace >::isFullyConvex(), DGtal::TimeStampMemoizer< TKey, TValue >::isValid(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::makeConfiguration(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myCfgX, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myComputations, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myDigConv, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myMemoizer, DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myResults, and DGtal::TimeStampMemoizer< TKey, TValue >::set().

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isFullyConvexCollapsible(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isLikelyNoise(), and main().

◆ isFullyConvexCollapsible()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isFullyConvexCollapsible ( )
inline

◆ isLikelyNoise()

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isLikelyNoise ( )
inline
Returns
'true' iff the center point is likely noise.

Definition at line 256 of file NeighborhoodConvexityAnalyzer.h.

257  {
258  if ( isCenterInX() )
259  return ( myNbInX >= 1 ) // ( ! myLocalX.empty() )
260  && ! isFullyConvex( true )
261  && isFullyConvex( false )
262  && isComplementaryFullyConvex( true );
263  else
264  return ( size() - myNbInX >= 2 ) // ( ! myLocalCompX.empty() )
265  && ! isComplementaryFullyConvex( true )
266  && isComplementaryFullyConvex( false )
267  && isFullyConvex( true );
268  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isCenterInX(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementaryFullyConvex(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isFullyConvex(), DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myNbInX, and DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::size().

◆ makeConfiguration()

template<typename TKSpace , int K>
static Configuration DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::makeConfiguration ( Configuration  current,
bool  complement,
bool  with_center 
)
inlinestatic

Builds the final configuration from the configuration current, by complementing it according to complement, and by adding its center point according to with_center.

Parameters
currentany configuration (with empty center/middle bit)
complementwhen 'true', complements the configuration.
with_centerwhen 'true', makes the center point part of the configuration
Returns
the corresponding configuration
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp.

Definition at line 473 of file NeighborhoodConvexityAnalyzer.h.

475  {
476  if ( complement )
477  {
478  current.flip(); // current = ~current;
479  if ( ! with_center ) current.reset( middle );
480  else current.set( middle );
481  }
482  else
483  {
484  if ( with_center ) current.set( middle );
485  }
486  return current;
487  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::middle.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isComplementaryFullyConvex(), and DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isFullyConvex().

◆ operator=()

template<typename TKSpace , int K>
Self& DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::operator= ( const Self other)
default

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ radius()

template<typename TKSpace , int K>
static int DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::radius ( )
inlinestatic
Returns
the fixed parameter K of the neighborhood, which determines its size.

Definition at line 196 of file NeighborhoodConvexityAnalyzer.h.

197  { return K; }

References K.

◆ setCenter()

template<typename TKSpace , int K>
template<typename PointPredicate >
void DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::setCenter ( Point  c,
const PointPredicate &  X 
)

Place the center of the neighborhood at point c on shape X All subsequent computations and results are related to this point afterwards.

Template Parameters
PointPredicatean arbitrary model of concept::CPointPredicate
Parameters
cany point in the domain of the embedding space.
Xa predicate associating a boolean to any point, which corresponds to a characteristic function of a digital subset X of the digital space.
Examples
geometry/volumes/fullConvexityAnalysis3D.cpp, geometry/volumes/fullConvexityCollapsiblePoints2D.cpp, and geometry/volumes/fullConvexityThinning3D.cpp.

Referenced by main().

◆ size()

template<typename TKSpace , int K>
static Size DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::size ( )
inlinestatic

◆ space()

template<typename TKSpace , int K>
const KSpace& DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::space ( ) const
inline
Returns
a const reference to the cellular grid space used by this object.

Definition at line 184 of file NeighborhoodConvexityAnalyzer.h.

185  {
186  return myDigConv.space();
187  }

References DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myDigConv, and DGtal::DigitalConvexity< TKSpace >::space().

Field Documentation

◆ dimension

template<typename TKSpace , int K>
const Dimension DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::dimension = KSpace::dimension
static

Definition at line 110 of file NeighborhoodConvexityAnalyzer.h.

◆ false_positive

template<typename TKSpace , int K>
const bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::false_positive = ( dimension > 2 ) || ( K > 1 )
static

◆ middle

template<typename TKSpace , int K>
const Size DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::middle = functions::const_middle( K, dimension )
static

◆ myBasic0ConvexityTable

template<typename TKSpace , int K>
std::bitset< 512 > DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myBasic0ConvexityTable
protected

Stores the 0-convexity property of the basic 3x3 neighborhood configurations.

Definition at line 525 of file NeighborhoodConvexityAnalyzer.h.

◆ myBasicCfgX

template<typename TKSpace , int K>
std::vector< BasicConfiguration > DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myBasicCfgX
protected

Stores the basic local configurations associated to myCfgX, for speed-up.

Definition at line 520 of file NeighborhoodConvexityAnalyzer.h.

◆ myBasicFullConvexityTable

template<typename TKSpace , int K>
std::bitset< 512 > DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myBasicFullConvexityTable
protected

Stores the full convexity property of the basic 3x3 neighborhood configurations.

Definition at line 523 of file NeighborhoodConvexityAnalyzer.h.

◆ myCenter

template<typename TKSpace , int K>
Point DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myCenter
protected

The current center of the neighborhood.

Definition at line 510 of file NeighborhoodConvexityAnalyzer.h.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::center().

◆ myCenterInX

template<typename TKSpace , int K>
bool DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myCenterInX
protected

tells if the center belongs to X

Definition at line 514 of file NeighborhoodConvexityAnalyzer.h.

Referenced by DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::isCenterInX().

◆ myCfgX

template<typename TKSpace , int K>
Configuration DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myCfgX
protected

◆ myComputations

template<typename TKSpace , int K>
int DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myComputations
protected

◆ myDigConv

template<typename TKSpace , int K>
DigitalConvexity<KSpace> DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myDigConv
protected

◆ myDomain

template<typename TKSpace , int K>
Domain DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myDomain
protected

◆ myMemoizer

template<typename TKSpace , int K>
TimeStampMemoizer< Configuration, bool > DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myMemoizer
protected

◆ myNbInX

template<typename TKSpace , int K>
Size DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myNbInX
protected

◆ myResults

template<typename TKSpace , int K>
int DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::myResults
protected

◆ neigh_size

template<typename TKSpace , int K>
const Size DGtal::NeighborhoodConvexityAnalyzer< TKSpace, K >::neigh_size = functions::const_pow( 2*K+1, dimension )
static

The documentation for this class was generated from the following file:
DGtal::NeighborhoodConvexityAnalyzer::FullConvexity_CompX_with_center
@ FullConvexity_CompX_with_center
Definition: NeighborhoodConvexityAnalyzer.h:531
DGtal::NeighborhoodConvexityAnalyzer::myNbInX
Size myNbInX
The number of points of the neighborhood that belongs to X (center omitted).
Definition: NeighborhoodConvexityAnalyzer.h:516
DGtal::NeighborhoodConvexityAnalyzer::myCenterInX
bool myCenterInX
tells if the center belongs to X
Definition: NeighborhoodConvexityAnalyzer.h:514
DGtal::NeighborhoodConvexityAnalyzer::computeBasicFullConvexityTable
void computeBasicFullConvexityTable()
DGtal::NeighborhoodConvexityAnalyzer::isComplementaryFullyConvex
bool isComplementaryFullyConvex(bool with_center)
Definition: NeighborhoodConvexityAnalyzer.h:355
DGtal::NeighborhoodConvexityAnalyzer::Convexity_X_without_center
@ Convexity_X_without_center
Definition: NeighborhoodConvexityAnalyzer.h:534
DGtal::TimeStampMemoizer::get
std::pair< Value, bool > get(const Key &key)
Definition: TimeStampMemoizer.h:175
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::DigitalConvexity::is0Convex
bool is0Convex(const PointRange &X, bool safe=false) const
K
KSpace K
Definition: testCubicalComplex.cpp:62
DGtal::NeighborhoodConvexityAnalyzer::myCenter
Point myCenter
The current center of the neighborhood.
Definition: NeighborhoodConvexityAnalyzer.h:510
DGtal::NeighborhoodConvexityAnalyzer::myCfgX
Configuration myCfgX
Stores the local configuration for X (without the center)
Definition: NeighborhoodConvexityAnalyzer.h:518
DGtal::NeighborhoodConvexityAnalyzer::Domain
HyperRectDomain< Space > Domain
Definition: NeighborhoodConvexityAnalyzer.h:107
DGtal::TimeStampMemoizer::isValid
bool isValid() const
Definition: TimeStampMemoizer.h:238
DGtal::NeighborhoodConvexityAnalyzer::myResults
int myResults
Stores the properties boolean values.
Definition: NeighborhoodConvexityAnalyzer.h:541
DGtal::NeighborhoodConvexityAnalyzer::myDomain
Domain myDomain
The bounded domain in which computations are carried out.
Definition: NeighborhoodConvexityAnalyzer.h:506
DGtal::NeighborhoodConvexityAnalyzer::Convexity_X_with_center
@ Convexity_X_with_center
Definition: NeighborhoodConvexityAnalyzer.h:533
DGtal::Trace::info
std::ostream & info()
DGtal::NeighborhoodConvexityAnalyzer::middle
static const Size middle
Definition: NeighborhoodConvexityAnalyzer.h:112
DGtal::NeighborhoodConvexityAnalyzer::getLocalCompX
void getLocalCompX(std::vector< Point > &localCompX, bool with_center) const
DGtal::NeighborhoodConvexityAnalyzer::is0Convex
bool is0Convex(bool with_center)
Definition: NeighborhoodConvexityAnalyzer.h:424
DGtal::NeighborhoodConvexityAnalyzer::checkBasicConfigurationsFullConvexity
bool checkBasicConfigurationsFullConvexity(bool compX, bool with_center) const
DGtal::NeighborhoodConvexityAnalyzer::isCenterInX
bool isCenterInX() const
Tells if the current center belongs to the shape X.
Definition: NeighborhoodConvexityAnalyzer.h:237
DGtal::NeighborhoodConvexityAnalyzer::FullConvexity_X_with_center
@ FullConvexity_X_with_center
Definition: NeighborhoodConvexityAnalyzer.h:529
DGtal::NeighborhoodConvexityAnalyzer::FullConvexity_X_without_center
@ FullConvexity_X_without_center
Definition: NeighborhoodConvexityAnalyzer.h:530
DGtal::NeighborhoodConvexityAnalyzer::Convexity_CompX_without_center
@ Convexity_CompX_without_center
Definition: NeighborhoodConvexityAnalyzer.h:536
DGtal::NeighborhoodConvexityAnalyzer::isFullyConvex
bool isFullyConvex(bool with_center)
Definition: NeighborhoodConvexityAnalyzer.h:288
DGtal::NeighborhoodConvexityAnalyzer::isComplementary0Convex
bool isComplementary0Convex(bool with_center)
Definition: NeighborhoodConvexityAnalyzer.h:447
DGtal::NeighborhoodConvexityAnalyzer::FullConvexity_CompX_without_center
@ FullConvexity_CompX_without_center
Definition: NeighborhoodConvexityAnalyzer.h:532
DGtal::NeighborhoodConvexityAnalyzer::getLocalX
void getLocalX(std::vector< Point > &localX, bool with_center) const
DGtal::NeighborhoodConvexityAnalyzer::makeConfiguration
static Configuration makeConfiguration(Configuration current, bool complement, bool with_center)
Definition: NeighborhoodConvexityAnalyzer.h:473
DGtal::NeighborhoodConvexityAnalyzer::myComputations
int myComputations
Stores which properties have already been computed.
Definition: NeighborhoodConvexityAnalyzer.h:539
DGtal::NeighborhoodConvexityAnalyzer::myMemoizer
TimeStampMemoizer< Configuration, bool > myMemoizer
The memoizer.
Definition: NeighborhoodConvexityAnalyzer.h:512
DGtal::NeighborhoodConvexityAnalyzer::false_positive
static const bool false_positive
Definition: NeighborhoodConvexityAnalyzer.h:113
DGtal::NeighborhoodConvexityAnalyzer::checkBasicConfigurations0Convexity
bool checkBasicConfigurations0Convexity(bool compX, bool with_center) const
DGtal::DigitalConvexity::isFullyConvex
bool isFullyConvex(const PointRange &X, bool convex0=false, bool safe=false) const
DGtal::DigitalConvexity::space
const KSpace & space() const
DGtal::TimeStampMemoizer::set
void set(const Key &key, const Value &value)
Definition: TimeStampMemoizer.h:192
DGtal::NeighborhoodConvexityAnalyzer::size
static Size size()
Definition: NeighborhoodConvexityAnalyzer.h:201
DGtal::NeighborhoodConvexityAnalyzer::myDigConv
DigitalConvexity< KSpace > myDigConv
The digital convexity that is used for checking full convexity.
Definition: NeighborhoodConvexityAnalyzer.h:508
DGtal::NeighborhoodConvexityAnalyzer::neigh_size
static const Size neigh_size
Definition: NeighborhoodConvexityAnalyzer.h:111
DGtal::NeighborhoodConvexityAnalyzer::Convexity_CompX_with_center
@ Convexity_CompX_with_center
Definition: NeighborhoodConvexityAnalyzer.h:535