52 #ifndef __PCL_MoffatFilter_h
53 #define __PCL_MoffatFilter_h
122 Initialize( sigma, beta, epsilon, 1, 0 );
134 Initialize( sigma, beta, epsilon, rho, theta );
145 Initialize( n, beta, epsilon, 1, 0 );
157 Initialize( n, beta, epsilon, rho, theta );
225 return m_rho*m_sigma;
281 return 2 *
Sqrt(
Pow2( 1/m_beta ) - 1 ) * m_sigma;
291 return m_rho * FWHMx();
311 void Set(
float sigma,
float beta,
float epsilon,
float rho,
float theta )
313 Initialize( sigma, beta, epsilon, rho, theta );
321 void Set(
float sigma,
float beta,
float epsilon,
float rho )
323 Initialize( sigma, beta, epsilon, rho, m_theta );
331 void Set(
float sigma,
float beta,
float epsilon )
333 Initialize( sigma, beta, epsilon, m_rho, m_theta );
341 void Set(
float sigma,
float beta )
343 Initialize( sigma, beta, m_epsilon, m_rho, m_theta );
353 Initialize( sigma, m_beta, m_epsilon, m_rho, m_theta );
370 Set( m_sigma, beta );
379 Set( m_sigma, m_beta, epsilon );
388 Set( m_sigma, m_beta, m_epsilon, rho );
397 Set( m_sigma, m_beta, m_epsilon, m_rho, theta );
409 Initialize( n, m_beta, m_epsilon, m_rho, m_theta );
414 float m_sigma = 2.0F;
417 float m_theta = 0.0F;
418 float m_epsilon = 0.01F;
420 void Initialize(
float s,
float b,
float e,
float r,
float a )
422 PCL_PRECONDITION( s > 0 )
423 PCL_PRECONDITION( b > 0 )
424 PCL_PRECONDITION( e > 0 )
425 PCL_PRECONDITION( r >= 0 && r <= 1 )
426 PCL_PRECONDITION( a >= 0 && a <=
Const<
float>::pi() )
429 m_epsilon =
Abs( e );
430 m_rho =
Range( r, 0.0F, 1.0F );
431 m_theta =
Range( a, 0.0F,
Const<
float>::pi() );
436 void Initialize(
int n,
float b,
float e,
float r,
float a )
438 PCL_PRECONDITION( n == 0 || n >= 3 && (n & 1) != 0 )
439 PCL_PRECONDITION( b > 0 )
440 PCL_PRECONDITION( e > 0 )
441 PCL_PRECONDITION( r >= 0 && r <= 1 )
442 PCL_PRECONDITION( a >= 0 && a <=
Const<
float>::pi() )
445 m_epsilon =
Abs( e );
446 m_sigma = (Size() >> 1)/
Sqrt(
Pow( m_epsilon, -1/m_beta ) - 1 );
447 m_rho =
Range( r, 0.0F, 1.0F );
448 m_theta =
Range( a, 0.0F,
Const<
float>::pi() );
458 float* h = *coefficients;
460 double sy = m_rho * sx;
463 if ( m_theta == 0 || m_rho == 1 )
467 for (
int n2 = size >> 1, dy = -n2; dy <= n2; ++dy )
469 for (
int dx = 0; dx < size; ++dx, ++h )
470 *h = *(h - ((dy+dy)*size));
472 for (
int dx = -n2; dx <= n2; ++dx, ++h )
473 *h = (dx > 0) ? *(h - (dx+dx)) : float(
Pow( 1 + dx*dx/sx2 + dy*dy/sy2, mb ) );
477 double st, ct;
SinCos(
double( m_theta ), st, ct );
483 double p1 = ct2/sx2 + st2/sy2;
484 double p2 = sct/sy2 - sct/sx2;
485 double p3 = st2/sx2 + ct2/sy2;
486 for (
int n2 = size >> 1, dy = -n2; dy <= n2; ++dy )
488 double twop2dy = 2*p2*dy;
489 double p3dy2 = p3*dy*dy;
490 for (
int dx = -n2; dx <= n2; ++dx, ++h )
491 *h =
float(
Pow( 1 + p1*dx*dx + twop2dy*dx + p3dy2, mb ) );
Fundamental numeric constants.
Kernel filter in two dimensions.
A kernel filter implementing a discrete Moffat distribution in two dimensions.
MoffatFilter(int n, float beta, float epsilon, float rho, float theta=0, const String &name=String())
void SetAspectRatio(float rho)
void Set(float sigma, float beta, float epsilon, float rho, float theta)
void Resize(int n) override
MoffatFilter(int n, float beta=4, float epsilon=0.01, const String &name=String())
void Set(float sigma, float beta, float epsilon, float rho)
float AspectRatio() const
MoffatFilter(const MoffatFilter &)=default
MoffatFilter(float sigma, float beta=4, float epsilon=0.01, const String &name=String())
void SetSigma(float sigma)
void Set(float sigma, float beta, float epsilon)
SeparableFilter AsSeparableFilter(float tolerance=__PCL_DEFAULT_FILTER_SEPARABILITY_TOLERANCE) const override
float RotationAngle() const
MoffatFilter(float sigma, float beta, float epsilon, float rho, float theta=0, const String &name=String())
KernelFilter * Clone() const override
void SetTruncation(float epsilon)
bool IsSeparable() const override
void SetRotationAngle(float theta)
void Set(float sigma, float beta)
MoffatFilter(MoffatFilter &&)=default
Separable filter in two dimensions.
Complex< T1 > Pow(const Complex< T1 > &c, T2 x) noexcept
Complex< T > Sqrt(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 T Pow2(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