DGtal  0.9.4.1
VoxelComplexFunctions.h
1 
17 #pragma once
18 
32 #if defined(VoxelComplexFunctions_RECURSES)
33 #error Recursive header files inclusion detected in VoxelComplexFunctions.h
34 #else // defined(VoxelComplexFunctions_RECURSES)
35 
36 #define VoxelComplexFunctions_RECURSES
37 
38 #if !defined VoxelComplexFunctions_h
39 
40 #define VoxelComplexFunctions_h
41 
43 // Inclusions
44 #include <iostream>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/topology/VoxelComplex.h"
48 namespace DGtal
49 {
50  namespace functions {
51 
52  template < typename TComplex >
53  TComplex
55  TComplex & vc ,
56  std::function<
57  std::pair<typename TComplex::Cell, typename TComplex::Data> (
58  const typename TComplex::Clique &)
59  > Select ,
60  std::function<
61  bool(
62  const TComplex & ,
63  const typename TComplex::Cell & )
64  > Skel,
65  bool verbose = false
66  );
67 
68  template < typename TComplex >
69  TComplex
71  TComplex & vc ,
72  std::function<
73  std::pair<typename TComplex::Cell, typename TComplex::Data> (
74  const typename TComplex::Clique &)
75  > Select ,
76  std::function<
77  bool(
78  const TComplex & ,
79  const typename TComplex::Cell & )
80  > Skel,
81  uint32_t persistence,
82  bool verbose = false
83  );
85 // Select Functions
94  template < typename TComplex >
95  std::pair<typename TComplex::Cell, typename TComplex::Data>
97  const typename TComplex::Clique & clique);
98 
107  template < typename TComplex >
108  std::pair<typename TComplex::Cell, typename TComplex::Data>
109  selectRandom(
110  const typename TComplex::Clique & clique);
111 
122  template < typename TComplex, typename TRandomGenerator >
123  std::pair<typename TComplex::Cell, typename TComplex::Data>
124  selectRandom(
125  const typename TComplex::Clique & clique,
126  TRandomGenerator & gen);
127 
153  template < typename TDistanceTransform, typename TComplex >
154  std::pair<typename TComplex::Cell, typename TComplex::Data>
156  const TDistanceTransform & dist_map,
157  const typename TComplex::Clique & clique);
159 // Skeleton Functions
176  template < typename TComplex >
177  bool
178  skelUltimate(
179  const TComplex & vc,
180  const typename TComplex::Cell & cell);
181 
191  template < typename TComplex >
192  bool
193  skelEnd(
194  const TComplex & vc,
195  const typename TComplex::Cell & cell);
196 
210  template < typename TComplex >
211  bool
212  skelSimple(
213  const TComplex & vc,
214  const typename TComplex::Cell & cell);
215 
228  template < typename TComplex >
229  bool
230  skelIsthmus(
231  const TComplex & vc,
232  const typename TComplex::Cell & cell);
233 
249  template < typename TComplex >
250  bool
251  oneIsthmus(
252  const TComplex & vc,
253  const typename TComplex::Cell & cell);
254 
269  template < typename TComplex >
270  bool
271  twoIsthmus(
272  const TComplex & vc,
273  const typename TComplex::Cell & cell);
274 
313  template < typename TComplex >
314  bool
316  const boost::dynamic_bitset<> & table,
317  const std::unordered_map<typename TComplex::Point, unsigned int> & pointToMaskMap,
318  const TComplex & vc,
319  const typename TComplex::Cell & cell);
321 // Helpers for Objects
332  template < typename TObject >
333  bool
334  isZeroSurface(const TObject & small_obj) ;
335 
349  template < typename TObject >
350  bool
351  isOneSurface(const TObject & small_obj) ;
352 
361  template <typename TObject >
362  std::vector< TObject >
363  connectedComponents(const TObject & input_obj, bool verbose);
364 
365 
367 //Operators between VoxelComplexes//
368 
380  template <typename TKSpace, typename TObject, typename TCellContainer>
381  inline VoxelComplex< TKSpace, TObject, TCellContainer >&
384  {
386  for ( Dimension i = 0; i <= VC::dimension; ++i )
387  setops::operator-=( S1.myCells[ i ],S2.myCells[ i ] );
388  // Update Object. Assuming is an AssociativeContainer
389  auto & S1ObjPoints = S1.myObject.pointSet();
390  const auto & S2ObjPoints = S2.myObject.pointSet();
391  for(auto it2 = S2ObjPoints.begin(); it2 != S2ObjPoints.end(); ++it2)
392  {
393  const auto it_search = S1ObjPoints.find(*it2);
394  if(it_search != S1ObjPoints.end())
395  S1ObjPoints.erase(it_search);
396  }
397  return S1;
398  }
399 
411  template <typename TKSpace, typename TObject, typename TCellContainer>
415  {
417  VC S = S1;
418  for ( Dimension i = 0; i <= VC::dimension; ++i )
419  setops::operator-=( S.myCells[ i ],S2.myCells[ i ] );
420  // Update Object. Assuming is an AssociativeContainer
421  auto & SObjPoints = S.myObject.pointSet();
422  const auto & S2ObjPoints = S2.myObject.pointSet();
423  for(auto it2 = S2ObjPoints.begin(); it2 != S2ObjPoints.end(); ++it2)
424  {
425  auto it_search = SObjPoints.find(*it2);
426  if(it_search != SObjPoints.end())
427  SObjPoints.erase(it_search);
428  }
429  return S;
430  }
431 
432  } // namespace functions
433 } // namespace DGtal
434 
435 
437 // Includes inline functions.
438 #include "DGtal/topology/VoxelComplexFunctions.ih"
439 
440 // //
442 
443 #endif // !defined VoxelComplexFunctions_h
444 
445 #undef VoxelComplexFunctions_RECURSES
446 #endif // else defined(VoxelComplexFunctions_RECURSES)
boost::uint32_t uint32_t
unsigned 32-bit integer.
Definition: BasicTypes.h:63
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)
DGtal::uint32_t Dimension
Definition: Common.h:120
CubicalComplex< TKSpace, TCellContainer > & operator-=(CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
bool twoIsthmus(const TComplex &vc, const typename TComplex::Cell &cell)
This class represents a voxel complex living in some Khalimsky space. Voxel complexes are derived fro...
Definition: VoxelComplex.h:52
std::vector< TObject > connectedComponents(const TObject &input_obj, bool verbose)
bool oneIsthmus(const TComplex &vc, const typename TComplex::Cell &cell)
bool isOneSurface(const TObject &small_obj)
std::pair< typename TComplex::Cell, typename TComplex::Data > selectRandom(const typename TComplex::Clique &clique)
bool skelIsthmus(const TComplex &vc, const typename TComplex::Cell &cell)
bool skelSimple(const TComplex &vc, const typename TComplex::Cell &cell)
std::pair< typename TComplex::Cell, typename TComplex::Data > selectFirst(const typename TComplex::Clique &clique)
bool skelEnd(const TComplex &vc, const typename TComplex::Cell &cell)
bool isZeroSurface(const TObject &small_obj)
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)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::vector< CellMap > myCells
CubicalComplex< TKSpace, TCellContainer > operator-(const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
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)
std::pair< typename TComplex::Cell, typename TComplex::Data > selectMaxValue(const TDistanceTransform &dist_map, const typename TComplex::Clique &clique)
bool skelUltimate(const TComplex &vc, const typename TComplex::Cell &cell)
KSpace::Cell Cell