52 #ifndef __PCL_BicubicFilterInterpolation_h
53 #define __PCL_BicubicFilterInterpolation_h
58 #include <pcl/Diagnostics.h>
98 m_k31 = ( 12 - 9*m_B - 6*m_C)/6;
99 m_k21 = (-18 + 12*m_B + 6*m_C)/6;
100 m_k01 = ( 6 - 2*m_B )/6;
101 m_k32 = ( -m_B - 6*m_C)/6;
102 m_k22 = ( 6*m_B + 30*m_C)/6;
103 m_k12 = ( -12*m_B - 48*m_C)/6;
104 m_k02 = ( 8*m_B + 24*m_C)/6;
139 return (x < 1) ? m_k01 + x*x*(m_k21 + x*m_k31) :
140 m_k02 + x*(m_k12 + x*(m_k22 + x*m_k32));
161 return String().
Format(
"Cubic filter (B=%.6f, C=%.6f)", m_B, m_C );
174 double m_k31, m_k21, m_k01, m_k32, m_k22, m_k12, m_k02;
218 return "Mitchell-Netravali cubic filter";
266 return "Catmull-Rom spline filter";
314 return "Cubic B-spline filter";
327 #define m_width this->m_width
328 #define m_height this->m_height
329 #define m_fillBorder this->m_fillBorder
330 #define m_fillValue this->m_fillValue
331 #define m_data this->m_data
350 template <
typename T>
367 : m_rx(
Max( 1, rx ) )
368 , m_ry(
Max( 1, ry ) )
371 PCL_PRECONDITION( rx >= 1 )
372 PCL_PRECONDITION( ry >= 1 )
390 void Initialize(
const T* data,
int dataWidth,
int dataHeight )
override
394 if ( m_rx > m_width || m_ry > m_height )
396 m_rx =
Min( m_rx, m_width );
397 m_ry =
Min( m_ry, m_height );
415 PCL_PRECONDITION( m_data !=
nullptr )
416 PCL_PRECONDITION( m_width > 0 && m_height > 0 )
417 PCL_PRECONDITION( x >= 0 && x < m_width )
418 PCL_PRECONDITION( y >= 0 && y < m_height )
419 PCL_CHECK( m_rx >= 1 && m_rx <= m_width )
420 PCL_CHECK( m_ry >= 1 && m_ry <= m_height )
421 PCL_CHECK( !m_k.IsEmpty() )
429 int64 d =
int64( y0 - m_ry )*m_width + x0 - m_rx;
434 for (
int xi = -m_rx, c = 0; xi <= m_rx; ++xi, ++c )
435 wx += (m_k[c] = m_filter( m_sx*(xi - dx) ));
437 double sy = 0, wy = 0;
438 for (
int yi = -m_ry; yi <= m_ry; ++yi )
440 double ky = m_filter( m_sy*(yi - dy) );
452 sy += m_fillValue * ky;
456 p = m_data + (d - 2*
int64( m_width )*(y + 1));
458 else if ( y >= m_height )
462 sy += m_fillValue * ky;
466 p = m_data + (d -= m_width);
476 int x1 =
Min( x2, m_width-1 );
478 const double* kx = m_k.Begin();
484 sx += (m_fillBorder ? m_fillValue : double( *(p - (x + x)) )) * *kx++;
496 sx += (m_fillBorder ? m_fillValue : double( *--p )) * *kx++;
508 for (
int yi = -m_ry, r = 0; yi <= m_ry; ++yi, ++r )
509 wy += (m_k[r] = m_filter( m_sy*(yi - dy) ));
511 double sx = 0, wx = 0;
512 for (
int xi = -m_rx; xi <= m_rx; ++xi )
514 double kx = m_filter( m_sx*(xi - dx) );
526 sx += m_fillValue * kx;
530 p = m_data + (d - 2*(x + 1));
532 else if ( x >= m_width )
536 sx += m_fillValue * kx;
547 int y1 =
Min( y2, m_height-1 );
549 const double* ky = m_k.Begin();
555 sy += (m_fillBorder ? m_fillValue : double( *(p - (y + y)*m_width) )) * *ky++;
568 sy += (m_fillBorder ? m_fillValue : double( *(p -= m_width) )) * *ky++;
605 if ( rx != m_rx || ry != m_ry )
610 if ( this->data !=
nullptr )
612 if ( m_rx > m_width )
614 if ( m_ry > m_height )
649 m_sx = m_filter.
Width()/(m_rx + 0.5);
650 m_sy = m_filter.
Width()/(m_ry + 0.5);
651 m_k =
DVector( 1 + (
Max( m_rx, m_ry ) << 1) );
Bicubic filter interpolation algorithms.
const CubicFilter & Filter() const noexcept
int VerticalRadius() const noexcept
int HorizontalRadius() const noexcept
void Initialize(const T *data, int dataWidth, int dataHeight) override
void SetRadii(int rx, int ry)
BicubicFilterInterpolation(const BicubicFilterInterpolation &)=default
PCL_HOT_FUNCTION double operator()(double x, double y) const override
~BicubicFilterInterpolation() override
BicubicFilterInterpolation(int rx, int ry, const CubicFilter &filter)
void SetFilter(const CubicFilter &filter)
A generic interface to two-dimensional interpolation algorithms.
virtual void Initialize(const T *data, int width, int height)
Catmull-Rom spline filter.
CubicFilter * Clone() const override
~CatmullRomSplineFilter() override
String Description() const override
CatmullRomSplineFilter(const CatmullRomSplineFilter &)=default
CubicBSplineFilter(const CubicBSplineFilter &)=default
CubicFilter * Clone() const override
~CubicBSplineFilter() override
String Description() const override
Mitchell-Netravali parameterized cubic filters.
virtual CubicFilter * Clone() const
CubicFilter(double B, double C)
PCL_HOT_FUNCTION double operator()(double x) const noexcept
CubicFilter(const CubicFilter &)=default
virtual String Description() const
double Width() const noexcept
Generic vector of arbitrary length.
Mitchell-Netravali cubic filter with B=C=1/3.
CubicFilter * Clone() const override
MitchellNetravaliCubicFilter()
MitchellNetravaliCubicFilter(const MitchellNetravaliCubicFilter &)=default
~MitchellNetravaliCubicFilter() override
String Description() const override
String & Format(const_c_string8 fmt,...)
int RoundInt(T x) noexcept
constexpr const T & Min(const T &a, const T &b) 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