52 #ifndef __PCL_PixelInterpolation_h
53 #define __PCL_PixelInterpolation_h
58 #include <pcl/Diagnostics.h>
72 # pragma warning( push )
73 # pragma warning( disable : 4267 )
147 const sample* data,
int width,
int height,
bool unclipped =
false )
148 : m_interpolation( interpolation )
149 , m_unclipped( unclipped )
151 if ( !m_interpolation.IsNull() )
152 m_interpolation->Initialize( data, width, height );
179 PCL_PRECONDITION( !m_interpolation.IsNull() )
180 return *m_interpolation;
189 PCL_PRECONDITION( !m_interpolation.IsNull() )
190 return *m_interpolation;
206 PCL_PRECONDITION( !m_interpolation.IsNull() )
207 double r = (*m_interpolation)( x, y );
210 if ( r > P::MaxSampleValue() )
211 return P::MaxSampleValue();
212 if ( r < P::MinSampleValue() )
213 return P::MinSampleValue();
215 return P::FloatToSample( r );
224 template <
typename T>
227 return operator()( p.
x, p.
y );
287 template <
class P,
class T>
290 return new Interpolator<P>( NewInterpolation( data ), data, width, height, unclipped );
298 throw NotImplemented( *
this,
"Interpolate 32-bit floating point images" );
301 virtual BidimensionalInterpolation<DoublePixelTraits::sample>*
304 throw NotImplemented( *
this,
"Interpolate 64-bit floating point images" );
307 virtual BidimensionalInterpolation<ComplexPixelTraits::sample>*
310 throw NotImplemented( *
this,
"Interpolate 32-bit complex images" );
313 virtual BidimensionalInterpolation<DComplexPixelTraits::sample>*
316 throw NotImplemented( *
this,
"Interpolate 64-bit complex images" );
319 virtual BidimensionalInterpolation<UInt8PixelTraits::sample>*
322 throw NotImplemented( *
this,
"Interpolate 8-bit integer images" );
325 virtual BidimensionalInterpolation<UInt16PixelTraits::sample>*
328 throw NotImplemented( *
this,
"Interpolate 16-bit integer images" );
331 virtual BidimensionalInterpolation<UInt32PixelTraits::sample>*
334 throw NotImplemented( *
this,
"Interpolate 32-bit integer images" );
370 return "Nearest neighbor interpolation";
381 BidimensionalInterpolation<DoublePixelTraits::sample>*
384 return new NearestNeighborInterpolation<DoublePixelTraits::sample>;
387 BidimensionalInterpolation<UInt8PixelTraits::sample>*
390 return new NearestNeighborInterpolation<UInt8PixelTraits::sample>;
393 BidimensionalInterpolation<UInt16PixelTraits::sample>*
396 return new NearestNeighborInterpolation<UInt16PixelTraits::sample>;
399 BidimensionalInterpolation<UInt32PixelTraits::sample>*
402 return new NearestNeighborInterpolation<UInt32PixelTraits::sample>;
438 return "Bilinear interpolation";
449 BidimensionalInterpolation<DoublePixelTraits::sample>*
452 return new BilinearInterpolation<DoublePixelTraits::sample>;
455 BidimensionalInterpolation<UInt8PixelTraits::sample>*
458 return new BilinearInterpolation<UInt8PixelTraits::sample>;
461 BidimensionalInterpolation<UInt16PixelTraits::sample>*
464 return new BilinearInterpolation<UInt16PixelTraits::sample>;
467 BidimensionalInterpolation<UInt32PixelTraits::sample>*
470 return new BilinearInterpolation<UInt32PixelTraits::sample>;
514 return String().
Format(
"Bicubic spline interpolation, c=%.2f", m_clamp );
527 BidimensionalInterpolation<DoublePixelTraits::sample>*
530 return new BicubicSplineInterpolation<DoublePixelTraits::sample>( m_clamp );
533 BidimensionalInterpolation<UInt8PixelTraits::sample>*
536 return new BicubicSplineInterpolation<UInt8PixelTraits::sample>( m_clamp );
539 BidimensionalInterpolation<UInt16PixelTraits::sample>*
542 return new BicubicSplineInterpolation<UInt16PixelTraits::sample>( m_clamp );
545 BidimensionalInterpolation<UInt32PixelTraits::sample>*
548 return new BicubicSplineInterpolation<UInt32PixelTraits::sample>( m_clamp );
616 return "Bicubic B-spline interpolation";
627 BidimensionalInterpolation<DoublePixelTraits::sample>*
630 return new BicubicBSplineInterpolation<DoublePixelTraits::sample>;
633 BidimensionalInterpolation<UInt8PixelTraits::sample>*
636 return new BicubicBSplineInterpolation<UInt8PixelTraits::sample>;
639 BidimensionalInterpolation<UInt16PixelTraits::sample>*
642 return new BicubicBSplineInterpolation<UInt16PixelTraits::sample>;
645 BidimensionalInterpolation<UInt32PixelTraits::sample>*
648 return new BicubicBSplineInterpolation<UInt32PixelTraits::sample>;
684 : m_rh(
Max( 1, rh ) )
685 , m_rv(
Max( 1, rv ) )
687 PCL_PRECONDITION( rh >= 1 )
688 PCL_PRECONDITION( rv >= 1 )
689 m_filter = filter.
Clone();
699 m_filter = x.m_filter->Clone();
718 return "Bicubic interpolation, " + m_filter->Description().
AppendFormat(
" (%dx%d)", 2*m_rh + 1, 2*m_rv + 1 );
741 BidimensionalInterpolation<DoublePixelTraits::sample>*
744 return new BicubicFilterInterpolation<DoublePixelTraits::sample>( m_rh, m_rv, *m_filter );
747 BidimensionalInterpolation<UInt8PixelTraits::sample>*
750 return new BicubicFilterInterpolation<UInt8PixelTraits::sample>( m_rh, m_rv, *m_filter );
753 BidimensionalInterpolation<UInt16PixelTraits::sample>*
756 return new BicubicFilterInterpolation<UInt16PixelTraits::sample>( m_rh, m_rv, *m_filter );
759 BidimensionalInterpolation<UInt32PixelTraits::sample>*
762 return new BicubicFilterInterpolation<UInt32PixelTraits::sample>( m_rh, m_rv, *m_filter );
806 PCL_PRECONDITION( n >= 1 )
807 PCL_PRECONDITION( clamp < 0 || 0 <= clamp && clamp <= 1 )
836 BidimensionalInterpolation<DoublePixelTraits::sample>*
839 return new LanczosInterpolation<DoublePixelTraits::sample>( m_n, m_clamp );
842 BidimensionalInterpolation<UInt8PixelTraits::sample>*
845 return new LanczosInterpolation<UInt8PixelTraits::sample>( m_n, m_clamp );
848 BidimensionalInterpolation<UInt16PixelTraits::sample>*
851 return new LanczosInterpolation<UInt16PixelTraits::sample>( m_n, m_clamp );
854 BidimensionalInterpolation<UInt32PixelTraits::sample>*
857 return new LanczosInterpolation<UInt32PixelTraits::sample>( m_n, m_clamp );
895 PCL_PRECONDITION( clamp < 0 || 0 <= clamp && clamp <= 1 )
907 String desc(
"Lanczos-3 LUT interpolation" );
923 BidimensionalInterpolation<DoublePixelTraits::sample>*
926 return new Lanczos3LUTInterpolation<DoublePixelTraits::sample>( m_clamp );
929 BidimensionalInterpolation<UInt8PixelTraits::sample>*
932 return new Lanczos3LUTInterpolation<UInt8PixelTraits::sample>( m_clamp );
935 BidimensionalInterpolation<UInt16PixelTraits::sample>*
938 return new Lanczos3LUTInterpolation<UInt16PixelTraits::sample>( m_clamp );
941 BidimensionalInterpolation<UInt32PixelTraits::sample>*
944 return new Lanczos3LUTInterpolation<UInt32PixelTraits::sample>( m_clamp );
980 : m_clamp(
Range( clamp, 0.0F, 1.0F ) )
982 PCL_PRECONDITION( clamp < 0 || 0 <= clamp && clamp <= 1 )
994 String desc(
"Lanczos-4 LUT interpolation" );
1010 BidimensionalInterpolation<DoublePixelTraits::sample>*
1013 return new Lanczos4LUTInterpolation<DoublePixelTraits::sample>( m_clamp );
1016 BidimensionalInterpolation<UInt8PixelTraits::sample>*
1019 return new Lanczos4LUTInterpolation<UInt8PixelTraits::sample>( m_clamp );
1022 BidimensionalInterpolation<UInt16PixelTraits::sample>*
1025 return new Lanczos4LUTInterpolation<UInt16PixelTraits::sample>( m_clamp );
1028 BidimensionalInterpolation<UInt32PixelTraits::sample>*
1031 return new Lanczos4LUTInterpolation<UInt32PixelTraits::sample>( m_clamp );
1067 : m_clamp(
Range( clamp, 0.0F, 1.0F ) )
1069 PCL_PRECONDITION( clamp < 0 || 0 <= clamp && clamp <= 1 )
1081 String desc(
"Lanczos-5 LUT interpolation" );
1097 BidimensionalInterpolation<DoublePixelTraits::sample>*
1100 return new Lanczos5LUTInterpolation<DoublePixelTraits::sample>( m_clamp );
1103 BidimensionalInterpolation<UInt8PixelTraits::sample>*
1106 return new Lanczos5LUTInterpolation<UInt8PixelTraits::sample>( m_clamp );
1109 BidimensionalInterpolation<UInt16PixelTraits::sample>*
1112 return new Lanczos5LUTInterpolation<UInt16PixelTraits::sample>( m_clamp );
1115 BidimensionalInterpolation<UInt32PixelTraits::sample>*
1118 return new Lanczos5LUTInterpolation<UInt32PixelTraits::sample>( m_clamp );
1127 # pragma warning( pop )
A smart pointer with exclusive object ownership and optional automatic object destruction.
Bicubic B-Spline Interpolation Algorithm.
Bicubic B-spline pixel interpolation.
BicubicBSplinePixelInterpolation()=default
String Description() const override
BicubicBSplinePixelInterpolation(const BicubicBSplinePixelInterpolation &)=default
Bicubic filter interpolation algorithms.
Pixel interpolation based on Mitchell-Netravali parameterized bicubic filters.
BicubicFilterPixelInterpolation(BicubicFilterPixelInterpolation &&)=default
BicubicFilterPixelInterpolation(const BicubicFilterPixelInterpolation &x)
String Description() const override
BicubicFilterPixelInterpolation(int rh, int rv, const CubicFilter &filter)
~BicubicFilterPixelInterpolation() override
const CubicFilter & Filter() const
Bicubic pixel interpolation - an alias for BicubicSplinePixelInterpolation.
BicubicPixelInterpolation(const BicubicPixelInterpolation &)=default
BicubicPixelInterpolation(double c=__PCL_BICUBIC_SPLINE_CLAMPING_THRESHOLD)
Bicubic spline interpolation algorithm.
Bicubic spline pixel interpolation.
String Description() const override
BicubicSplinePixelInterpolation(const BicubicSplinePixelInterpolation &)=default
BicubicSplinePixelInterpolation(double clamp=__PCL_BICUBIC_SPLINE_CLAMPING_THRESHOLD)
A generic interface to two-dimensional interpolation algorithms.
Bilinear interpolation algorithm.
Bilinear pixel interpolation.
String Description() const override
BilinearPixelInterpolation()=default
BilinearPixelInterpolation(const BilinearPixelInterpolation &)=default
traits_type::sample sample
Mitchell-Netravali parameterized cubic filters.
virtual CubicFilter * Clone() const
traits_type::sample sample
traits_type::sample sample
traits_type::sample sample
A generic point in the two-dimensional space.
component x
Abscissa (horizontal, or X-axis coordinate).
component y
Ordinate (vertical, or Y-axis coordinate).
Two dimensional LUT-based 3rd-order Lanczos interpolation algorithm.
Lanczos 3rd-order LUT-based pixel interpolation.
Lanczos3LUTPixelInterpolation(const Lanczos3LUTPixelInterpolation &)=default
Lanczos3LUTPixelInterpolation(float clamp=0.3F)
String Description() const override
Two dimensional LUT-based 4th-order Lanczos interpolation algorithm.
Lanczos 3rd-order LUT-based pixel interpolation.
String Description() const override
Lanczos4LUTPixelInterpolation(const Lanczos4LUTPixelInterpolation &)=default
Lanczos4LUTPixelInterpolation(float clamp=0.3F)
Two dimensional LUT-based 5th-order Lanczos interpolation algorithm.
Lanczos 5th-order LUT-based pixel interpolation.
Lanczos5LUTPixelInterpolation(const Lanczos5LUTPixelInterpolation &)=default
Lanczos5LUTPixelInterpolation(float clamp=0.3F)
String Description() const override
Two dimensional Lanczos interpolation algorithm.
Lanczos pixel interpolation.
LanczosPixelInterpolation(const LanczosPixelInterpolation &)=default
String Description() const override
LanczosPixelInterpolation(int n=3, float clamp=0.3)
Two-dimensional nearest neighbor interpolation algorithm.
NearestNeighbor pixel interpolation.
NearestNeighborPixelInterpolation()=default
String Description() const override
NearestNeighborPixelInterpolation(const NearestNeighborPixelInterpolation &)=default
An exception that indicates an unsupported feature.
Generic two-dimensional pixel interpolator.
sample operator()(double x, double y) const
Interpolator(BidimensionalInterpolation< sample > *interpolation, const sample *data, int width, int height, bool unclipped=false)
const BidimensionalInterpolation< sample > & Interpolation() const
typename P::sample sample
BidimensionalInterpolation< sample > & Interpolation()
sample operator()(const GenericPoint< T > &p) const
Interpolator(const Interpolator &)=delete
Interpolator(Interpolator &&)=default
Abstract root base class for all pixel interpolation algorithms.
PixelInterpolation(const PixelInterpolation &)=default
virtual String Description() const =0
virtual bool IsThreadSafe() const
virtual ~PixelInterpolation()
PixelInterpolation()=default
Interpolator< P > * NewInterpolator(const T *data, int width, int height, bool unclipped=false) const
String & AppendFormat(const_c_string8 fmt,...)
String & Format(const_c_string8 fmt,...)
traits_type::sample sample
traits_type::sample sample
traits_type::sample sample
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