52 #ifndef __PCL_StructuringElement_h
53 #define __PCL_StructuringElement_h
58 #include <pcl/Diagnostics.h>
63 #include <pcl/Rotate.h>
136 : m_size(
Max( 3, size|1 ) )
137 , m_mask(
Max( 1, n ) )
138 , m_count( 0,
Max( 1, n ) )
140 PCL_PRECONDITION( size >= 3 )
141 PCL_PRECONDITION( (size & 1) != 0 )
142 PCL_PRECONDITION( n >= 1 )
143 for (
int k = 0; k < NumberOfWays(); ++k )
152 , m_mask( x.NumberOfWays() )
153 , m_count( 0, x.NumberOfWays() )
155 for (
int k = 0; k < NumberOfWays(); ++k )
185 for (
int k = 0; k < NumberOfWays(); ++k )
196 return int( m_mask.Length() );
213 return m_size*m_size;
230 PCL_PRECONDITION( k >= 0 && k < NumberOfWays() )
232 return m_count[k] == NumberOfElements();
249 PCL_PRECONDITION( i >= 0 && i < m_size )
250 PCL_PRECONDITION( j >= 0 && j < m_size )
251 PCL_PRECONDITION( k >= 0 && k < NumberOfWays() )
276 template <
typename T>
279 PCL_PRECONDITION( h1 != 0 )
280 PCL_PRECONDITION( h != 0 )
281 PCL_PRECONDITION( k >= 0 && k < NumberOfWays() )
303 pcl::Reverse( i->Begin(), i->End() );
304 m_reflected = !m_reflected;
340 if ( !m_initialized )
343 if ( m_initialized.Load() == 0 )
345 int N = NumberOfWays();
346 for (
int k = 0; k < N; ++k )
350 for (
int i = 0; i < m_size; ++i )
351 for (
int j = 0; j < m_size; ++j, ++m )
352 if ( ElementExists( i, j, k ) )
361 m_initialized.Store( 1 );
377 mutable existence_mask_set m_mask;
382 mutable existence_mask_count m_count;
387 bool m_reflected =
false;
397 mutable Mutex m_mutex;
454 PCL_PRECONDITION( k == 0 )
518 PCL_PRECONDITION( k == 0 )
526 PCL_PRECONDITION( i >= 0 && i < Size() )
527 PCL_PRECONDITION( j >= 0 && j < Size() )
528 PCL_PRECONDITION( k == 0 )
529 float n2 = 0.5F*Size();
530 float di = i+0.5F - n2;
531 float dj = j+0.5F - n2;
532 return di*di + dj*dj <= n2*n2;
590 PCL_PRECONDITION( k == 0 )
598 PCL_PRECONDITION( i >= 0 && i < Size() )
599 PCL_PRECONDITION( j >= 0 && j < Size() )
600 PCL_PRECONDITION( k == 0 )
601 int n2 = Size() >> 1;
602 return i == n2 || j == n2;
660 PCL_PRECONDITION( k == 0 )
668 PCL_PRECONDITION( i >= 0 && i < Size() )
669 PCL_PRECONDITION( j >= 0 && j < Size() )
670 PCL_PRECONDITION( k == 0 )
671 return j == i || j == Size()-i-1;
732 PCL_PRECONDITION( k == 0 )
740 PCL_PRECONDITION( i >= 0 && i < Size() )
741 PCL_PRECONDITION( j >= 0 && j < Size() )
742 PCL_PRECONDITION( k == 0 )
743 int n2 = Size() >> 1;
744 if ( i == n2 || j == n2 )
746 if ( j == i || j == Size()-i-1 )
748 float n2 = 0.5F*Size();
749 float di = i+0.5F - n2;
750 float dj = j+0.5F - n2;
751 return di*di + dj*dj <= n2*n2;
818 PCL_PRECONDITION( k >= 0 && k < 3 )
826 PCL_PRECONDITION( i >= 0 && i < Size() )
827 PCL_PRECONDITION( j >= 0 && j < Size() )
828 PCL_PRECONDITION( k >= 0 && k < 3 )
829 int n2 = Size() >> 1;
834 return i == n2 && j == n2;
836 return i == n2 || j == n2;
838 return (j == i || j == Size()-i-1) && i != n2;
916 PCL_PRECONDITION( bitmaps !=
nullptr )
917 PCL_PRECONDITION( *bitmaps !=
'\0' )
918 for (
int i = 0; i < NumberOfWays(); ++i )
919 m_bitmaps.Add(
bitmap( bitmaps[i] ) );
938 PCL_PRECONDITION( i >= 0 && i < Size() )
939 PCL_PRECONDITION( j >= 0 && j < Size() )
940 PCL_PRECONDITION( k >= 0 && k < NumberOfWays() )
941 return m_bitmaps[k][i + j*Size()] ==
'x';
946 bitmap_set m_bitmaps;
Atomic operations on integers.
Automatic mutex lock/unlock.
A structuring element where static strings are used to define custom existence matrices.
BitmapStructure(const char **bitmaps, int size, int n=1)
bool ElementExists(int i, int j, int k) const override
StructuringElement * Clone() const override
BitmapStructure(const BitmapStructure &)=default
Standard box (square) structure.
StructuringElement * Clone() const override
bool IsBox(int k) const override
BoxStructure(const BoxStructure &)=default
Standard circular structure.
bool IsBox(int k) const override
CircularStructure(int diameter)
bool ElementExists(int i, int j, int k) const override
StructuringElement * Clone() const override
CircularStructure(const CircularStructure &)=default
Standard diagonal structure.
bool IsBox(int k) const override
DiagonalStructure(const DiagonalStructure &)=default
StructuringElement * Clone() const override
bool ElementExists(int i, int j, int k) const override
DiagonalStructure(int size)
Generic vector of arbitrary length.
existence_mask * iterator
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Adaptive mutual exclusion lock variable.
Standard orthogonal structure.
StructuringElement * Clone() const override
OrthogonalStructure(int size)
bool ElementExists(int i, int j, int k) const override
bool IsBox(int k) const override
OrthogonalStructure(const OrthogonalStructure &)=default
StructuringElement * Clone() const override
bool IsBox(int k) const override
bool ElementExists(int i, int j, int k) const override
StarStructure(const StarStructure &)=default
Abstract base class of all PCL structuring elements.
StructuringElement(const StructuringElement &x)
virtual bool IsBox(int k) const
virtual ~StructuringElement()
virtual bool ElementExists(int i, int j, int k) const
int NumberOfElements() const
StructuringElement(int size=3, int n=1)
virtual StructuringElement * Clone() const =0
uint32 existence_mask_element
void PeekElements(T *h1, int &nh1, const T *h, int k) const
Standard three-way structure.
StructuringElement * Clone() const override
ThreeWayStructure(const ThreeWayStructure &)=default
bool IsBox(int k) const override
ThreeWayStructure(int size)
bool ElementExists(int i, int j, int k) const override
constexpr const T & Max(const T &a, const T &b) noexcept