52 #ifndef __PCL_PixelInterpolation_h
53 #define __PCL_PixelInterpolation_h
58 #include <pcl/Diagnostics.h>
72 # pragma warning( push )
73 # pragma warning( disable : 4267 ) // conversion from 'size_t' to ...
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 );
258 virtual String Description()
const = 0;
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 )
1130 #endif // __PCL_PixelInterpolation_h