52 #ifndef __PCL_GaussianFilter_h
53 #define __PCL_GaussianFilter_h
114 Initialize( sigma, epsilon, 1, 0 );
126 Initialize( sigma, epsilon, rho, theta );
137 Initialize( n, epsilon, 1, 0 );
149 Initialize( n, epsilon, rho, theta );
183 FVector v = coefficients.RowVector( Size()>>1 );
206 (void)KernelFilter::operator =( x );
208 m_epsilon = x.m_epsilon;
219 (void)KernelFilter::operator =( std::move( x ) );
221 m_epsilon = x.m_epsilon;
242 return m_rho*m_sigma;
289 return 2.3548200450309493 * m_sigma;
298 return m_rho * FWHMx();
317 void Set(
float sigma,
float epsilon,
float rho,
float theta )
319 Initialize( sigma, epsilon, rho, theta );
327 void Set(
float sigma,
float epsilon,
float rho )
329 Initialize( sigma, epsilon, rho, m_theta );
337 void Set(
float sigma,
float epsilon )
339 Initialize( sigma, epsilon, m_rho, m_theta );
349 Initialize( sigma, m_epsilon, m_rho, m_theta );
366 Set( m_sigma, epsilon );
375 Set( m_sigma, m_epsilon, rho );
384 Set( m_sigma, m_epsilon, m_rho, theta );
395 Initialize( n, m_epsilon, m_rho, m_theta );
415 float m_epsilon = 0.01F;
417 void Initialize(
float s,
float e,
float r,
float a )
419 PCL_PRECONDITION( s > 0 )
420 PCL_PRECONDITION( e > 0 )
421 PCL_PRECONDITION( r >= 0 && r <= 1 )
422 PCL_PRECONDITION( a >= 0 && a <=
Const<
float>::pi() )
424 m_epsilon =
Abs( e );
425 m_rho =
Range( r, 0.0F, 1.0F );
426 m_theta =
Range( a, 0.0F,
Const<
float>::pi() );
431 void Initialize(
int n,
float e,
float r,
float a )
433 PCL_PRECONDITION( n == 0 || n >= 3 && (n & 1) != 0 )
434 PCL_PRECONDITION( e > 0 )
435 PCL_PRECONDITION( r >= 0 && r <= 1 )
436 PCL_PRECONDITION( a >= 0 && a <=
Const<
float>::pi() )
438 m_epsilon =
Abs( e );
439 m_sigma = (Size() >> 1)/
Sqrt( -2*
Ln( m_epsilon ) );
440 m_rho =
Range( r, 0.0F, 1.0F );
441 m_theta =
Range( a, 0.0F,
Const<
float>::pi() );
451 float* __restrict__ h = *coefficients;
453 double sy = m_rho * sx;
455 if ( m_theta == 0 || m_rho == 1 )
457 double twosx2 = 2*sx*sx;
458 double twosy2 = 2*sy*sy;
459 for (
int n2 = size >> 1, dy = -n2; dy <= n2; ++dy )
461 for (
int dx = 0; dx < size; ++dx, ++h )
462 *h = *(h - ((dy+dy)*size));
464 for (
int dx = -n2; dx <= n2; ++dx, ++h )
465 *h = (dx > 0) ? *(h - (dx+dx)) : float(
Exp( -(dx*dx/twosx2 + dy*dy/twosy2) ) );
469 double st, ct;
SinCos(
double( m_theta ), st, ct );
473 double twosx2 = 2*sx*sx;
474 double twosy2 = 2*sy*sy;
475 double p1 = ct2/twosx2 + st2/twosy2;
476 double p2 = sct/twosy2 - sct/twosx2;
477 double p3 = st2/twosx2 + ct2/twosy2;
478 for (
int n2 = size >> 1, dy = -n2; dy <= n2; ++dy )
480 double twop2dy = 2*p2*dy;
481 double p3dy2 = p3*dy*dy;
482 for (
int dx = -n2; dx <= n2; ++dx, ++h )
483 *h =
float(
Exp( -(p1*dx*dx + twop2dy*dx + p3dy2) ) );
Fundamental numeric constants.
A kernel filter implementing a discrete Gaussian distribution in two dimensions.
void Set(float sigma, float epsilon, float rho, float theta)
GaussianFilter(int n, float epsilon, float rho, float theta=0, const String &name=String())
friend void Swap(GaussianFilter &x1, GaussianFilter &x2)
void SetSigma(float sigma)
void Resize(int n) override
GaussianFilter(float sigma, float epsilon, float rho, float theta=0, const String &name=String())
float RotationAngle() const
void Set(float sigma, float epsilon, float rho)
SeparableFilter AsSeparableFilter(float tolerance=__PCL_DEFAULT_FILTER_SEPARABILITY_TOLERANCE) const override
GaussianFilter(float sigma, float epsilon=0.01, const String &name=String())
void SetAspectRatio(float rho)
GaussianFilter(const GaussianFilter &)=default
float AspectRatio() const
bool IsSeparable() const override
void SetRotationAngle(float theta)
KernelFilter * Clone() const override
void Set(float sigma, float epsilon)
void SetTruncation(float epsilon)
GaussianFilter(GaussianFilter &&)=default
GaussianFilter(int n, float epsilon=0.01, const String &name=String())
Generic vector of arbitrary length.
Kernel filter in two dimensions.
Separable filter in two dimensions.
Complex< T > Sqrt(const Complex< T > &c) noexcept
Complex< T > Exp(const Complex< T > &c) noexcept
Complex< T > Ln(const Complex< T > &c) noexcept
T Abs(const Complex< T > &c) noexcept
void SinCos(T x, T &sx, T &cx) noexcept
int RoundInt(T x) noexcept
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
constexpr const T & Max(const T &a, const T &b) noexcept