52 #ifndef __PCL_MorphologicalOperator_h
53 #define __PCL_MorphologicalOperator_h
58 #include <pcl/Diagnostics.h>
121 virtual bool IsDilation()
const
132 throw NotImplemented( *
this,
"Apply to 32-bit floating-point images" );
141 throw NotImplemented( *
this,
"Apply to 64-bit floating-point images" );
223 return Operate( f, n );
232 return Operate( f, n );
241 return Operate( f, n );
250 return Operate( f, n );
259 return Operate( f, n );
264 template <
typename T>
265 static T Operate( T* __restrict__ f,
size_type n )
268 for ( ; --n > 0; ++f )
276 static float Operate(
float* __restrict__ f,
size_type n )
278 if ( unlikely( n < 8 ) )
289 if ( unlikely( ((ptrdiff_t)f) & 31 ) )
291 vmin = _mm256_loadu_ps( f );
293 vmin = _mm256_min_ps( vmin, _mm256_loadu_ps( (
const float* __restrict__)(f + i*8) ) );
297 vmin = _mm256_load_ps( f );
299 vmin = _mm256_min_ps( vmin, ((
const __m256* __restrict__)f)[i] );
301 float min = ((
const float* __restrict__)&vmin)[0];
302 for (
int i = 1; i < 8; ++i )
304 float vn = ((
const float* __restrict__)&vmin)[i];
308 for (
size_type i = n8 << 3; i < n; ++i )
314 static double Operate(
double* __restrict__ f,
size_type n )
316 if ( unlikely( n < 4 ) )
327 if ( unlikely( ((ptrdiff_t)f) & 31 ) )
329 vmin = _mm256_loadu_pd( f );
331 vmin = _mm256_min_pd( vmin, _mm256_loadu_pd( (
const double* __restrict__)(f + i*4) ) );
335 vmin = _mm256_load_pd( f );
337 vmin = _mm256_min_pd( vmin, ((
const __m256d* __restrict__)f)[i] );
339 double min = ((
const double* __restrict__)&vmin)[0];
340 for (
int i = 1; i < 4; ++i )
342 double vn = ((
const double* __restrict__)&vmin)[i];
346 for (
size_type i = n4 << 2; i < n; ++i )
384 bool IsDilation()
const override
395 return Operate( f, n );
404 return Operate( f, n );
413 return Operate( f, n );
422 return Operate( f, n );
431 return Operate( f, n );
436 template <
typename T>
437 static T Operate( T* __restrict__ f,
size_type n )
440 for ( ; --n > 0; ++f )
448 static float Operate(
float* __restrict__ f,
size_type n )
450 if ( unlikely( n < 8 ) )
461 if ( unlikely( ((ptrdiff_t)f) & 31 ) )
463 vmax = _mm256_loadu_ps( f );
465 vmax = _mm256_max_ps( vmax, _mm256_loadu_ps( (
const float* __restrict__)(f + i*8) ) );
469 vmax = _mm256_load_ps( f );
471 vmax = _mm256_max_ps( vmax, ((
const __m256* __restrict__)f)[i] );
473 float max = ((
const float* __restrict__)&vmax)[0];
474 for (
int i = 1; i < 8; ++i )
476 float vn = ((
const float* __restrict__)&vmax)[i];
480 for (
size_type i = n8 << 3; i < n; ++i )
486 static double Operate(
double* __restrict__ f,
size_type n )
488 if ( unlikely( n < 4 ) )
499 if ( unlikely( ((ptrdiff_t)f) & 31 ) )
501 vmax = _mm256_loadu_pd( f );
503 vmax = _mm256_max_pd( vmax, _mm256_loadu_pd( (
const double* __restrict__)(f + i*4) ) );
507 vmax = _mm256_load_pd( f );
509 vmax = _mm256_max_pd( vmax, ((
const __m256d* __restrict__)f)[i] );
511 double max = ((
const double* __restrict__)&vmax)[0];
512 for (
int i = 1; i < 4; ++i )
514 double vn = ((
const double* __restrict__)&vmax)[i];
518 for (
size_type i = n4 << 2; i < n; ++i )
601 template <
typename T,
class P>
602 static T Operate( T* __restrict__ f,
size_type n, P* )
604 if ( n > __PCL_SMALL_MEDIAN_MAX_LENGTH )
609 return P::FloatToSample( (
double( *
pcl::Select( f, f+n, n2 ) )
613 return P::FloatToSample( pcl::SmallMedianDestructive( f, f+n ) );
648 PCL_PRECONDITION( 0 <= k && k <= 1 )
649 PCL_CHECK( 0 <= m_k && m_k <= 1 )
677 PCL_PRECONDITION( 0 <= k && k <= 1 )
694 return Operate( f, n );
703 return Operate( f, n );
712 return Operate( f, n );
721 return Operate( f, n );
730 return Operate( f, n );
737 template <
typename T>
738 T Operate( T* __restrict__ f,
size_type n )
const
818 template <
typename T,
class P>
819 static T Operate( T* __restrict__ f,
size_type n, P* )
823 return P::FloatToSample( (
double( *min ) +
double( *max ))/2 );
863 PCL_PRECONDITION( 0 <= d && d <= 1 )
864 PCL_CHECK( 0 <= m_d && m_d <= 1 )
892 PCL_PRECONDITION( 0 <= d && d <= 1 )
900 return String().
Format(
"Alpha-trimmed mean, d=%.5f", m_d );
952 template <
typename T,
class P>
953 T Operate( T* __restrict__ f,
size_type n, P* )
const
961 return P::FloatToSample( s/(i2 - i1) );
Alpha-trimmed mean operator.
AlphaTrimmedMeanFilter(const AlphaTrimmedMeanFilter &)=default
void SetTrimmingFactor(double d)
String Description() const override
AlphaTrimmedMeanFilter()=default
double TrimmingFactor() const
AlphaTrimmedMeanFilter(double d)
MorphologicalOperator * Clone() const override
Dilation morphological operator.
String Description() const override
MorphologicalOperator * Clone() const override
64-bit IEEE 754 normalized floating point real pixel traits.
traits_type::sample sample
Erosion morphological operator.
MorphologicalOperator * Clone() const override
String Description() const override
32-bit IEEE 754 normalized floating point real pixel traits.
traits_type::sample sample
String Description() const override
MorphologicalOperator * Clone() const override
Abstract base class of all PCL morphological operators.
virtual String Description() const
virtual ~MorphologicalOperator()
virtual MorphologicalOperator * Clone() const =0
MorphologicalOperator(const MorphologicalOperator &)=default
MorphologicalOperator()=default
An exception that indicates an unsupported feature.
Morphological selection operator.
String Description() const override
double SelectionPoint() const
SelectionFilter(const SelectionFilter &)=default
MorphologicalOperator * Clone() const override
void SetSelectionPoint(double k)
SelectionFilter()=default
SelectionFilter(double k)
String & Format(const_c_string8 fmt,...)
16-bit unsigned integer pixel traits.
traits_type::sample sample
32-bit unsigned integer pixel traits.
traits_type::sample sample
8-bit unsigned integer pixel traits.
traits_type::sample sample
int RoundInt(T x) noexcept
RI Select(RI i, RI j, distance_type k)
void FindExtremeItems(FI &kmin, FI &kmax, FI i, FI j) noexcept
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept