52 #ifndef __PCL_VariableShapeFilter_h
53 #define __PCL_VariableShapeFilter_h
121 Initialize( sigma, shape, epsilon, 1, 0 );
133 Initialize( sigma, shape, epsilon, rho, theta );
144 Initialize( n, shape, epsilon, 1, 0 );
156 Initialize( n, shape, epsilon, rho, theta );
190 if ( m_shape == 2 && m_rho == 1 )
192 FVector v = coefficients.RowVector( Size()>>1 );
207 return m_shape == 2 && m_rho == 1;
235 return m_rho*m_sigma;
297 return 2 * m_sigma *
Pow( m_shape*0.6931471805599453, 1.0/m_shape );
307 return m_rho * FWHMx();
327 void Set(
float sigma,
float shape,
float epsilon,
float rho,
float theta )
329 Initialize( sigma, shape, epsilon, rho, theta );
337 void Set(
float sigma,
float shape,
float epsilon,
float rho )
339 Initialize( sigma, shape, epsilon, rho, m_theta );
347 void Set(
float sigma,
float shape,
float epsilon )
349 Initialize( sigma, shape, epsilon, m_rho, m_theta );
357 void Set(
float sigma,
float shape )
359 Initialize( sigma, shape, m_epsilon, m_rho, m_theta );
369 Initialize( sigma, m_shape, m_epsilon, m_rho, m_theta );
386 Set( m_sigma, shape );
395 Set( m_sigma, m_shape, epsilon );
404 Set( m_sigma, m_shape, m_epsilon, rho );
413 Set( m_sigma, m_shape, m_epsilon, m_rho, theta );
424 Initialize( n, m_shape, m_epsilon, m_rho, m_theta );
429 float m_sigma = 2.0F;
430 float m_shape = 2.0F;
432 float m_theta = 0.0F;
433 float m_epsilon = 0.01F;
435 void Initialize(
float s,
float k,
float e,
float r,
float a )
437 PCL_PRECONDITION( s > 0 )
438 PCL_PRECONDITION( k > 0 )
439 PCL_PRECONDITION( e > 0 )
440 PCL_PRECONDITION( r >= 0 && r <= 1 )
441 PCL_PRECONDITION( a >= 0 && a <=
Const<
float>::pi() )
444 m_epsilon =
Abs( e );
445 m_rho =
Range( r, 0.0F, 1.0F );
446 m_theta =
Range( a, 0.0F,
Const<
float>::pi() );
451 void Initialize(
int n,
float k,
float e,
float r,
float a )
453 PCL_PRECONDITION( n == 0 || n >= 3 && (n & 1) != 0 )
454 PCL_PRECONDITION( k > 0 )
455 PCL_PRECONDITION( e > 0 )
456 PCL_PRECONDITION( r >= 0 && r <= 1 )
457 PCL_PRECONDITION( a >= 0 && a <=
Const<
float>::pi() )
460 m_epsilon =
Abs( e );
461 m_sigma = (Size() >> 1)/
Pow( -m_shape*
Ln( m_epsilon ), 1/m_shape );
462 m_rho =
Range( r, 0.0F, 1.0F );
463 m_theta =
Range( a, 0.0F,
Const<
float>::pi() );
473 float* h = *coefficients;
474 float rk = m_shape *
Pow( m_sigma, m_shape );
476 for (
int n2 = size >> 1, y = -n2; y <= n2; ++y )
478 for (
int x = 0; x < size; ++x, ++h )
479 *h = *(h - ((y+y)*size));
481 for (
int x = -n2; x <= n2; ++x, ++h )
482 *h = (x > 0) ? *(h - (x+x)) : float(
Exp( -
Pow(
Sqrt(
float( x*x + y*y ) ), m_shape )/rk ) );
489 coefficient_matrix ctemp( coefficients );
490 ctemp.EnsureUnique();
494 float r =
Max( 0.5F/size, m_rho );
495 for (
int n2 = size >> 1, i = -n2; i <= n2; ++i )
497 float y = float( i )/r + n2;
498 for (
int x = 0; x < size; ++x )
499 *h++ = (y < 0 || y >= size) ? 0.0F : (*interpolator)( float( x ), y );
505 coefficient_matrix ctemp( coefficients );
506 ctemp.EnsureUnique();
507 AutoPointer<PixelInterpolation::Interpolator<FloatPixelTraits> >
508 interpolator( B.NewInterpolator<FloatPixelTraits>( *ctemp, size, size ) );
511 SinCos( -m_theta, sa, ca );
512 for (
int n2 = size >> 1, i = -n2; i <= n2; ++i )
513 for (
int j = -n2; j <= n2; ++j )
515 float x = ca*j + sa*i + n2;
516 float y = -sa*j + ca*i + n2;
517 *h++ = (x < 0 || y < 0 || x >= size || y >= size) ? 0.0F : (*interpolator)( x, y );
A smart pointer with exclusive object ownership and optional automatic object destruction.
Bicubic pixel interpolation - an alias for BicubicSplinePixelInterpolation.
Fundamental numeric constants.
32-bit IEEE 754 normalized floating point real pixel traits.
Generic vector of arbitrary length.
Kernel filter in two dimensions.
Separable filter in two dimensions.
A kernel filter with variable kurtosis.
void Resize(int n) override
VariableShapeFilter(float sigma, float shape, float epsilon, float rho, float theta=0, const String &name=String())
VariableShapeFilter(const VariableShapeFilter &)=default
float AspectRatio() const
VariableShapeFilter(int n, float shape=2, float epsilon=0.01, const String &name=String())
VariableShapeFilter(int n, float shape, float epsilon, float rho, float theta=0, const String &name=String())
void Set(float sigma, float shape)
bool IsSeparable() const override
VariableShapeFilter()=default
void SetShape(float shape)
void Set(float sigma, float shape, float epsilon, float rho, float theta)
void SetTruncation(float epsilon)
void Set(float sigma, float shape, float epsilon, float rho)
void Set(float sigma, float shape, float epsilon)
VariableShapeFilter(float sigma, float shape=2, float epsilon=0.01, const String &name=String())
float RotationAngle() const
VariableShapeFilter(VariableShapeFilter &&)=default
void SetAspectRatio(float rho)
void SetSigma(float sigma)
SeparableFilter AsSeparableFilter(float tolerance=__PCL_DEFAULT_FILTER_SEPARABILITY_TOLERANCE) const override
void SetRotationAngle(float theta)
KernelFilter * Clone() const override
Complex< T1 > Pow(const Complex< T1 > &c, T2 x) noexcept
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
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