52 #ifndef __PCL_WinsorizedSigmaClippingRejection_h
53 #define __PCL_WinsorizedSigmaClippingRejection_h
58 #include <pcl/Diagnostics.h>
141 EnableLowClipping( !disable );
159 EnableHighClipping( !disable );
198 PCL_PRECONDITION( sigma >= 0 )
199 m_sigmaLow =
Max( 0.0F, sigma );
208 PCL_PRECONDITION( sigma >= 0 )
209 m_sigmaHigh =
Max( 0.0F, sigma );
236 PCL_PRECONDITION( cutoff >= 1 )
237 m_cutoff =
Max( 1.0F, cutoff );
289 template <
class C,
typename I>
294 j = I( data.Length() );
295 for (
int it = 0; ; ++it )
297 GetWinsorizedParameters( mean, sigma, i, j, data, (it > 0) ? .0F : m_cutoff );
298 if ( 1 + sigma == 1 )
300 if ( I( j - i ) < I( 3 ) )
305 for ( ; i < j; ++i, ++c )
306 if ( (mean - data[i])/sigma <= m_sigmaLow )
309 for ( ; i < j; --j, ++c )
310 if ( (data[j-1] - mean)/sigma <= m_sigmaHigh )
325 template <
class C,
typename I>
326 void operator()( I& i, I& j,
double& mean,
double& sigma, C& data )
const
328 return PerformRejection( i, j, mean, sigma, data );
333 bool m_clipLow =
true;
334 bool m_clipHigh =
true;
335 float m_sigmaLow = 3;
336 float m_sigmaHigh = 3;
359 template <
class C,
typename I>
360 static void GetWinsorizedParameters(
double& mean,
double& sigma,
const I i,
const I j,
const C& data,
float cutoff )
369 Array<double> v( n );
372 for ( I k = i; k < j; ++k, ++l )
373 v[l] =
double( data[k] );
377 sigma = 1.1926*
Sn( v.Begin(), v.End() );
382 if ( 1 + sigma == 1 )
385 double t0 = mean - 1.5*sigma;
386 double t1 = mean + 1.5*sigma;
390 double c0 = mean - cutoff*sigma;
391 double c1 = mean + cutoff*sigma;
394 v[i] = (v[i] > c0) ? t0 : mean;
395 else if ( v[i] > t1 )
396 v[i] = (v[i] < c1) ? t1 : mean;
403 else if ( v[i] > t1 )
408 sigma = 1.134*
StdDev( v.Begin(), v.End() );
409 mean =
Mean( v.Begin(), v.End() );
411 if (
Abs( s0 - sigma )/s0 < 0.0005 )
Winsorized sigma clipping outlier rejection algorithm.
void SetLowSigma(float sigma)
void EnableLowClipping(bool enable=true)
float WinsorizationCutoff() const
void SetWinsorizationCutoff(float cutoff)
void EnableHighClipping(bool enable=true)
WinsorizedSigmaClippingRejection()=default
void SetHighSigma(float sigma)
virtual ~WinsorizedSigmaClippingRejection()
void operator()(I &i, I &j, double &mean, double &sigma, C &data) const
void DisableLowClipping(bool disable=true)
void PerformRejection(I &i, I &j, double &mean, double &sigma, C &data) const
WinsorizedSigmaClippingRejection(const WinsorizedSigmaClippingRejection &)=default
void DisableHighClipping(bool disable=true)
T Abs(const Complex< T > &c) noexcept
double MedianDestructive(T *__restrict__ i, T *__restrict__ j) noexcept
double StdDev(const T *__restrict__ i, const T *__restrict__ j, double center) noexcept
double Mean(const T *__restrict__ i, const T *__restrict__ j) noexcept
double Sn(T *__restrict__ x, T *__restrict__ xn)
constexpr const T & Max(const T &a, const T &b) noexcept