DGtal 2.1.0
Loading...
Searching...
No Matches
ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M > Class Template Reference

Public Member Functions

 ArrayXYOfLabelledMap ()
 
const Valuevalue (unsigned int l, unsigned int x, unsigned int y) const
 
void setValue (const Value &val, unsigned int l, unsigned int x, unsigned int y)
 
unsigned int erase (unsigned int l, unsigned int x, unsigned int y)
 
void setValueNoNewLabel (const Value &val, unsigned int l, unsigned int x, unsigned int y)
 
bool hasLabel (unsigned int l, unsigned int x, unsigned int y) const
 
void getLabels (std::vector< unsigned int > &labels, unsigned int x, unsigned int y) const
 
unsigned int nbLabels (unsigned int x, unsigned int y) const
 
void display (ostream &, unsigned int, unsigned int x, unsigned int y)
 
unsigned long long area () const
 

Private Types

typedef LabelledMap< Value, L, TWord, N, M > MyLabelledMap
 

Private Attributes

MyLabelledMap _data [X][Y]
 

Detailed Description

template<typename Value, unsigned int L, unsigned int X, unsigned int Y, typename TWord, unsigned int N, unsigned int M>
class ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >

Array[X][Y] of LabelledMap<L>

The proposed alternative to the brute-force approach. Generally less than 10 times the memory used by brute force for L >= 16. Approximately 50% slower in most operations, except initialization or used of all labels. In this case outperforms Array[L][X][Y].

Note that 4000*4000*16 is fine on my 8Gb laptop (529Mb). Note that 2000*2000*64 takes 133Mb.

Definition at line 412 of file testLabelledMap-benchmark.cpp.

Member Typedef Documentation

◆ MyLabelledMap

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
typedef LabelledMap< Value, L, TWord, N, M> ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::MyLabelledMap
private

Definition at line 413 of file testLabelledMap-benchmark.cpp.

Constructor & Destructor Documentation

◆ ArrayXYOfLabelledMap()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::ArrayXYOfLabelledMap ( )
inline

Definition at line 418 of file testLabelledMap-benchmark.cpp.

418{}

Member Function Documentation

◆ area()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
unsigned long long ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::area ( ) const
inline

Definition at line 468 of file testLabelledMap-benchmark.cpp.

469 {
470 unsigned long long total = 0;
471 for ( unsigned int y = 0; y < Y; ++y )
472 for ( unsigned int x = 0; x < X; ++x )
473 {
474 unsigned int size = nbLabels( x, y );
475 total += sizeof( MyLabelledMap );
476 if ( size > (N+1) )
477 total += ( 1 + ( size - N - 1 ) / M ) * ( M * sizeof( Value ) + 8 );
478 }
479 return total;
480 }
LabelledMap< Value, L, TWord, N, M > MyLabelledMap
unsigned int nbLabels(unsigned int x, unsigned int y) const

References ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::nbLabels().

◆ display()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
void ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::display ( ostream &  ,
unsigned int  ,
unsigned int  x,
unsigned int  y 
)
inline

Definition at line 462 of file testLabelledMap-benchmark.cpp.

463 {
464 std::cerr << _data[ x ][ y ] << endl;
465 }

References ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::_data.

◆ erase()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
unsigned int ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::erase ( unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

Definition at line 433 of file testLabelledMap-benchmark.cpp.

434 {
435 return _data[ x ][ y ].erase( l );
436 }
void erase(Iterator position)

References ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::_data, and DGtal::LabelledMap< TData, L, TWord, N, M >::erase().

◆ getLabels()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
void ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::getLabels ( std::vector< unsigned int > &  labels,
unsigned int  x,
unsigned int  y 
) const
inline

Definition at line 451 of file testLabelledMap-benchmark.cpp.

453 {
454 _data[ x ][ y ].labels().getLabels( labels );
455 }
const LabelsType & labels() const
void getLabels(std::vector< Label > &labels) const

References ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::_data, DGtal::Labels< L, TWord >::getLabels(), and DGtal::LabelledMap< TData, L, TWord, N, M >::labels().

◆ hasLabel()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
bool ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::hasLabel ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

Definition at line 445 of file testLabelledMap-benchmark.cpp.

446 {
447 return _data[ x ][ y ].count( l );
448 }
SizeType count(const Key &key) const

References ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::_data, and DGtal::LabelledMap< TData, L, TWord, N, M >::count().

◆ nbLabels()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
unsigned int ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::nbLabels ( unsigned int  x,
unsigned int  y 
) const
inline

◆ setValue()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
void ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::setValue ( const Value val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

Definition at line 427 of file testLabelledMap-benchmark.cpp.

428 {
429 _data[ x ][ y ][ l ] = val;
430 }

References ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::_data.

◆ setValueNoNewLabel()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
void ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::setValueNoNewLabel ( const Value val,
unsigned int  l,
unsigned int  x,
unsigned int  y 
)
inline

Definition at line 439 of file testLabelledMap-benchmark.cpp.

440 {
441 _data[ x ][ y ].fastAt( l ) = val;
442 }
Data & fastAt(const Key &key)

References ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::_data, and DGtal::LabelledMap< TData, L, TWord, N, M >::fastAt().

◆ value()

template<typename Value , unsigned int L, unsigned int X, unsigned int Y, typename TWord , unsigned int N, unsigned int M>
const Value & ArrayXYOfLabelledMap< Value, L, X, Y, TWord, N, M >::value ( unsigned int  l,
unsigned int  x,
unsigned int  y 
) const
inline

Field Documentation

◆ _data


The documentation for this class was generated from the following file: