33 #ifndef __INCLUDE_MIST_INTERPOLATE__
34 #define __INCLUDE_MIST_INTERPOLATE__
37 #ifndef __INCLUDE_MIST_H__
41 #ifndef __INCLUDE_MIST_LIMITS__
46 #ifndef __INCLUDE_MIST_THREAD__
57 namespace __interpolate_utility__
64 static void convert(
double in, T &out )
66 out =
static_cast< T
>( in );
70 static void convert(
const rgb< double > &in, rgb< T > &out )
72 out.r =
static_cast< T
>( in.r );
73 out.g =
static_cast< T
>( in.g );
74 out.b =
static_cast< T
>( in.b );
78 static void convert(
const rgb< double > &in, rgba< T > &out )
80 out.r =
static_cast< T
>( in.r );
81 out.g =
static_cast< T
>( in.g );
82 out.b =
static_cast< T
>( in.b );
86 static void convert(
const bgr< double > &in, bgr< T > &out )
88 out.r =
static_cast< T
>( in.r );
89 out.g =
static_cast< T
>( in.g );
90 out.b =
static_cast< T
>( in.b );
94 static void convert(
const bgr< double > &in, bgra< T > &out )
96 out.r =
static_cast< T
>( in.r );
97 out.g =
static_cast< T
>( in.g );
98 out.b =
static_cast< T
>( in.b );
104 struct _round_< true >
107 static void convert(
double in, T &out )
109 out =
static_cast< T
>( in + 0.5 );
113 static void convert(
const rgb< double > &in, rgb< T > &out )
115 out.r =
static_cast< T
>( in.r + 0.5 );
116 out.g =
static_cast< T
>( in.g + 0.5 );
117 out.b =
static_cast< T
>( in.b + 0.5 );
121 static void convert(
const rgb< double > &in, rgba< T > &out )
123 out.r =
static_cast< T
>( in.r + 0.5 );
124 out.g =
static_cast< T
>( in.g + 0.5 );
125 out.b =
static_cast< T
>( in.b + 0.5 );
129 static void convert(
const bgr< double > &in, bgr< T > &out )
131 out.r =
static_cast< T
>( in.r + 0.5 );
132 out.g =
static_cast< T
>( in.g + 0.5 );
133 out.b =
static_cast< T
>( in.b + 0.5 );
137 static void convert(
const bgr< double > &in, bgra< T > &out )
139 out.r =
static_cast< T
>( in.r + 0.5 );
140 out.g =
static_cast< T
>( in.g + 0.5 );
141 out.b =
static_cast< T
>( in.b + 0.5 );
146 inline void round(
const double in, T &out )
148 _round_< is_integer< T >::value >
::convert( in, out );
152 inline void round(
const rgb< double > &in, rgb< T > &out )
154 _round_< is_integer< T >::value >
::convert( in, out );
158 inline void round(
const rgb< double > &in, rgba< T > &out )
160 _round_< is_integer< T >::value >
::convert( in, out );
164 inline void round(
const bgr< double > &in, bgr< T > &out )
166 _round_< is_integer< T >::value >
::convert( in, out );
170 inline void round(
const bgr< double > &in, bgra< T > &out )
172 _round_< is_integer< T >::value >
::convert( in, out );
177 namespace __nearest__
179 template <
class Array1,
class Array2 >
180 void interpolate(
const Array1 &in, Array2 &out,
181 typename Array1::size_type thread_idx,
typename Array1::size_type thread_numx,
182 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
183 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz )
185 typedef typename Array1::size_type size_type;
186 typedef typename Array1::value_type value_type;
187 typedef typename Array2::value_type out_value_type;
190 size_type iw = in.width( );
191 size_type ih = in.height( );
192 size_type
id = in.depth( );
193 size_type ow = out.width( );
194 size_type oh = out.height( );
195 size_type od = out.depth( );
197 double sx =
static_cast< double >( iw ) / static_cast< double >( ow );
198 double sy =
static_cast< double >( ih ) / static_cast< double >( oh );
199 double sz =
static_cast< double >( id ) / static_cast< double >( od );
202 for( k = thread_idz ; k < od ; k += thread_numz )
204 z =
static_cast< size_type
>( sz * k + 0.5 );
205 z = z <
id ? z :
id - 1;
206 for( j = thread_idy ; j < oh ; j += thread_numy )
208 y =
static_cast< size_type
>( sy * j + 0.5 );
209 y = y < ih ? y : ih - 1;
210 for( i = thread_idx ; i < ow ; i += thread_numx )
212 x =
static_cast< size_type
>( sx * i + 0.5 );
213 x = x < iw ? x : iw - 1;
215 __interpolate_utility__::round( in( x, y, z ), out( i, j, k ) );
229 template <
class T,
class Allocator >
230 static double mean___(
const array< T, Allocator > &in,
231 typename array< T, Allocator >::size_type i1,
232 typename array< T, Allocator >::size_type i2,
233 typename array< T, Allocator >::size_type j1,
234 typename array< T, Allocator >::size_type j2,
235 typename array< T, Allocator >::size_type k1,
236 typename array< T, Allocator >::size_type k2,
244 typedef typename array< T, Allocator >::value_type value_type;
245 typedef typename array< T, Allocator >::size_type size_type;
249 double a = ( i1 + 1 - xs ) * 0.5;
250 pix += ( in[ i1 ] + in[ i1 + 1 ] ) * a;
253 for( size_type i = i1 + 1 ; i < i2 - 1 ; i++ )
255 pix += ( in[ i ] + in[ i + 1 ] ) * 0.5;
259 double a = ( xe - i2 + 1 ) * 0.5;
260 pix += ( in[ i2 - 1 ] + in[ i2 ] ) * a;
263 double min = type_limits< value_type >::minimum( );
264 double max = type_limits< value_type >::maximum( );
265 pix /= ( xe - xs ) * ( ye - ys ) * ( ze - zs );
266 pix = pix > min ? pix : min;
267 pix = pix < max ? pix : max;
271 template <
class T,
class Allocator >
272 static double mean___(
const array2< T, Allocator > &in,
273 typename array2< T, Allocator >::size_type i1,
274 typename array2< T, Allocator >::size_type i2,
275 typename array2< T, Allocator >::size_type j1,
276 typename array2< T, Allocator >::size_type j2,
277 typename array2< T, Allocator >::size_type ,
278 typename array2< T, Allocator >::size_type ,
286 typedef typename array2< T, Allocator >::value_type value_type;
287 typedef typename array2< T, Allocator >::size_type size_type;
288 typedef typename array2< T, Allocator >::const_pointer const_pointer;
289 double pix = 0.0, sum = 0.0;
294 double xx[ 2 ] = { ( i1 + 1 - xs ) * 0.25, ( xe - i2 + 1 ) * 0.25 };
295 for( size_type j = j1 ; j < j2 ; j++ )
301 else if( j == j2 - 1 )
310 double aa[ 2 ] = { xx[ 0 ] * yy, xx[ 1 ] * yy };
312 const_pointer p0 = &in( 0, j );
313 const_pointer p1 = &in( 0, j + 1 );
315 pix += ( p0[ i1 ] + p1[ i1 ] + p0[ i1 + 1 ] + p1[ i1 + 1 ] ) * aa[ 0 ];
316 pix += ( p0[ i2 - 1 ] + p1[ i2 - 1 ] + p0[ i2 ] + p1[ i2 ] ) * aa[ 1 ];
317 sum += ( aa[ 0 ] + aa[ 1 ] ) * 4.0;
322 double xx[ 3 ] = { ( i1 + 1 - xs ) * 0.25, 0.25, ( xe - i2 + 1 ) * 0.25 };
323 for( size_type j = j1 ; j < j2 ; j++ )
329 else if( j == j2 - 1 )
338 double aa[ 3 ] = { xx[ 0 ] * yy, xx[ 1 ] * yy, xx[ 2 ] * yy };
340 const_pointer p0 = &in( 0, j );
341 const_pointer p1 = &in( 0, j + 1 );
346 pix += ( p0[ i ] + p1[ i ] + p0[ i + 1 ] + p1[ i + 1 ] ) * aa[ 0 ];
347 ppp = p0[ i + 1 ] + p1[ i + 1 ];
350 for( i = i1 + 2 ; i < i2 - 1 ; i++ )
352 ppp += ( p0[ i ] + p1[ i ] ) * 2.0;
356 ppp += p0[ i2 - 1 ] + p1[ i2 - 1 ];
357 pix += ppp * aa[ 1 ];
358 pix += ( p0[ i2 - 1 ] + p1[ i2 - 1 ] + p0[ i2 ] + p1[ i2 ] ) * aa[ 2 ];
361 sum += ( aa[ 0 ] + aa[ 2 ] ) * 4.0 + aa[ 1 ] * ( i2 - i1 - 2 ) * 4.0;
365 double min = type_limits< value_type >::minimum( );
366 double max = type_limits< value_type >::maximum( );
368 pix = pix > min ? pix : min;
369 pix = pix < max ? pix : max;
373 template <
class T,
class Allocator >
374 static double mean___(
const array3< T, Allocator > &in,
375 typename array3< T, Allocator >::size_type i1,
376 typename array3< T, Allocator >::size_type i2,
377 typename array3< T, Allocator >::size_type j1,
378 typename array3< T, Allocator >::size_type j2,
379 typename array3< T, Allocator >::size_type k1,
380 typename array3< T, Allocator >::size_type k2,
388 typedef typename array3< T, Allocator >::value_type value_type;
389 typedef typename array3< T, Allocator >::size_type size_type;
390 typedef typename array3< T, Allocator >::const_pointer const_pointer;
392 double xx[ 3 ] = { ( i1 + 1 - xs ) * 0.125, i2 - i1 < 3 ? 0.0 : 1.0 * 0.125, ( xe - i2 + 1 ) * 0.125 };
395 for( size_type k = k1 ; k < k2 ; k++ )
401 else if( k == k2 - 1 )
410 for( size_type j = j1 ; j < j2 ; j++ )
416 else if( j == j2 - 1 )
425 double aa[ 3 ] = { xx[ 0 ] * yy * zz, xx[ 1 ] * yy * zz, xx[ 2 ] * yy * zz };
427 const_pointer p0 = &in( 0, j , k );
428 const_pointer p1 = &in( 0, j + 1, k );
429 const_pointer p2 = &in( 0, j , k + 1 );
430 const_pointer p3 = &in( 0, j + 1, k + 1 );
434 const value_type &c1 = p0[ i1 ];
435 const value_type &c2 = p1[ i1 ];
436 const value_type &c3 = p2[ i1 ];
437 const value_type &c4 = p3[ i1 ];
438 const value_type &c5 = p0[ i1 + 1 ];
439 const value_type &c6 = p1[ i1 + 1 ];
440 const value_type &c7 = p2[ i1 + 1 ];
441 const value_type &c8 = p3[ i1 + 1 ];
443 pix += ( c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 ) * aa[ 0 ];
444 ppp += c5 + c6 + c7 + c8;
447 for( size_type i = i1 + 2 ; i < i2 - 1 ; i++ )
449 const value_type &c1 = p0[ i ];
450 const value_type &c2 = p1[ i ];
451 const value_type &c3 = p2[ i ];
452 const value_type &c4 = p3[ i ];
454 ppp += ( c1 + c2 + c3 + c4 ) * 2.0;
458 const value_type &c1 = p0[ i2 - 1 ];
459 const value_type &c2 = p1[ i2 - 1 ];
460 const value_type &c3 = p2[ i2 - 1 ];
461 const value_type &c4 = p3[ i2 - 1 ];
462 const value_type &c5 = p0[ i2 ];
463 const value_type &c6 = p1[ i2 ];
464 const value_type &c7 = p2[ i2 ];
465 const value_type &c8 = p3[ i2 ];
467 ppp += c1 + c2 + c3 + c4;
468 pix += ppp * aa[ 1 ];
469 pix += ( c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 ) * aa[ 2 ];
474 double min = type_limits< value_type >::minimum( );
475 double max = type_limits< value_type >::maximum( );
476 pix /= ( xe - xs ) * ( ye - ys ) * ( ze - zs );
477 pix = pix > min ? pix : min;
478 pix = pix < max ? pix : max;
484 struct _mean_< true >
486 template <
class T,
class Allocator >
487 static const typename T::template rebind< double >::other mean___(
const array< T, Allocator > &in,
488 typename array< T, Allocator >::size_type i1,
489 typename array< T, Allocator >::size_type i2,
490 typename array< T, Allocator >::size_type ,
491 typename array< T, Allocator >::size_type ,
492 typename array< T, Allocator >::size_type ,
493 typename array< T, Allocator >::size_type ,
501 typedef typename array< T, Allocator >::value_type color;
502 typedef typename array< T, Allocator >::size_type size_type;
503 typedef typename color::value_type value_type;
504 typedef typename T::template rebind< double >::other ovalue_type;
514 const color &c1 = in[ i1 ];
515 const color &c2 = in[ i1 + 1 ];
517 rr += c1.r; gg += c1.g; bb += c1.b;
518 rr += c2.r; gg += c2.g; bb += c2.b;
520 double a = ( i1 + 1 - xs ) * 0.5;
526 for( size_type i = i1 + 1 ; i < i2 - 1 ; i++ )
532 const color &c1 = in[ i ];
533 const color &c2 = in[ i + 1 ];
535 rr += c1.r; gg += c1.g; bb += c1.b;
536 rr += c2.r; gg += c2.g; bb += c2.b;
549 const color &c1 = in[ i2 - 1 ];
550 const color &c2 = in[ i2 ];
552 rr += c1.r; gg += c1.g; bb += c1.b;
553 rr += c2.r; gg += c2.g; bb += c2.b;
555 double a = ( xe - i2 + 1 ) * 0.5;
561 double numPixels = ( xe - xs ) * ( ye - ys ) * ( ze - zs );
562 double min = type_limits< value_type >::minimum( );
563 double max = type_limits< value_type >::maximum( );
565 r = r > min ? r : min;
566 r = r < max ? r : max;
568 g = g > min ? g : min;
569 g = g < max ? g : max;
571 b = b > min ? b : min;
572 b = b < max ? b : max;
573 return( ovalue_type( r, g, b ) );
576 template <
class T,
class Allocator >
577 static const typename T::template rebind< double >::other mean___(
const array2< T, Allocator > &in,
578 typename array2< T, Allocator >::size_type i1,
579 typename array2< T, Allocator >::size_type i2,
580 typename array2< T, Allocator >::size_type j1,
581 typename array2< T, Allocator >::size_type j2,
582 typename array2< T, Allocator >::size_type ,
583 typename array2< T, Allocator >::size_type ,
591 typedef typename array2< T, Allocator >::value_type color;
592 typedef typename array2< T, Allocator >::size_type size_type;
593 typedef typename array2< T, Allocator >::const_pointer const_pointer;
594 typedef typename color::value_type value_type;
595 typedef typename T::template rebind< double >::other ovalue_type;
599 double yy, sum = 0.0;
603 double xx[ 2 ] = { ( i1 + 1 - xs ) * 0.25, ( xe - i2 + 1 ) * 0.25 };
604 for( size_type j = j1 ; j < j2 ; j++ )
610 else if( j == j2 - 1 )
619 double aa[ 2 ] = { xx[ 0 ] * yy, xx[ 1 ] * yy };
621 const_pointer p0 = &in( 0, j );
622 const_pointer p1 = &in( 0, j + 1 );
625 const color &c1 = p0[ i1 ];
626 const color &c2 = p1[ i1 ];
627 const color &c3 = p0[ i1 + 1 ];
628 const color &c4 = p1[ i2 - 1 ];
629 const color &c5 = p0[ i2 ];
630 const color &c6 = p1[ i2 ];
632 r += ( c1.r + c2.r + c3.r + c4.r ) * aa[ 0 ];
633 g += ( c1.g + c2.g + c3.g + c4.g ) * aa[ 0 ];
634 b += ( c1.b + c2.b + c3.b + c4.b ) * aa[ 0 ];
636 r += ( c3.r + c4.r + c5.r + c6.r ) * aa[ 1 ];
637 g += ( c3.g + c4.g + c5.g + c6.g ) * aa[ 1 ];
638 b += ( c3.b + c4.b + c5.b + c6.b ) * aa[ 1 ];
641 sum += ( aa[ 0 ] + aa[ 1 ] ) * 4.0;
646 double xx[ 3 ] = { ( i1 + 1 - xs ) * 0.25, 0.25, ( xe - i2 + 1 ) * 0.25 };
647 for( size_type j = j1 ; j < j2 ; j++ )
653 else if( j == j2 - 1 )
662 double aa[ 3 ] = { xx[ 0 ] * yy, xx[ 1 ] * yy, xx[ 2 ] * yy };
664 const_pointer p0 = &in( 0, j );
665 const_pointer p1 = &in( 0, j + 1 );
669 const color &c1 = p0[ i1 ];
670 const color &c2 = p1[ i1 ];
671 const color &c3 = p0[ i1 + 1 ];
672 const color &c4 = p1[ i1 + 1 ];
674 r += ( c1.r + c2.r + c3.r + c4.r ) * aa[ 0 ];
675 g += ( c1.g + c2.g + c3.g + c4.g ) * aa[ 0 ];
676 b += ( c1.b + c2.b + c3.b + c4.b ) * aa[ 0 ];
683 for( size_type i = i1 + 2 ; i < i2 - 1 ; i++ )
685 const color &c1 = p0[ i ];
686 const color &c2 = p1[ i ];
688 rr += ( c1.r + c2.r ) * 2.0;
689 gg += ( c1.g + c2.g ) * 2.0;
690 bb += ( c1.b + c2.b ) * 2.0;
694 const color &c1 = p0[ i2 - 1 ];
695 const color &c2 = p1[ i2 - 1 ];
696 const color &c3 = p0[ i2 ];
697 const color &c4 = p1[ i2 ];
707 r += ( c1.r + c2.r + c3.r + c4.r ) * aa[ 2 ];
708 g += ( c1.g + c2.g + c3.g + c4.g ) * aa[ 2 ];
709 b += ( c1.b + c2.b + c3.b + c4.b ) * aa[ 2 ];
712 sum += ( aa[ 0 ] + aa[ 2 ] ) * 4.0 + aa[ 1 ] * ( i2 - i1 - 2 ) * 4.0;
716 double min = type_limits< value_type >::minimum( );
717 double max = type_limits< value_type >::maximum( );
719 r = r > min ? r : min;
720 r = r < max ? r : max;
722 g = g > min ? g : min;
723 g = g < max ? g : max;
725 b = b > min ? b : min;
726 b = b < max ? b : max;
727 return( ovalue_type( r, g, b ) );
730 template <
class T,
class Allocator >
731 static const typename T::template rebind< double >::other mean___(
const array3< T, Allocator > &in,
732 typename array3< T, Allocator >::size_type i1,
733 typename array3< T, Allocator >::size_type i2,
734 typename array3< T, Allocator >::size_type j1,
735 typename array3< T, Allocator >::size_type j2,
736 typename array3< T, Allocator >::size_type k1,
737 typename array3< T, Allocator >::size_type k2,
745 typedef typename array3< T, Allocator >::value_type color;
746 typedef typename array3< T, Allocator >::size_type size_type;
747 typedef typename array3< T, Allocator >::const_pointer const_pointer;
748 typedef typename color::value_type value_type;
749 typedef typename T::template rebind< double >::other ovalue_type;
754 double xx[ 3 ] = { ( i1 + 1 - xs ) * 0.125, i2 - i1 < 3 ? 0.0 : 1.0 * 0.125, ( xe - i2 + 1 ) * 0.125 };
756 for( size_type k = k1 ; k < k2 ; k++ )
762 else if( k == k2 - 1 )
771 for( size_type j = j1 ; j < j2 ; j++ )
777 else if( j == j2 - 1 )
786 double aa[ 3 ] = { xx[ 0 ] * yy * zz, xx[ 1 ] * yy * zz, xx[ 2 ] * yy * zz };
788 const_pointer p0 = &in( 0, j , k );
789 const_pointer p1 = &in( 0, j + 1, k );
790 const_pointer p2 = &in( 0, j , k + 1 );
791 const_pointer p3 = &in( 0, j + 1, k + 1 );
797 const color &c1 = p0[ i1 ];
798 const color &c2 = p1[ i1 ];
799 const color &c3 = p2[ i1 ];
800 const color &c4 = p3[ i1 ];
801 const color &c5 = p0[ i1 + 1 ];
802 const color &c6 = p1[ i1 + 1 ];
803 const color &c7 = p2[ i1 + 1 ];
804 const color &c8 = p3[ i1 + 1 ];
806 r += ( c1.r + c2.r + c3.r + c4.r + c5.r + c6.r + c7.r + c8.r ) * aa[ 0 ];
807 g += ( c1.g + c2.g + c3.g + c4.g + c5.g + c6.g + c7.g + c8.g ) * aa[ 0 ];
808 b += ( c1.b + c2.b + c3.b + c4.b + c5.b + c6.b + c7.b + c8.b ) * aa[ 0 ];
810 rr += c5.r + c6.r + c7.r + c8.r;
811 gg += c5.g + c6.g + c7.g + c8.g;
812 bb += c5.b + c6.b + c7.b + c8.b;
815 for( size_type i = i1 + 2 ; i < i2 - 1 ; i++ )
817 const color &c1 = p0[ i ];
818 const color &c2 = p1[ i ];
819 const color &c3 = p2[ i ];
820 const color &c4 = p3[ i ];
822 rr += ( c1.r + c2.r + c3.r + c4.r ) * 2.0;
823 gg += ( c1.g + c2.g + c3.g + c4.g ) * 2.0;
824 bb += ( c1.b + c2.b + c3.b + c4.b ) * 2.0;
828 const color &c1 = p0[ i2 - 1 ];
829 const color &c2 = p1[ i2 - 1 ];
830 const color &c3 = p2[ i2 - 1 ];
831 const color &c4 = p3[ i2 - 1 ];
832 const color &c5 = p0[ i2 ];
833 const color &c6 = p1[ i2 ];
834 const color &c7 = p2[ i2 ];
835 const color &c8 = p3[ i2 ];
837 rr += c1.r + c2.r + c3.r + c4.r;
838 gg += c1.g + c2.g + c3.g + c4.g;
839 bb += c1.b + c2.b + c3.b + c4.b;
845 r += ( c1.r + c2.r + c3.r + c4.r + c5.r + c6.r + c7.r + c8.r ) * aa[ 2 ];
846 g += ( c1.g + c2.g + c3.g + c4.g + c5.g + c6.g + c7.g + c8.g ) * aa[ 2 ];
847 b += ( c1.b + c2.b + c3.b + c4.b + c5.b + c6.b + c7.b + c8.b ) * aa[ 2 ];
852 double numPixels = ( xe - xs ) * ( ye - ys ) * ( ze - zs );
853 double min = type_limits< value_type >::minimum( );
854 double max = type_limits< value_type >::maximum( );
856 r = r > min ? r : min;
857 r = r < max ? r : max;
859 g = g > min ? g : min;
860 g = g < max ? g : max;
862 b = b > min ? b : min;
863 b = b < max ? b : max;
864 return( ovalue_type( r, g, b ) );
868 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
869 void interpolate(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
870 typename array< T1, Allocator1 >::size_type thread_idx,
typename array< T1, Allocator1 >::size_type thread_numx,
871 typename array< T1, Allocator1 >::size_type thread_idy,
typename array< T1, Allocator1 >::size_type thread_numy,
872 typename array< T1, Allocator1 >::size_type thread_idz,
typename array< T1, Allocator1 >::size_type thread_numz )
874 typedef typename array< T1, Allocator1 >::size_type size_type;
875 typedef typename array< T1, Allocator1 >::value_type value_type;
876 typedef typename array< T2, Allocator2 >::value_type out_value_type;
879 size_type iw = in.width( );
880 size_type ow = out.width( );
882 double sx =
static_cast< double >( iw - 1 ) / static_cast< double >( ow );
884 for( i = thread_idx ; i < ow ; i += thread_numx )
889 i1 =
static_cast< size_type
>( xs );
890 i2 =
static_cast< size_type
>( xe );
891 i2 = xe > i2 ? i2 + 1 : i2;
892 i2 = i2 < iw - 1 ? i2 : iw - 1;
894 __interpolate_utility__::round( _mean_< is_color< value_type >::value >::mean___( in, i1, i2, 0, 1, 0, 1, xs, xe, 0, 1, 0, 1 ), out[ i ] );
898 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
899 void interpolate(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
900 typename array2< T1, Allocator1 >::size_type thread_idx,
typename array2< T1, Allocator1 >::size_type thread_numx,
901 typename array2< T1, Allocator1 >::size_type thread_idy,
typename array2< T1, Allocator1 >::size_type thread_numy,
902 typename array2< T1, Allocator1 >::size_type ,
typename array2< T1, Allocator1 >::size_type )
904 typedef typename array2< T1, Allocator1 >::size_type size_type;
905 typedef typename array2< T1, Allocator1 >::value_type value_type;
906 typedef typename array2< T2, Allocator2 >::value_type out_value_type;
908 size_type i, j, i1, i2, j1, j2;
909 size_type iw = in.width( );
910 size_type ih = in.height( );
911 size_type ow = out.width( );
912 size_type oh = out.height( );
914 double sx =
static_cast< double >( iw ) / static_cast< double >( ow );
915 double sy =
static_cast< double >( ih ) / static_cast< double >( oh );
917 for( j = thread_idy ; j < oh ; j += thread_numy )
922 j1 =
static_cast< size_type
>( ys );
923 j2 =
static_cast< size_type
>( ye );
924 j2 = ye > j2 ? j2 + 1 : j2;
925 j2 = j2 < ih - 1 ? j2 : ih - 1;
927 for( i = thread_idx ; i < ow ; i += thread_numx )
932 i1 =
static_cast< size_type
>( xs );
933 i2 =
static_cast< size_type
>( xe );
934 i2 = xe > i2 ? i2 + 1 : i2;
935 i2 = i2 < iw - 1 ? i2 : iw - 1;
937 __interpolate_utility__::round( _mean_< is_color< value_type >::value >::mean___( in, i1, i2, j1, j2, 0, 1, xs, xe, ys, ye, 0, 1 ), out( i, j ) );
942 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
943 void interpolate(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
944 typename array3< T1, Allocator1 >::size_type thread_idx,
typename array3< T1, Allocator1 >::size_type thread_numx,
945 typename array3< T1, Allocator1 >::size_type thread_idy,
typename array3< T1, Allocator1 >::size_type thread_numy,
946 typename array3< T1, Allocator1 >::size_type thread_idz,
typename array3< T1, Allocator1 >::size_type thread_numz )
948 typedef typename array3< T1, Allocator1 >::size_type size_type;
949 typedef typename array3< T1, Allocator1 >::value_type value_type;
950 typedef typename array3< T2, Allocator2 >::value_type out_value_type;
952 size_type i, j, k, i1, i2, j1, j2, k1, k2;
953 size_type iw = in.width( );
954 size_type ih = in.height( );
955 size_type
id = in.depth( );
956 size_type ow = out.width( );
957 size_type oh = out.height( );
958 size_type od = out.depth( );
960 double sx =
static_cast< double >( iw - 1 ) / static_cast< double >( ow );
961 double sy =
static_cast< double >( ih - 1 ) / static_cast< double >( oh );
962 double sz =
static_cast< double >(
id - 1 ) / static_cast< double >( od );
964 for( k = thread_idz ; k < od ; k += thread_numz )
969 k1 =
static_cast< size_type
>( zs );
970 k2 =
static_cast< size_type
>( ze );
971 k2 = ze > k2 ? k2 + 1 : k2;
972 k2 = k2 <
id - 1 ? k2 :
id - 1;
974 for( j = thread_idy ; j < oh ; j += thread_numy )
979 j1 =
static_cast< size_type
>( ys );
980 j2 =
static_cast< size_type
>( ye );
981 j2 = ye > j2 ? j2 + 1 : j2;
982 j2 = j2 < ih - 1 ? j2 : ih - 1;
984 for( i = thread_idx ; i < ow ; i += thread_numx )
989 i1 =
static_cast< size_type
>( xs );
990 i2 =
static_cast< size_type
>( xe );
991 i2 = xe > i2 ? i2 + 1 : i2;
992 i2 = i2 < iw - 1 ? i2 : iw - 1;
994 __interpolate_utility__::round( _mean_< is_color< value_type >::value >::mean___( in, i1, i2, j1, j2, k1, k2, xs, xe, ys, ye, zs, ze ), out( i, j, k ) );
1002 namespace __linear__
1007 template <
class T,
class Allocator >
1008 static double interpolate(
const array< T, Allocator > &in,
1009 typename array< T, Allocator >::size_type i1,
1010 typename array< T, Allocator >::size_type i2,
1011 typename array< T, Allocator >::size_type j1,
1012 typename array< T, Allocator >::size_type j2,
1013 typename array< T, Allocator >::size_type k1,
1014 typename array< T, Allocator >::size_type k2,
1015 double x,
double y,
double z )
1017 typedef typename array< T, Allocator >::value_type value_type;
1018 double min = type_limits< value_type >::minimum( );
1019 double max = type_limits< value_type >::maximum( );
1020 double pix = in[ i1 ] * ( 1.0 - x ) + in[ i2 ] * x;
1021 pix = pix > min ? pix : min;
1022 pix = pix < max ? pix : max;
1026 template <
class T,
class Allocator >
1027 static double interpolate(
const array2< T, Allocator > &in,
1028 typename array2< T, Allocator >::size_type i1,
1029 typename array2< T, Allocator >::size_type i2,
1030 typename array2< T, Allocator >::size_type j1,
1031 typename array2< T, Allocator >::size_type j2,
1032 typename array2< T, Allocator >::size_type ,
1033 typename array2< T, Allocator >::size_type ,
1034 double x,
double y,
double )
1036 typedef typename array2< T, Allocator >::value_type value_type;
1037 double min = type_limits< value_type >::minimum( );
1038 double max = type_limits< value_type >::maximum( );
1039 double pix = ( in( i1, j1 ) * ( 1.0 - x ) + in( i2, j1 ) * x ) * ( 1.0 - y ) + ( in( i1, j2 ) * ( 1.0 - x ) + in( i2, j2 ) * x ) * y;
1040 pix = pix > min ? pix : min;
1041 pix = pix < max ? pix : max;
1045 template <
class T,
class Allocator >
1046 static double interpolate(
const array3< T, Allocator > &in,
1047 typename array3< T, Allocator >::size_type i1,
1048 typename array3< T, Allocator >::size_type i2,
1049 typename array3< T, Allocator >::size_type j1,
1050 typename array3< T, Allocator >::size_type j2,
1051 typename array3< T, Allocator >::size_type k1,
1052 typename array3< T, Allocator >::size_type k2,
1053 double x,
double y,
double z )
1055 typedef typename array3< T, Allocator >::value_type value_type;
1056 double min = type_limits< value_type >::minimum( );
1057 double max = type_limits< value_type >::maximum( );
1058 double pix = ( ( in( i1, j1, k1 ) * ( 1.0 - x ) + in( i2, j1, k1 ) * x ) * ( 1.0 - y ) + ( in( i1, j2, k1 ) * ( 1.0 - x ) + in( i2, j2, k1 ) * x ) * y ) * ( 1.0 - z )
1059 + ( ( in( i1, j1, k2 ) * ( 1.0 - x ) + in( i2, j1, k2 ) * x ) * ( 1.0 - y ) + ( in( i1, j2, k2 ) * ( 1.0 - x ) + in( i2, j2, k2 ) * x ) * y ) * z;
1060 pix = pix > min ? pix : min;
1061 pix = pix < max ? pix : max;
1067 struct _linear_< true >
1069 template <
class T,
class Allocator >
1070 static const typename T::template rebind< double >::other interpolate(
const array< T, Allocator > &in,
1071 typename array< T, Allocator >::size_type i1,
1072 typename array< T, Allocator >::size_type i2,
1073 typename array< T, Allocator >::size_type ,
1074 typename array< T, Allocator >::size_type ,
1075 typename array< T, Allocator >::size_type ,
1076 typename array< T, Allocator >::size_type ,
1077 double x,
double ,
double )
1079 typedef typename array< T, Allocator >::value_type color;
1080 typedef typename color::value_type value_type;
1081 typedef typename T::template rebind< double >::other ovalue_type;
1082 double min = type_limits< value_type >::minimum( );
1083 double max = type_limits< value_type >::maximum( );
1084 double r = in[ i1 ].r * ( 1.0 - x ) + in[ i2 ].r * x;
1085 double g = in[ i1 ].g * ( 1.0 - x ) + in[ i2 ].g * x;
1086 double b = in[ i1 ].b * ( 1.0 - x ) + in[ i2 ].b * x;
1087 r = r > min ? r : min;
1088 r = r < max ? r : max;
1089 g = g > min ? g : min;
1090 g = g < max ? g : max;
1091 b = b > min ? b : min;
1092 b = b < max ? b : max;
1093 return( ovalue_type( r, g, b ) );
1096 template <
class T,
class Allocator >
1097 static const typename T::template rebind< double >::other interpolate(
const array2< T, Allocator > &in,
1098 typename array2< T, Allocator >::size_type i1,
1099 typename array2< T, Allocator >::size_type i2,
1100 typename array2< T, Allocator >::size_type j1,
1101 typename array2< T, Allocator >::size_type j2,
1102 typename array2< T, Allocator >::size_type ,
1103 typename array2< T, Allocator >::size_type ,
1104 double x,
double y,
double )
1106 typedef typename array2< T, Allocator >::value_type color;
1107 typedef typename color::value_type value_type;
1108 typedef typename T::template rebind< double >::other ovalue_type;
1109 double min = type_limits< value_type >::minimum( );
1110 double max = type_limits< value_type >::maximum( );
1111 double r = ( in( i1, j1 ).r * ( 1.0 - x ) + in( i2, j1 ).r * x ) * ( 1.0 - y ) + ( in( i1, j2 ).r * ( 1.0 - x ) + in( i2, j2 ).r * x ) * y;
1112 double g = ( in( i1, j1 ).g * ( 1.0 - x ) + in( i2, j1 ).g * x ) * ( 1.0 - y ) + ( in( i1, j2 ).g * ( 1.0 - x ) + in( i2, j2 ).g * x ) * y;
1113 double b = ( in( i1, j1 ).b * ( 1.0 - x ) + in( i2, j1 ).b * x ) * ( 1.0 - y ) + ( in( i1, j2 ).b * ( 1.0 - x ) + in( i2, j2 ).b * x ) * y;
1114 r = r > min ? r : min;
1115 r = r < max ? r : max;
1116 g = g > min ? g : min;
1117 g = g < max ? g : max;
1118 b = b > min ? b : min;
1119 b = b < max ? b : max;
1120 return( ovalue_type( r, g, b ) );
1123 template <
class T,
class Allocator >
1124 static const typename T::template rebind< double >::other interpolate(
const array3< T, Allocator > &in,
1125 typename array3< T, Allocator >::size_type i1,
1126 typename array3< T, Allocator >::size_type i2,
1127 typename array3< T, Allocator >::size_type j1,
1128 typename array3< T, Allocator >::size_type j2,
1129 typename array3< T, Allocator >::size_type k1,
1130 typename array3< T, Allocator >::size_type k2,
1131 double x,
double y,
double z )
1133 typedef typename array3< T, Allocator >::value_type color;
1134 typedef typename color::value_type value_type;
1135 typedef typename T::template rebind< double >::other ovalue_type;
1136 double min = type_limits< value_type >::minimum( );
1137 double max = type_limits< value_type >::maximum( );
1138 double r = ( ( in( i1, j1, k1 ).r * ( 1.0 - x ) + in( i2, j1, k1 ).r * x ) * ( 1.0 - y ) + ( in( i1, j2, k1 ).r * ( 1.0 - x ) + in( i2, j2, k1 ).r * x ) * y ) * ( 1.0 - z )
1139 + ( ( in( i1, j1, k2 ).r * ( 1.0 - x ) + in( i2, j1, k2 ).r * x ) * ( 1.0 - y ) + ( in( i1, j2, k2 ).r * ( 1.0 - x ) + in( i2, j2, k2 ).r * x ) * y ) * z;
1140 double g = ( ( in( i1, j1, k1 ).g * ( 1.0 - x ) + in( i2, j1, k1 ).g * x ) * ( 1.0 - y ) + ( in( i1, j2, k1 ).g * ( 1.0 - x ) + in( i2, j2, k1 ).g * x ) * y ) * ( 1.0 - z )
1141 + ( ( in( i1, j1, k2 ).g * ( 1.0 - x ) + in( i2, j1, k2 ).g * x ) * ( 1.0 - y ) + ( in( i1, j2, k2 ).g * ( 1.0 - x ) + in( i2, j2, k2 ).g * x ) * y ) * z;
1142 double b = ( ( in( i1, j1, k1 ).b * ( 1.0 - x ) + in( i2, j1, k1 ).b * x ) * ( 1.0 - y ) + ( in( i1, j2, k1 ).b * ( 1.0 - x ) + in( i2, j2, k1 ).b * x ) * y ) * ( 1.0 - z )
1143 + ( ( in( i1, j1, k2 ).b * ( 1.0 - x ) + in( i2, j1, k2 ).b * x ) * ( 1.0 - y ) + ( in( i1, j2, k2 ).b * ( 1.0 - x ) + in( i2, j2, k2 ).b * x ) * y ) * z;
1144 r = r > min ? r : min;
1145 r = r < max ? r : max;
1146 g = g > min ? g : min;
1147 g = g < max ? g : max;
1148 b = b > min ? b : min;
1149 b = b < max ? b : max;
1150 return( ovalue_type( r, g, b ) );
1154 template <
class Array1,
class Array2 >
1155 void interpolate(
const Array1 &in, Array2 &out,
1156 typename Array1::size_type thread_idx,
typename Array1::size_type thread_numx,
1157 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
1158 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz )
1160 typedef typename Array1::size_type size_type;
1161 typedef typename Array1::value_type value_type;
1162 typedef typename Array2::value_type out_value_type;
1164 size_type i, j, k, i1, i2, j1, j2, k1, k2;
1165 size_type iw = in.width( );
1166 size_type ih = in.height( );
1167 size_type
id = in.depth( );
1168 size_type ow = out.width( );
1169 size_type oh = out.height( );
1170 size_type od = out.depth( );
1172 double sx =
static_cast< double >( iw ) / static_cast< double >( ow );
1173 double sy =
static_cast< double >( ih ) / static_cast< double >( oh );
1174 double sz =
static_cast< double >( id ) / static_cast< double >( od );
1177 for( k = thread_idz ; k < od ; k += thread_numz )
1180 k1 =
static_cast< size_type
>( z );
1182 k2 = k1 <
id - 1 ? k1 + 1 : k1;
1183 for( j = thread_idy ; j < oh ; j += thread_numy )
1186 j1 =
static_cast< size_type
>( y );
1188 j2 = j1 < ih - 1 ? j1 + 1 : j1;
1189 for( i = thread_idx ; i < ow ; i += thread_numx )
1192 i1 =
static_cast< size_type
>( x );
1194 i2 = i1 < iw - 1 ? i1 + 1 : i1;
1196 __interpolate_utility__::round( _linear_< is_color< value_type >::value >::interpolate( in, i1, i2, j1, j2, k1, k2, x, y, z ), out( i, j, k ) );
1209 inline double sinc1(
double t ){
return( 1.0 + ( t - 2.0 ) * t * t ); }
1212 inline double sinc2(
double t ){
return( 4.0 + ( -8.0 + ( 5.0 - t ) * t ) * t ); }
1218 template <
class T,
class Allocator >
1219 static double interpolate(
const array< T, Allocator > &in,
1220 typename array< T, Allocator >::size_type i[4],
1221 typename array< T, Allocator >::size_type [4],
1222 typename array< T, Allocator >::size_type [4],
1223 double x,
double ,
double )
1225 typedef typename array< T, Allocator >::value_type value_type;
1227 double u0 = sinc2( 1 + x );
1228 double u1 = sinc1( x );
1229 double u2 = sinc1( 1 - x );
1230 double u3 = sinc2( 2 - x );
1231 double pix = in[ i[ 0 ] ] * u0 + in[ i[ 1 ] ] * u1 + in[ i[ 2 ] ] * u2 + in[ i[ 3 ] ] * u3;
1233 double min = type_limits< value_type >::minimum( );
1234 double max = type_limits< value_type >::maximum( );
1235 pix = pix > min ? pix : min;
1236 pix = pix < max ? pix : max;
1241 template <
class T,
class Allocator >
1242 static double interpolate(
const array2< T, Allocator > &in,
1243 typename array2< T, Allocator >::size_type i[4],
1244 typename array2< T, Allocator >::size_type j[4],
1245 typename array2< T, Allocator >::size_type [4],
1246 double x,
double y,
double )
1248 typedef typename array2< T, Allocator >::value_type value_type;
1250 double u0 = sinc2( 1 + x );
1251 double u1 = sinc1( x );
1252 double u2 = sinc1( 1 - x );
1253 double u3 = sinc2( 2 - x );
1254 double v0 = sinc2( 1 + y );
1255 double v1 = sinc1( y );
1256 double v2 = sinc1( 1 - y );
1257 double v3 = sinc2( 2 - y );
1258 double pix = ( in( i[ 0 ], j[ 0 ] ) * u0 + in( i[ 1 ], j[ 0 ] ) * u1 + in( i[ 2 ], j[ 0 ] ) * u2 + in( i[ 3 ], j[ 0 ] ) * u3 ) * v0
1259 + ( in( i[ 0 ], j[ 1 ] ) * u0 + in( i[ 1 ], j[ 1 ] ) * u1 + in( i[ 2 ], j[ 1 ] ) * u2 + in( i[ 3 ], j[ 1 ] ) * u3 ) * v1
1260 + ( in( i[ 0 ], j[ 2 ] ) * u0 + in( i[ 1 ], j[ 2 ] ) * u1 + in( i[ 2 ], j[ 2 ] ) * u2 + in( i[ 3 ], j[ 2 ] ) * u3 ) * v2
1261 + ( in( i[ 0 ], j[ 3 ] ) * u0 + in( i[ 1 ], j[ 3 ] ) * u1 + in( i[ 2 ], j[ 3 ] ) * u2 + in( i[ 3 ], j[ 3 ] ) * u3 ) * v3;
1263 double min = type_limits< value_type >::minimum( );
1264 double max = type_limits< value_type >::maximum( );
1265 pix = pix > min ? pix : min;
1266 pix = pix < max ? pix : max;
1271 template <
class T,
class Allocator >
1272 static double interpolate(
const array3< T, Allocator > &in,
1273 typename array3< T, Allocator >::size_type i[4],
1274 typename array3< T, Allocator >::size_type j[4],
1275 typename array3< T, Allocator >::size_type k[4],
1276 double x,
double y,
double z )
1278 typedef typename array3< T, Allocator >::value_type value_type;
1280 double u0 = sinc2( 1 + x );
1281 double u1 = sinc1( x );
1282 double u2 = sinc1( 1 - x );
1283 double u3 = sinc2( 2 - x );
1284 double v0 = sinc2( 1 + y );
1285 double v1 = sinc1( y );
1286 double v2 = sinc1( 1 - y );
1287 double v3 = sinc2( 2 - y );
1288 double w0 = sinc2( 1 + z );
1289 double w1 = sinc1( z );
1290 double w2 = sinc1( 1 - z );
1291 double w3 = sinc2( 2 - z );
1293 double p0 = ( ( in( i[ 0 ], j[ 0 ], k[ 0 ] ) * u0 + in( i[ 1 ], j[ 0 ], k[ 0 ] ) * u1 + in( i[ 2 ], j[ 0 ], k[ 0 ] ) * u2 + in( i[ 3 ], j[ 0 ], k[ 0 ] ) * u3 ) * v0
1294 + ( in( i[ 0 ], j[ 1 ], k[ 0 ] ) * u0 + in( i[ 1 ], j[ 1 ], k[ 0 ] ) * u1 + in( i[ 2 ], j[ 1 ], k[ 0 ] ) * u2 + in( i[ 3 ], j[ 1 ], k[ 0 ] ) * u3 ) * v1
1295 + ( in( i[ 0 ], j[ 2 ], k[ 0 ] ) * u0 + in( i[ 1 ], j[ 2 ], k[ 0 ] ) * u1 + in( i[ 2 ], j[ 2 ], k[ 0 ] ) * u2 + in( i[ 3 ], j[ 2 ], k[ 0 ] ) * u3 ) * v2
1296 + ( in( i[ 0 ], j[ 3 ], k[ 0 ] ) * u0 + in( i[ 1 ], j[ 3 ], k[ 0 ] ) * u1 + in( i[ 2 ], j[ 3 ], k[ 0 ] ) * u2 + in( i[ 3 ], j[ 3 ], k[ 0 ] ) * u3 ) * v3 );
1297 double p1 = ( ( in( i[ 0 ], j[ 0 ], k[ 1 ] ) * u0 + in( i[ 1 ], j[ 0 ], k[ 1 ] ) * u1 + in( i[ 2 ], j[ 0 ], k[ 1 ] ) * u2 + in( i[ 3 ], j[ 0 ], k[ 1 ] ) * u3 ) * v0
1298 + ( in( i[ 0 ], j[ 1 ], k[ 1 ] ) * u0 + in( i[ 1 ], j[ 1 ], k[ 1 ] ) * u1 + in( i[ 2 ], j[ 1 ], k[ 1 ] ) * u2 + in( i[ 3 ], j[ 1 ], k[ 1 ] ) * u3 ) * v1
1299 + ( in( i[ 0 ], j[ 2 ], k[ 1 ] ) * u0 + in( i[ 1 ], j[ 2 ], k[ 1 ] ) * u1 + in( i[ 2 ], j[ 2 ], k[ 1 ] ) * u2 + in( i[ 3 ], j[ 2 ], k[ 1 ] ) * u3 ) * v2
1300 + ( in( i[ 0 ], j[ 3 ], k[ 1 ] ) * u0 + in( i[ 1 ], j[ 3 ], k[ 1 ] ) * u1 + in( i[ 2 ], j[ 3 ], k[ 1 ] ) * u2 + in( i[ 3 ], j[ 3 ], k[ 1 ] ) * u3 ) * v3 );
1301 double p2 = ( ( in( i[ 0 ], j[ 0 ], k[ 2 ] ) * u0 + in( i[ 1 ], j[ 0 ], k[ 2 ] ) * u1 + in( i[ 2 ], j[ 0 ], k[ 2 ] ) * u2 + in( i[ 3 ], j[ 0 ], k[ 2 ] ) * u3 ) * v0
1302 + ( in( i[ 0 ], j[ 1 ], k[ 2 ] ) * u0 + in( i[ 1 ], j[ 1 ], k[ 2 ] ) * u1 + in( i[ 2 ], j[ 1 ], k[ 2 ] ) * u2 + in( i[ 3 ], j[ 1 ], k[ 2 ] ) * u3 ) * v1
1303 + ( in( i[ 0 ], j[ 2 ], k[ 2 ] ) * u0 + in( i[ 1 ], j[ 2 ], k[ 2 ] ) * u1 + in( i[ 2 ], j[ 2 ], k[ 2 ] ) * u2 + in( i[ 3 ], j[ 2 ], k[ 2 ] ) * u3 ) * v2
1304 + ( in( i[ 0 ], j[ 3 ], k[ 2 ] ) * u0 + in( i[ 1 ], j[ 3 ], k[ 2 ] ) * u1 + in( i[ 2 ], j[ 3 ], k[ 2 ] ) * u2 + in( i[ 3 ], j[ 3 ], k[ 2 ] ) * u3 ) * v3 );
1305 double p3 = ( ( in( i[ 0 ], j[ 0 ], k[ 3 ] ) * u0 + in( i[ 1 ], j[ 0 ], k[ 3 ] ) * u1 + in( i[ 2 ], j[ 0 ], k[ 3 ] ) * u2 + in( i[ 3 ], j[ 0 ], k[ 3 ] ) * u3 ) * v0
1306 + ( in( i[ 0 ], j[ 1 ], k[ 3 ] ) * u0 + in( i[ 1 ], j[ 1 ], k[ 3 ] ) * u1 + in( i[ 2 ], j[ 1 ], k[ 3 ] ) * u2 + in( i[ 3 ], j[ 1 ], k[ 3 ] ) * u3 ) * v1
1307 + ( in( i[ 0 ], j[ 2 ], k[ 3 ] ) * u0 + in( i[ 1 ], j[ 2 ], k[ 3 ] ) * u1 + in( i[ 2 ], j[ 2 ], k[ 3 ] ) * u2 + in( i[ 3 ], j[ 2 ], k[ 3 ] ) * u3 ) * v2
1308 + ( in( i[ 0 ], j[ 3 ], k[ 3 ] ) * u0 + in( i[ 1 ], j[ 3 ], k[ 3 ] ) * u1 + in( i[ 2 ], j[ 3 ], k[ 3 ] ) * u2 + in( i[ 3 ], j[ 3 ], k[ 3 ] ) * u3 ) * v3 );
1309 double pix = p0 * w0 + p1 * w1 + p2 * w2 + p3 * w3;
1311 double min = type_limits< value_type >::minimum( );
1312 double max = type_limits< value_type >::maximum( );
1313 pix = pix > min ? pix : min;
1314 pix = pix < max ? pix : max;
1321 struct _cubic_< true >
1323 template <
class T,
class Allocator >
1324 static const typename T::template rebind< double >::other interpolate(
const array< T, Allocator > &in,
1325 typename array< T, Allocator >::size_type i[4],
1326 typename array< T, Allocator >::size_type [4],
1327 typename array< T, Allocator >::size_type [4],
1328 double x,
double ,
double )
1330 typedef typename array< T, Allocator >::value_type color;
1331 typedef typename color::value_type value_type;
1332 typedef typename T::template rebind< double >::other ovalue_type;
1334 double u0 = sinc2( 1 + x );
1335 double u1 = sinc1( x );
1336 double u2 = sinc1( 1 - x );
1337 double u3 = sinc2( 2 - x );
1338 double r = in[ i[ 0 ] ].r * u0 + in[ i[ 1 ] ].r * u1 + in[ i[ 2 ] ].r * u2 + in[ i[ 3 ] ].r * u3;
1339 double g = in[ i[ 0 ] ].g * u0 + in[ i[ 1 ] ].g * u1 + in[ i[ 2 ] ].g * u2 + in[ i[ 3 ] ].g * u3;
1340 double b = in[ i[ 0 ] ].b * u0 + in[ i[ 1 ] ].b * u1 + in[ i[ 2 ] ].b * u2 + in[ i[ 3 ] ].b * u3;
1342 double min = type_limits< value_type >::minimum( );
1343 double max = type_limits< value_type >::maximum( );
1345 r = r > min ? r : min;
1346 r = r < max ? r : max;
1347 g = g > min ? g : min;
1348 g = g < max ? g : max;
1349 b = b > min ? b : min;
1350 b = b < max ? b : max;
1352 return( ovalue_type( r, g, b ) );
1355 template <
class T,
class Allocator >
1356 static const typename T::template rebind< double >::other interpolate(
const array2< T, Allocator > &in,
1357 typename array2< T, Allocator >::size_type i[4],
1358 typename array2< T, Allocator >::size_type j[4],
1359 typename array2< T, Allocator >::size_type [4],
1360 double x,
double y,
double )
1362 typedef typename array2< T, Allocator >::value_type color;
1363 typedef typename color::value_type value_type;
1364 typedef typename T::template rebind< double >::other ovalue_type;
1366 double u0 = sinc2( 1 + x );
1367 double u1 = sinc1( x );
1368 double u2 = sinc1( 1 - x );
1369 double u3 = sinc2( 2 - x );
1370 double v0 = sinc2( 1 + y );
1371 double v1 = sinc1( y );
1372 double v2 = sinc1( 1 - y );
1373 double v3 = sinc2( 2 - y );
1375 double r = ( in( i[ 0 ], j[ 0 ] ).r * u0 + in( i[ 1 ], j[ 0 ] ).r * u1 + in( i[ 2 ], j[ 0 ] ).r * u2 + in( i[ 3 ], j[ 0 ] ).r * u3 ) * v0
1376 + ( in( i[ 0 ], j[ 1 ] ).r * u0 + in( i[ 1 ], j[ 1 ] ).r * u1 + in( i[ 2 ], j[ 1 ] ).r * u2 + in( i[ 3 ], j[ 1 ] ).r * u3 ) * v1
1377 + ( in( i[ 0 ], j[ 2 ] ).r * u0 + in( i[ 1 ], j[ 2 ] ).r * u1 + in( i[ 2 ], j[ 2 ] ).r * u2 + in( i[ 3 ], j[ 2 ] ).r * u3 ) * v2
1378 + ( in( i[ 0 ], j[ 3 ] ).r * u0 + in( i[ 1 ], j[ 3 ] ).r * u1 + in( i[ 2 ], j[ 3 ] ).r * u2 + in( i[ 3 ], j[ 3 ] ).r * u3 ) * v3;
1379 double g = ( in( i[ 0 ], j[ 0 ] ).g * u0 + in( i[ 1 ], j[ 0 ] ).g * u1 + in( i[ 2 ], j[ 0 ] ).g * u2 + in( i[ 3 ], j[ 0 ] ).g * u3 ) * v0
1380 + ( in( i[ 0 ], j[ 1 ] ).g * u0 + in( i[ 1 ], j[ 1 ] ).g * u1 + in( i[ 2 ], j[ 1 ] ).g * u2 + in( i[ 3 ], j[ 1 ] ).g * u3 ) * v1
1381 + ( in( i[ 0 ], j[ 2 ] ).g * u0 + in( i[ 1 ], j[ 2 ] ).g * u1 + in( i[ 2 ], j[ 2 ] ).g * u2 + in( i[ 3 ], j[ 2 ] ).g * u3 ) * v2
1382 + ( in( i[ 0 ], j[ 3 ] ).g * u0 + in( i[ 1 ], j[ 3 ] ).g * u1 + in( i[ 2 ], j[ 3 ] ).g * u2 + in( i[ 3 ], j[ 3 ] ).g * u3 ) * v3;
1383 double b = ( in( i[ 0 ], j[ 0 ] ).b * u0 + in( i[ 1 ], j[ 0 ] ).b * u1 + in( i[ 2 ], j[ 0 ] ).b * u2 + in( i[ 3 ], j[ 0 ] ).b * u3 ) * v0
1384 + ( in( i[ 0 ], j[ 1 ] ).b * u0 + in( i[ 1 ], j[ 1 ] ).b * u1 + in( i[ 2 ], j[ 1 ] ).b * u2 + in( i[ 3 ], j[ 1 ] ).b * u3 ) * v1
1385 + ( in( i[ 0 ], j[ 2 ] ).b * u0 + in( i[ 1 ], j[ 2 ] ).b * u1 + in( i[ 2 ], j[ 2 ] ).b * u2 + in( i[ 3 ], j[ 2 ] ).b * u3 ) * v2
1386 + ( in( i[ 0 ], j[ 3 ] ).b * u0 + in( i[ 1 ], j[ 3 ] ).b * u1 + in( i[ 2 ], j[ 3 ] ).b * u2 + in( i[ 3 ], j[ 3 ] ).b * u3 ) * v3;
1388 double min = type_limits< value_type >::minimum( );
1389 double max = type_limits< value_type >::maximum( );
1391 r = r > min ? r : min;
1392 r = r < max ? r : max;
1393 g = g > min ? g : min;
1394 g = g < max ? g : max;
1395 b = b > min ? b : min;
1396 b = b < max ? b : max;
1398 return( ovalue_type( r, g, b ) );
1401 template <
class T,
class Allocator >
1402 static const typename T::template rebind< double >::other interpolate(
const array3< T, Allocator > &in,
1403 typename array3< T, Allocator >::size_type i[4],
1404 typename array3< T, Allocator >::size_type j[4],
1405 typename array3< T, Allocator >::size_type k[4],
1406 double x,
double y,
double z )
1408 typedef typename array3< T, Allocator >::value_type color;
1409 typedef typename color::value_type value_type;
1410 typedef typename T::template rebind< double >::other ovalue_type;
1412 double u0 = sinc2( 1 + x );
1413 double u1 = sinc1( x );
1414 double u2 = sinc1( 1 - x );
1415 double u3 = sinc2( 2 - x );
1416 double v0 = sinc2( 1 + y );
1417 double v1 = sinc1( y );
1418 double v2 = sinc1( 1 - y );
1419 double v3 = sinc2( 2 - y );
1420 double w0 = sinc2( 1 + z );
1421 double w1 = sinc1( z );
1422 double w2 = sinc1( 1 - z );
1423 double w3 = sinc2( 2 - z );
1425 double r0 = ( ( in( i[ 0 ], j[ 0 ], k[ 0 ] ).r * u0 + in( i[ 1 ], j[ 0 ], k[ 0 ] ).r * u1 + in( i[ 2 ], j[ 0 ], k[ 0 ] ).r * u2 + in( i[ 3 ], j[ 0 ], k[ 0 ] ).r * u3 ) * v0
1426 + ( in( i[ 0 ], j[ 1 ], k[ 0 ] ).r * u0 + in( i[ 1 ], j[ 1 ], k[ 0 ] ).r * u1 + in( i[ 2 ], j[ 1 ], k[ 0 ] ).r * u2 + in( i[ 3 ], j[ 1 ], k[ 0 ] ).r * u3 ) * v1
1427 + ( in( i[ 0 ], j[ 2 ], k[ 0 ] ).r * u0 + in( i[ 1 ], j[ 2 ], k[ 0 ] ).r * u1 + in( i[ 2 ], j[ 2 ], k[ 0 ] ).r * u2 + in( i[ 3 ], j[ 2 ], k[ 0 ] ).r * u3 ) * v2
1428 + ( in( i[ 0 ], j[ 3 ], k[ 0 ] ).r * u0 + in( i[ 1 ], j[ 3 ], k[ 0 ] ).r * u1 + in( i[ 2 ], j[ 3 ], k[ 0 ] ).r * u2 + in( i[ 3 ], j[ 3 ], k[ 0 ] ).r * u3 ) * v3 );
1429 double r1 = ( ( in( i[ 0 ], j[ 0 ], k[ 1 ] ).r * u0 + in( i[ 1 ], j[ 0 ], k[ 1 ] ).r * u1 + in( i[ 2 ], j[ 0 ], k[ 1 ] ).r * u2 + in( i[ 3 ], j[ 0 ], k[ 1 ] ).r * u3 ) * v0
1430 + ( in( i[ 0 ], j[ 1 ], k[ 1 ] ).r * u0 + in( i[ 1 ], j[ 1 ], k[ 1 ] ).r * u1 + in( i[ 2 ], j[ 1 ], k[ 1 ] ).r * u2 + in( i[ 3 ], j[ 1 ], k[ 1 ] ).r * u3 ) * v1
1431 + ( in( i[ 0 ], j[ 2 ], k[ 1 ] ).r * u0 + in( i[ 1 ], j[ 2 ], k[ 1 ] ).r * u1 + in( i[ 2 ], j[ 2 ], k[ 1 ] ).r * u2 + in( i[ 3 ], j[ 2 ], k[ 1 ] ).r * u3 ) * v2
1432 + ( in( i[ 0 ], j[ 3 ], k[ 1 ] ).r * u0 + in( i[ 1 ], j[ 3 ], k[ 1 ] ).r * u1 + in( i[ 2 ], j[ 3 ], k[ 1 ] ).r * u2 + in( i[ 3 ], j[ 3 ], k[ 1 ] ).r * u3 ) * v3 );
1433 double r2 = ( ( in( i[ 0 ], j[ 0 ], k[ 2 ] ).r * u0 + in( i[ 1 ], j[ 0 ], k[ 2 ] ).r * u1 + in( i[ 2 ], j[ 0 ], k[ 2 ] ).r * u2 + in( i[ 3 ], j[ 0 ], k[ 2 ] ).r * u3 ) * v0
1434 + ( in( i[ 0 ], j[ 1 ], k[ 2 ] ).r * u0 + in( i[ 1 ], j[ 1 ], k[ 2 ] ).r * u1 + in( i[ 2 ], j[ 1 ], k[ 2 ] ).r * u2 + in( i[ 3 ], j[ 1 ], k[ 2 ] ).r * u3 ) * v1
1435 + ( in( i[ 0 ], j[ 2 ], k[ 2 ] ).r * u0 + in( i[ 1 ], j[ 2 ], k[ 2 ] ).r * u1 + in( i[ 2 ], j[ 2 ], k[ 2 ] ).r * u2 + in( i[ 3 ], j[ 2 ], k[ 2 ] ).r * u3 ) * v2
1436 + ( in( i[ 0 ], j[ 3 ], k[ 2 ] ).r * u0 + in( i[ 1 ], j[ 3 ], k[ 2 ] ).r * u1 + in( i[ 2 ], j[ 3 ], k[ 2 ] ).r * u2 + in( i[ 3 ], j[ 3 ], k[ 2 ] ).r * u3 ) * v3 );
1437 double r3 = ( ( in( i[ 0 ], j[ 0 ], k[ 3 ] ).r * u0 + in( i[ 1 ], j[ 0 ], k[ 3 ] ).r * u1 + in( i[ 2 ], j[ 0 ], k[ 3 ] ).r * u2 + in( i[ 3 ], j[ 0 ], k[ 3 ] ).r * u3 ) * v0
1438 + ( in( i[ 0 ], j[ 1 ], k[ 3 ] ).r * u0 + in( i[ 1 ], j[ 1 ], k[ 3 ] ).r * u1 + in( i[ 2 ], j[ 1 ], k[ 3 ] ).r * u2 + in( i[ 3 ], j[ 1 ], k[ 3 ] ).r * u3 ) * v1
1439 + ( in( i[ 0 ], j[ 2 ], k[ 3 ] ).r * u0 + in( i[ 1 ], j[ 2 ], k[ 3 ] ).r * u1 + in( i[ 2 ], j[ 2 ], k[ 3 ] ).r * u2 + in( i[ 3 ], j[ 2 ], k[ 3 ] ).r * u3 ) * v2
1440 + ( in( i[ 0 ], j[ 3 ], k[ 3 ] ).r * u0 + in( i[ 1 ], j[ 3 ], k[ 3 ] ).r * u1 + in( i[ 2 ], j[ 3 ], k[ 3 ] ).r * u2 + in( i[ 3 ], j[ 3 ], k[ 3 ] ).r * u3 ) * v3 );
1441 double g0 = ( ( in( i[ 0 ], j[ 0 ], k[ 0 ] ).g * u0 + in( i[ 1 ], j[ 0 ], k[ 0 ] ).g * u1 + in( i[ 2 ], j[ 0 ], k[ 0 ] ).g * u2 + in( i[ 3 ], j[ 0 ], k[ 0 ] ).g * u3 ) * v0
1442 + ( in( i[ 0 ], j[ 1 ], k[ 0 ] ).g * u0 + in( i[ 1 ], j[ 1 ], k[ 0 ] ).g * u1 + in( i[ 2 ], j[ 1 ], k[ 0 ] ).g * u2 + in( i[ 3 ], j[ 1 ], k[ 0 ] ).g * u3 ) * v1
1443 + ( in( i[ 0 ], j[ 2 ], k[ 0 ] ).g * u0 + in( i[ 1 ], j[ 2 ], k[ 0 ] ).g * u1 + in( i[ 2 ], j[ 2 ], k[ 0 ] ).g * u2 + in( i[ 3 ], j[ 2 ], k[ 0 ] ).g * u3 ) * v2
1444 + ( in( i[ 0 ], j[ 3 ], k[ 0 ] ).g * u0 + in( i[ 1 ], j[ 3 ], k[ 0 ] ).g * u1 + in( i[ 2 ], j[ 3 ], k[ 0 ] ).g * u2 + in( i[ 3 ], j[ 3 ], k[ 0 ] ).g * u3 ) * v3 );
1445 double g1 = ( ( in( i[ 0 ], j[ 0 ], k[ 1 ] ).g * u0 + in( i[ 1 ], j[ 0 ], k[ 1 ] ).g * u1 + in( i[ 2 ], j[ 0 ], k[ 1 ] ).g * u2 + in( i[ 3 ], j[ 0 ], k[ 1 ] ).g * u3 ) * v0
1446 + ( in( i[ 0 ], j[ 1 ], k[ 1 ] ).g * u0 + in( i[ 1 ], j[ 1 ], k[ 1 ] ).g * u1 + in( i[ 2 ], j[ 1 ], k[ 1 ] ).g * u2 + in( i[ 3 ], j[ 1 ], k[ 1 ] ).g * u3 ) * v1
1447 + ( in( i[ 0 ], j[ 2 ], k[ 1 ] ).g * u0 + in( i[ 1 ], j[ 2 ], k[ 1 ] ).g * u1 + in( i[ 2 ], j[ 2 ], k[ 1 ] ).g * u2 + in( i[ 3 ], j[ 2 ], k[ 1 ] ).g * u3 ) * v2
1448 + ( in( i[ 0 ], j[ 3 ], k[ 1 ] ).g * u0 + in( i[ 1 ], j[ 3 ], k[ 1 ] ).g * u1 + in( i[ 2 ], j[ 3 ], k[ 1 ] ).g * u2 + in( i[ 3 ], j[ 3 ], k[ 1 ] ).g * u3 ) * v3 );
1449 double g2 = ( ( in( i[ 0 ], j[ 0 ], k[ 2 ] ).g * u0 + in( i[ 1 ], j[ 0 ], k[ 2 ] ).g * u1 + in( i[ 2 ], j[ 0 ], k[ 2 ] ).g * u2 + in( i[ 3 ], j[ 0 ], k[ 2 ] ).g * u3 ) * v0
1450 + ( in( i[ 0 ], j[ 1 ], k[ 2 ] ).g * u0 + in( i[ 1 ], j[ 1 ], k[ 2 ] ).g * u1 + in( i[ 2 ], j[ 1 ], k[ 2 ] ).g * u2 + in( i[ 3 ], j[ 1 ], k[ 2 ] ).g * u3 ) * v1
1451 + ( in( i[ 0 ], j[ 2 ], k[ 2 ] ).g * u0 + in( i[ 1 ], j[ 2 ], k[ 2 ] ).g * u1 + in( i[ 2 ], j[ 2 ], k[ 2 ] ).g * u2 + in( i[ 3 ], j[ 2 ], k[ 2 ] ).g * u3 ) * v2
1452 + ( in( i[ 0 ], j[ 3 ], k[ 2 ] ).g * u0 + in( i[ 1 ], j[ 3 ], k[ 2 ] ).g * u1 + in( i[ 2 ], j[ 3 ], k[ 2 ] ).g * u2 + in( i[ 3 ], j[ 3 ], k[ 2 ] ).g * u3 ) * v3 );
1453 double g3 = ( ( in( i[ 0 ], j[ 0 ], k[ 3 ] ).g * u0 + in( i[ 1 ], j[ 0 ], k[ 3 ] ).g * u1 + in( i[ 2 ], j[ 0 ], k[ 3 ] ).g * u2 + in( i[ 3 ], j[ 0 ], k[ 3 ] ).g * u3 ) * v0
1454 + ( in( i[ 0 ], j[ 1 ], k[ 3 ] ).g * u0 + in( i[ 1 ], j[ 1 ], k[ 3 ] ).g * u1 + in( i[ 2 ], j[ 1 ], k[ 3 ] ).g * u2 + in( i[ 3 ], j[ 1 ], k[ 3 ] ).g * u3 ) * v1
1455 + ( in( i[ 0 ], j[ 2 ], k[ 3 ] ).g * u0 + in( i[ 1 ], j[ 2 ], k[ 3 ] ).g * u1 + in( i[ 2 ], j[ 2 ], k[ 3 ] ).g * u2 + in( i[ 3 ], j[ 2 ], k[ 3 ] ).g * u3 ) * v2
1456 + ( in( i[ 0 ], j[ 3 ], k[ 3 ] ).g * u0 + in( i[ 1 ], j[ 3 ], k[ 3 ] ).g * u1 + in( i[ 2 ], j[ 3 ], k[ 3 ] ).g * u2 + in( i[ 3 ], j[ 3 ], k[ 3 ] ).g * u3 ) * v3 );
1457 double b0 = ( ( in( i[ 0 ], j[ 0 ], k[ 0 ] ).b * u0 + in( i[ 1 ], j[ 0 ], k[ 0 ] ).b * u1 + in( i[ 2 ], j[ 0 ], k[ 0 ] ).b * u2 + in( i[ 3 ], j[ 0 ], k[ 0 ] ).b * u3 ) * v0
1458 + ( in( i[ 0 ], j[ 1 ], k[ 0 ] ).b * u0 + in( i[ 1 ], j[ 1 ], k[ 0 ] ).b * u1 + in( i[ 2 ], j[ 1 ], k[ 0 ] ).b * u2 + in( i[ 3 ], j[ 1 ], k[ 0 ] ).b * u3 ) * v1
1459 + ( in( i[ 0 ], j[ 2 ], k[ 0 ] ).b * u0 + in( i[ 1 ], j[ 2 ], k[ 0 ] ).b * u1 + in( i[ 2 ], j[ 2 ], k[ 0 ] ).b * u2 + in( i[ 3 ], j[ 2 ], k[ 0 ] ).b * u3 ) * v2
1460 + ( in( i[ 0 ], j[ 3 ], k[ 0 ] ).b * u0 + in( i[ 1 ], j[ 3 ], k[ 0 ] ).b * u1 + in( i[ 2 ], j[ 3 ], k[ 0 ] ).b * u2 + in( i[ 3 ], j[ 3 ], k[ 0 ] ).b * u3 ) * v3 );
1461 double b1 = ( ( in( i[ 0 ], j[ 0 ], k[ 1 ] ).b * u0 + in( i[ 1 ], j[ 0 ], k[ 1 ] ).b * u1 + in( i[ 2 ], j[ 0 ], k[ 1 ] ).b * u2 + in( i[ 3 ], j[ 0 ], k[ 1 ] ).b * u3 ) * v0
1462 + ( in( i[ 0 ], j[ 1 ], k[ 1 ] ).b * u0 + in( i[ 1 ], j[ 1 ], k[ 1 ] ).b * u1 + in( i[ 2 ], j[ 1 ], k[ 1 ] ).b * u2 + in( i[ 3 ], j[ 1 ], k[ 1 ] ).b * u3 ) * v1
1463 + ( in( i[ 0 ], j[ 2 ], k[ 1 ] ).b * u0 + in( i[ 1 ], j[ 2 ], k[ 1 ] ).b * u1 + in( i[ 2 ], j[ 2 ], k[ 1 ] ).b * u2 + in( i[ 3 ], j[ 2 ], k[ 1 ] ).b * u3 ) * v2
1464 + ( in( i[ 0 ], j[ 3 ], k[ 1 ] ).b * u0 + in( i[ 1 ], j[ 3 ], k[ 1 ] ).b * u1 + in( i[ 2 ], j[ 3 ], k[ 1 ] ).b * u2 + in( i[ 3 ], j[ 3 ], k[ 1 ] ).b * u3 ) * v3 );
1465 double b2 = ( ( in( i[ 0 ], j[ 0 ], k[ 2 ] ).b * u0 + in( i[ 1 ], j[ 0 ], k[ 2 ] ).b * u1 + in( i[ 2 ], j[ 0 ], k[ 2 ] ).b * u2 + in( i[ 3 ], j[ 0 ], k[ 2 ] ).b * u3 ) * v0
1466 + ( in( i[ 0 ], j[ 1 ], k[ 2 ] ).b * u0 + in( i[ 1 ], j[ 1 ], k[ 2 ] ).b * u1 + in( i[ 2 ], j[ 1 ], k[ 2 ] ).b * u2 + in( i[ 3 ], j[ 1 ], k[ 2 ] ).b * u3 ) * v1
1467 + ( in( i[ 0 ], j[ 2 ], k[ 2 ] ).b * u0 + in( i[ 1 ], j[ 2 ], k[ 2 ] ).b * u1 + in( i[ 2 ], j[ 2 ], k[ 2 ] ).b * u2 + in( i[ 3 ], j[ 2 ], k[ 2 ] ).b * u3 ) * v2
1468 + ( in( i[ 0 ], j[ 3 ], k[ 2 ] ).b * u0 + in( i[ 1 ], j[ 3 ], k[ 2 ] ).b * u1 + in( i[ 2 ], j[ 3 ], k[ 2 ] ).b * u2 + in( i[ 3 ], j[ 3 ], k[ 2 ] ).b * u3 ) * v3 );
1469 double b3 = ( ( in( i[ 0 ], j[ 0 ], k[ 3 ] ).b * u0 + in( i[ 1 ], j[ 0 ], k[ 3 ] ).b * u1 + in( i[ 2 ], j[ 0 ], k[ 3 ] ).b * u2 + in( i[ 3 ], j[ 0 ], k[ 3 ] ).b * u3 ) * v0
1470 + ( in( i[ 0 ], j[ 1 ], k[ 3 ] ).b * u0 + in( i[ 1 ], j[ 1 ], k[ 3 ] ).b * u1 + in( i[ 2 ], j[ 1 ], k[ 3 ] ).b * u2 + in( i[ 3 ], j[ 1 ], k[ 3 ] ).b * u3 ) * v1
1471 + ( in( i[ 0 ], j[ 2 ], k[ 3 ] ).b * u0 + in( i[ 1 ], j[ 2 ], k[ 3 ] ).b * u1 + in( i[ 2 ], j[ 2 ], k[ 3 ] ).b * u2 + in( i[ 3 ], j[ 2 ], k[ 3 ] ).b * u3 ) * v2
1472 + ( in( i[ 0 ], j[ 3 ], k[ 3 ] ).b * u0 + in( i[ 1 ], j[ 3 ], k[ 3 ] ).b * u1 + in( i[ 2 ], j[ 3 ], k[ 3 ] ).b * u2 + in( i[ 3 ], j[ 3 ], k[ 3 ] ).b * u3 ) * v3 );
1474 double r = r0 * w0 + r1 * w1 + r2 * w2 + r3 * w3;
1475 double g = g0 * w0 + g1 * w1 + g2 * w2 + g3 * w3;
1476 double b = b0 * w0 + b1 * w1 + b2 * w2 + b3 * w3;
1478 double min = type_limits< value_type >::minimum( );
1479 double max = type_limits< value_type >::maximum( );
1481 r = r > min ? r : min;
1482 r = r < max ? r : max;
1483 g = g > min ? g : min;
1484 g = g < max ? g : max;
1485 b = b > min ? b : min;
1486 b = b < max ? b : max;
1488 return( ovalue_type( r, g, b ) );
1492 template <
class Array1,
class Array2 >
1493 void interpolate(
const Array1 &in, Array2 &out,
1494 typename Array1::size_type thread_idx,
typename Array1::size_type thread_numx,
1495 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
1496 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz )
1498 typedef typename Array1::size_type size_type;
1499 typedef typename Array1::value_type value_type;
1500 typedef typename Array2::value_type out_value_type;
1502 size_type i, j, k, ii[ 4 ], jj[ 4 ], kk[ 4 ];
1503 size_type iw = in.width( );
1504 size_type ih = in.height( );
1505 size_type
id = in.depth( );
1506 size_type ow = out.width( );
1507 size_type oh = out.height( );
1508 size_type od = out.depth( );
1510 double sx =
static_cast< double >( iw ) / static_cast< double >( ow );
1511 double sy =
static_cast< double >( ih ) / static_cast< double >( oh );
1512 double sz =
static_cast< double >( id ) / static_cast< double >( od );
1515 for( k = thread_idz ; k < od ; k += thread_numz )
1518 kk[ 1 ] =
static_cast< size_type
>( z );
1519 kk[ 0 ] = kk[ 1 ] > 0 ? kk[ 1 ] - 1 : kk[ 1 ];
1520 kk[ 2 ] = kk[ 1 ] <
id - 1 ? kk[ 1 ] + 1 : kk[ 1 ];
1521 kk[ 3 ] = kk[ 2 ] <
id - 1 ? kk[ 2 ] + 1 : kk[ 2 ];
1524 for( j = thread_idy ; j < oh ; j += thread_numy )
1527 jj[ 1 ] =
static_cast< size_type
>( y );
1528 jj[ 0 ] = jj[ 1 ] > 0 ? jj[ 1 ] - 1 : jj[ 1 ];
1529 jj[ 2 ] = jj[ 1 ] < ih - 1 ? jj[ 1 ] + 1 : jj[ 1 ];
1530 jj[ 3 ] = jj[ 2 ] < ih - 1 ? jj[ 2 ] + 1 : jj[ 2 ];
1533 for( i = thread_idx ; i < ow ; i += thread_numx )
1536 ii[ 1 ] =
static_cast< size_type
>( x );
1537 ii[ 0 ] = ii[ 1 ] > 0 ? ii[ 1 ] - 1 : ii[ 1 ];
1538 ii[ 2 ] = ii[ 1 ] < iw - 1 ? ii[ 1 ] + 1 : ii[ 1 ];
1539 ii[ 3 ] = ii[ 2 ] < iw - 1 ? ii[ 2 ] + 1 : ii[ 2 ];
1542 __interpolate_utility__::round( _cubic_< is_color< value_type >::value >::interpolate( in, ii, jj, kk, x, y, z ), out( i, j, k ) );
1555 namespace __bspline__
1558 inline double bspline1(
double t ){
return( 2.0 / 3.0 + ( 0.5 * t - 1.0 ) * t * t ); }
1561 inline double bspline2(
double t ){
return( 4.0 / 3.0 + ( -2.0 + ( 1.0 - t / 6.0 ) * t ) * t ); }
1567 template <
class T,
class Allocator >
1568 static double interpolate(
const array< T, Allocator > &in,
1569 typename array< T, Allocator >::size_type i[4],
1570 typename array< T, Allocator >::size_type [4],
1571 typename array< T, Allocator >::size_type [4],
1572 double x,
double ,
double )
1574 typedef typename array< T, Allocator >::value_type value_type;
1576 double u0 = bspline2( 1 + x );
1577 double u1 = bspline1( x );
1578 double u2 = bspline1( 1 - x );
1579 double u3 = bspline2( 2 - x );
1580 double pix = in[ i[ 0 ] ] * u0 + in[ i[ 1 ] ] * u1 + in[ i[ 2 ] ] * u2 + in[ i[ 3 ] ] * u3;
1582 double min = type_limits< value_type >::minimum( );
1583 double max = type_limits< value_type >::maximum( );
1584 pix = pix > min ? pix : min;
1585 pix = pix < max ? pix : max;
1590 template <
class T,
class Allocator >
1591 static double interpolate(
const array2< T, Allocator > &in,
1592 typename array2< T, Allocator >::size_type i[4],
1593 typename array2< T, Allocator >::size_type j[4],
1594 typename array2< T, Allocator >::size_type [4],
1595 double x,
double y,
double )
1597 typedef typename array2< T, Allocator >::value_type value_type;
1599 double u0 = bspline2( 1 + x );
1600 double u1 = bspline1( x );
1601 double u2 = bspline1( 1 - x );
1602 double u3 = bspline2( 2 - x );
1603 double v0 = bspline2( 1 + y );
1604 double v1 = bspline1( y );
1605 double v2 = bspline1( 1 - y );
1606 double v3 = bspline2( 2 - y );
1607 double pix = ( in( i[ 0 ], j[ 0 ] ) * u0 + in( i[ 1 ], j[ 0 ] ) * u1 + in( i[ 2 ], j[ 0 ] ) * u2 + in( i[ 3 ], j[ 0 ] ) * u3 ) * v0
1608 + ( in( i[ 0 ], j[ 1 ] ) * u0 + in( i[ 1 ], j[ 1 ] ) * u1 + in( i[ 2 ], j[ 1 ] ) * u2 + in( i[ 3 ], j[ 1 ] ) * u3 ) * v1
1609 + ( in( i[ 0 ], j[ 2 ] ) * u0 + in( i[ 1 ], j[ 2 ] ) * u1 + in( i[ 2 ], j[ 2 ] ) * u2 + in( i[ 3 ], j[ 2 ] ) * u3 ) * v2
1610 + ( in( i[ 0 ], j[ 3 ] ) * u0 + in( i[ 1 ], j[ 3 ] ) * u1 + in( i[ 2 ], j[ 3 ] ) * u2 + in( i[ 3 ], j[ 3 ] ) * u3 ) * v3;
1612 double min = type_limits< value_type >::minimum( );
1613 double max = type_limits< value_type >::maximum( );
1614 pix = pix > min ? pix : min;
1615 pix = pix < max ? pix : max;
1620 template <
class T,
class Allocator >
1621 static double interpolate(
const array3< T, Allocator > &in,
1622 typename array3< T, Allocator >::size_type i[4],
1623 typename array3< T, Allocator >::size_type j[4],
1624 typename array3< T, Allocator >::size_type k[4],
1625 double x,
double y,
double z )
1627 typedef typename array3< T, Allocator >::value_type value_type;
1629 double u0 = bspline2( 1 + x );
1630 double u1 = bspline1( x );
1631 double u2 = bspline1( 1 - x );
1632 double u3 = bspline2( 2 - x );
1633 double v0 = bspline2( 1 + y );
1634 double v1 = bspline1( y );
1635 double v2 = bspline1( 1 - y );
1636 double v3 = bspline2( 2 - y );
1637 double w0 = bspline2( 1 + z );
1638 double w1 = bspline1( z );
1639 double w2 = bspline1( 1 - z );
1640 double w3 = bspline2( 2 - z );
1642 double p0 = ( ( in( i[ 0 ], j[ 0 ], k[ 0 ] ) * u0 + in( i[ 1 ], j[ 0 ], k[ 0 ] ) * u1 + in( i[ 2 ], j[ 0 ], k[ 0 ] ) * u2 + in( i[ 3 ], j[ 0 ], k[ 0 ] ) * u3 ) * v0
1643 + ( in( i[ 0 ], j[ 1 ], k[ 0 ] ) * u0 + in( i[ 1 ], j[ 1 ], k[ 0 ] ) * u1 + in( i[ 2 ], j[ 1 ], k[ 0 ] ) * u2 + in( i[ 3 ], j[ 1 ], k[ 0 ] ) * u3 ) * v1
1644 + ( in( i[ 0 ], j[ 2 ], k[ 0 ] ) * u0 + in( i[ 1 ], j[ 2 ], k[ 0 ] ) * u1 + in( i[ 2 ], j[ 2 ], k[ 0 ] ) * u2 + in( i[ 3 ], j[ 2 ], k[ 0 ] ) * u3 ) * v2
1645 + ( in( i[ 0 ], j[ 3 ], k[ 0 ] ) * u0 + in( i[ 1 ], j[ 3 ], k[ 0 ] ) * u1 + in( i[ 2 ], j[ 3 ], k[ 0 ] ) * u2 + in( i[ 3 ], j[ 3 ], k[ 0 ] ) * u3 ) * v3 );
1646 double p1 = ( ( in( i[ 0 ], j[ 0 ], k[ 1 ] ) * u0 + in( i[ 1 ], j[ 0 ], k[ 1 ] ) * u1 + in( i[ 2 ], j[ 0 ], k[ 1 ] ) * u2 + in( i[ 3 ], j[ 0 ], k[ 1 ] ) * u3 ) * v0
1647 + ( in( i[ 0 ], j[ 1 ], k[ 1 ] ) * u0 + in( i[ 1 ], j[ 1 ], k[ 1 ] ) * u1 + in( i[ 2 ], j[ 1 ], k[ 1 ] ) * u2 + in( i[ 3 ], j[ 1 ], k[ 1 ] ) * u3 ) * v1
1648 + ( in( i[ 0 ], j[ 2 ], k[ 1 ] ) * u0 + in( i[ 1 ], j[ 2 ], k[ 1 ] ) * u1 + in( i[ 2 ], j[ 2 ], k[ 1 ] ) * u2 + in( i[ 3 ], j[ 2 ], k[ 1 ] ) * u3 ) * v2
1649 + ( in( i[ 0 ], j[ 3 ], k[ 1 ] ) * u0 + in( i[ 1 ], j[ 3 ], k[ 1 ] ) * u1 + in( i[ 2 ], j[ 3 ], k[ 1 ] ) * u2 + in( i[ 3 ], j[ 3 ], k[ 1 ] ) * u3 ) * v3 );
1650 double p2 = ( ( in( i[ 0 ], j[ 0 ], k[ 2 ] ) * u0 + in( i[ 1 ], j[ 0 ], k[ 2 ] ) * u1 + in( i[ 2 ], j[ 0 ], k[ 2 ] ) * u2 + in( i[ 3 ], j[ 0 ], k[ 2 ] ) * u3 ) * v0
1651 + ( in( i[ 0 ], j[ 1 ], k[ 2 ] ) * u0 + in( i[ 1 ], j[ 1 ], k[ 2 ] ) * u1 + in( i[ 2 ], j[ 1 ], k[ 2 ] ) * u2 + in( i[ 3 ], j[ 1 ], k[ 2 ] ) * u3 ) * v1
1652 + ( in( i[ 0 ], j[ 2 ], k[ 2 ] ) * u0 + in( i[ 1 ], j[ 2 ], k[ 2 ] ) * u1 + in( i[ 2 ], j[ 2 ], k[ 2 ] ) * u2 + in( i[ 3 ], j[ 2 ], k[ 2 ] ) * u3 ) * v2
1653 + ( in( i[ 0 ], j[ 3 ], k[ 2 ] ) * u0 + in( i[ 1 ], j[ 3 ], k[ 2 ] ) * u1 + in( i[ 2 ], j[ 3 ], k[ 2 ] ) * u2 + in( i[ 3 ], j[ 3 ], k[ 2 ] ) * u3 ) * v3 );
1654 double p3 = ( ( in( i[ 0 ], j[ 0 ], k[ 3 ] ) * u0 + in( i[ 1 ], j[ 0 ], k[ 3 ] ) * u1 + in( i[ 2 ], j[ 0 ], k[ 3 ] ) * u2 + in( i[ 3 ], j[ 0 ], k[ 3 ] ) * u3 ) * v0
1655 + ( in( i[ 0 ], j[ 1 ], k[ 3 ] ) * u0 + in( i[ 1 ], j[ 1 ], k[ 3 ] ) * u1 + in( i[ 2 ], j[ 1 ], k[ 3 ] ) * u2 + in( i[ 3 ], j[ 1 ], k[ 3 ] ) * u3 ) * v1
1656 + ( in( i[ 0 ], j[ 2 ], k[ 3 ] ) * u0 + in( i[ 1 ], j[ 2 ], k[ 3 ] ) * u1 + in( i[ 2 ], j[ 2 ], k[ 3 ] ) * u2 + in( i[ 3 ], j[ 2 ], k[ 3 ] ) * u3 ) * v2
1657 + ( in( i[ 0 ], j[ 3 ], k[ 3 ] ) * u0 + in( i[ 1 ], j[ 3 ], k[ 3 ] ) * u1 + in( i[ 2 ], j[ 3 ], k[ 3 ] ) * u2 + in( i[ 3 ], j[ 3 ], k[ 3 ] ) * u3 ) * v3 );
1658 double pix = p0 * w0 + p1 * w1 + p2 * w2 + p3 * w3;
1660 double min = type_limits< value_type >::minimum( );
1661 double max = type_limits< value_type >::maximum( );
1662 pix = pix > min ? pix : min;
1663 pix = pix < max ? pix : max;
1670 struct _bspline_< true >
1672 template <
class T,
class Allocator >
1673 static const typename T::template rebind< double >::other interpolate(
const array< T, Allocator > &in,
1674 typename array< T, Allocator >::size_type i[4],
1675 typename array< T, Allocator >::size_type [4],
1676 typename array< T, Allocator >::size_type [4],
1677 double x,
double ,
double )
1679 typedef typename array< T, Allocator >::value_type color;
1680 typedef typename color::value_type value_type;
1681 typedef typename T::template rebind< double >::other ovalue_type;
1683 double u0 = bspline2( 1 + x );
1684 double u1 = bspline1( x );
1685 double u2 = bspline1( 1 - x );
1686 double u3 = bspline2( 2 - x );
1687 double r = in[ i[ 0 ] ].r * u0 + in[ i[ 1 ] ].r * u1 + in[ i[ 2 ] ].r * u2 + in[ i[ 3 ] ].r * u3;
1688 double g = in[ i[ 0 ] ].g * u0 + in[ i[ 1 ] ].g * u1 + in[ i[ 2 ] ].g * u2 + in[ i[ 3 ] ].g * u3;
1689 double b = in[ i[ 0 ] ].b * u0 + in[ i[ 1 ] ].b * u1 + in[ i[ 2 ] ].b * u2 + in[ i[ 3 ] ].b * u3;
1691 double min = type_limits< value_type >::minimum( );
1692 double max = type_limits< value_type >::maximum( );
1694 r = r > min ? r : min;
1695 r = r < max ? r : max;
1696 g = g > min ? g : min;
1697 g = g < max ? g : max;
1698 b = b > min ? b : min;
1699 b = b < max ? b : max;
1701 return( ovalue_type( r, g, b ) );
1704 template <
class T,
class Allocator >
1705 static const typename T::template rebind< double >::other interpolate(
const array2< T, Allocator > &in,
1706 typename array2< T, Allocator >::size_type i[4],
1707 typename array2< T, Allocator >::size_type j[4],
1708 typename array2< T, Allocator >::size_type [4],
1709 double x,
double y,
double )
1711 typedef typename array2< T, Allocator >::value_type color;
1712 typedef typename color::value_type value_type;
1713 typedef typename T::template rebind< double >::other ovalue_type;
1715 double u0 = bspline2( 1 + x );
1716 double u1 = bspline1( x );
1717 double u2 = bspline1( 1 - x );
1718 double u3 = bspline2( 2 - x );
1719 double v0 = bspline2( 1 + y );
1720 double v1 = bspline1( y );
1721 double v2 = bspline1( 1 - y );
1722 double v3 = bspline2( 2 - y );
1724 double r = ( in( i[ 0 ], j[ 0 ] ).r * u0 + in( i[ 1 ], j[ 0 ] ).r * u1 + in( i[ 2 ], j[ 0 ] ).r * u2 + in( i[ 3 ], j[ 0 ] ).r * u3 ) * v0
1725 + ( in( i[ 0 ], j[ 1 ] ).r * u0 + in( i[ 1 ], j[ 1 ] ).r * u1 + in( i[ 2 ], j[ 1 ] ).r * u2 + in( i[ 3 ], j[ 1 ] ).r * u3 ) * v1
1726 + ( in( i[ 0 ], j[ 2 ] ).r * u0 + in( i[ 1 ], j[ 2 ] ).r * u1 + in( i[ 2 ], j[ 2 ] ).r * u2 + in( i[ 3 ], j[ 2 ] ).r * u3 ) * v2
1727 + ( in( i[ 0 ], j[ 3 ] ).r * u0 + in( i[ 1 ], j[ 3 ] ).r * u1 + in( i[ 2 ], j[ 3 ] ).r * u2 + in( i[ 3 ], j[ 3 ] ).r * u3 ) * v3;
1728 double g = ( in( i[ 0 ], j[ 0 ] ).g * u0 + in( i[ 1 ], j[ 0 ] ).g * u1 + in( i[ 2 ], j[ 0 ] ).g * u2 + in( i[ 3 ], j[ 0 ] ).g * u3 ) * v0
1729 + ( in( i[ 0 ], j[ 1 ] ).g * u0 + in( i[ 1 ], j[ 1 ] ).g * u1 + in( i[ 2 ], j[ 1 ] ).g * u2 + in( i[ 3 ], j[ 1 ] ).g * u3 ) * v1
1730 + ( in( i[ 0 ], j[ 2 ] ).g * u0 + in( i[ 1 ], j[ 2 ] ).g * u1 + in( i[ 2 ], j[ 2 ] ).g * u2 + in( i[ 3 ], j[ 2 ] ).g * u3 ) * v2
1731 + ( in( i[ 0 ], j[ 3 ] ).g * u0 + in( i[ 1 ], j[ 3 ] ).g * u1 + in( i[ 2 ], j[ 3 ] ).g * u2 + in( i[ 3 ], j[ 3 ] ).g * u3 ) * v3;
1732 double b = ( in( i[ 0 ], j[ 0 ] ).b * u0 + in( i[ 1 ], j[ 0 ] ).b * u1 + in( i[ 2 ], j[ 0 ] ).b * u2 + in( i[ 3 ], j[ 0 ] ).b * u3 ) * v0
1733 + ( in( i[ 0 ], j[ 1 ] ).b * u0 + in( i[ 1 ], j[ 1 ] ).b * u1 + in( i[ 2 ], j[ 1 ] ).b * u2 + in( i[ 3 ], j[ 1 ] ).b * u3 ) * v1
1734 + ( in( i[ 0 ], j[ 2 ] ).b * u0 + in( i[ 1 ], j[ 2 ] ).b * u1 + in( i[ 2 ], j[ 2 ] ).b * u2 + in( i[ 3 ], j[ 2 ] ).b * u3 ) * v2
1735 + ( in( i[ 0 ], j[ 3 ] ).b * u0 + in( i[ 1 ], j[ 3 ] ).b * u1 + in( i[ 2 ], j[ 3 ] ).b * u2 + in( i[ 3 ], j[ 3 ] ).b * u3 ) * v3;
1737 double min = type_limits< value_type >::minimum( );
1738 double max = type_limits< value_type >::maximum( );
1740 r = r > min ? r : min;
1741 r = r < max ? r : max;
1742 g = g > min ? g : min;
1743 g = g < max ? g : max;
1744 b = b > min ? b : min;
1745 b = b < max ? b : max;
1747 return( ovalue_type( r, g, b ) );
1750 template <
class T,
class Allocator >
1751 static const typename T::template rebind< double >::other interpolate(
const array3< T, Allocator > &in,
1752 typename array3< T, Allocator >::size_type i[4],
1753 typename array3< T, Allocator >::size_type j[4],
1754 typename array3< T, Allocator >::size_type k[4],
1755 double x,
double y,
double z )
1757 typedef typename array3< T, Allocator >::value_type color;
1758 typedef typename color::value_type value_type;
1759 typedef typename T::template rebind< double >::other ovalue_type;
1761 double u0 = bspline2( 1 + x );
1762 double u1 = bspline1( x );
1763 double u2 = bspline1( 1 - x );
1764 double u3 = bspline2( 2 - x );
1765 double v0 = bspline2( 1 + y );
1766 double v1 = bspline1( y );
1767 double v2 = bspline1( 1 - y );
1768 double v3 = bspline2( 2 - y );
1769 double w0 = bspline2( 1 + z );
1770 double w1 = bspline1( z );
1771 double w2 = bspline1( 1 - z );
1772 double w3 = bspline2( 2 - z );
1774 double r0 = ( ( in( i[ 0 ], j[ 0 ], k[ 0 ] ).r * u0 + in( i[ 1 ], j[ 0 ], k[ 0 ] ).r * u1 + in( i[ 2 ], j[ 0 ], k[ 0 ] ).r * u2 + in( i[ 3 ], j[ 0 ], k[ 0 ] ).r * u3 ) * v0
1775 + ( in( i[ 0 ], j[ 1 ], k[ 0 ] ).r * u0 + in( i[ 1 ], j[ 1 ], k[ 0 ] ).r * u1 + in( i[ 2 ], j[ 1 ], k[ 0 ] ).r * u2 + in( i[ 3 ], j[ 1 ], k[ 0 ] ).r * u3 ) * v1
1776 + ( in( i[ 0 ], j[ 2 ], k[ 0 ] ).r * u0 + in( i[ 1 ], j[ 2 ], k[ 0 ] ).r * u1 + in( i[ 2 ], j[ 2 ], k[ 0 ] ).r * u2 + in( i[ 3 ], j[ 2 ], k[ 0 ] ).r * u3 ) * v2
1777 + ( in( i[ 0 ], j[ 3 ], k[ 0 ] ).r * u0 + in( i[ 1 ], j[ 3 ], k[ 0 ] ).r * u1 + in( i[ 2 ], j[ 3 ], k[ 0 ] ).r * u2 + in( i[ 3 ], j[ 3 ], k[ 0 ] ).r * u3 ) * v3 );
1778 double r1 = ( ( in( i[ 0 ], j[ 0 ], k[ 1 ] ).r * u0 + in( i[ 1 ], j[ 0 ], k[ 1 ] ).r * u1 + in( i[ 2 ], j[ 0 ], k[ 1 ] ).r * u2 + in( i[ 3 ], j[ 0 ], k[ 1 ] ).r * u3 ) * v0
1779 + ( in( i[ 0 ], j[ 1 ], k[ 1 ] ).r * u0 + in( i[ 1 ], j[ 1 ], k[ 1 ] ).r * u1 + in( i[ 2 ], j[ 1 ], k[ 1 ] ).r * u2 + in( i[ 3 ], j[ 1 ], k[ 1 ] ).r * u3 ) * v1
1780 + ( in( i[ 0 ], j[ 2 ], k[ 1 ] ).r * u0 + in( i[ 1 ], j[ 2 ], k[ 1 ] ).r * u1 + in( i[ 2 ], j[ 2 ], k[ 1 ] ).r * u2 + in( i[ 3 ], j[ 2 ], k[ 1 ] ).r * u3 ) * v2
1781 + ( in( i[ 0 ], j[ 3 ], k[ 1 ] ).r * u0 + in( i[ 1 ], j[ 3 ], k[ 1 ] ).r * u1 + in( i[ 2 ], j[ 3 ], k[ 1 ] ).r * u2 + in( i[ 3 ], j[ 3 ], k[ 1 ] ).r * u3 ) * v3 );
1782 double r2 = ( ( in( i[ 0 ], j[ 0 ], k[ 2 ] ).r * u0 + in( i[ 1 ], j[ 0 ], k[ 2 ] ).r * u1 + in( i[ 2 ], j[ 0 ], k[ 2 ] ).r * u2 + in( i[ 3 ], j[ 0 ], k[ 2 ] ).r * u3 ) * v0
1783 + ( in( i[ 0 ], j[ 1 ], k[ 2 ] ).r * u0 + in( i[ 1 ], j[ 1 ], k[ 2 ] ).r * u1 + in( i[ 2 ], j[ 1 ], k[ 2 ] ).r * u2 + in( i[ 3 ], j[ 1 ], k[ 2 ] ).r * u3 ) * v1
1784 + ( in( i[ 0 ], j[ 2 ], k[ 2 ] ).r * u0 + in( i[ 1 ], j[ 2 ], k[ 2 ] ).r * u1 + in( i[ 2 ], j[ 2 ], k[ 2 ] ).r * u2 + in( i[ 3 ], j[ 2 ], k[ 2 ] ).r * u3 ) * v2
1785 + ( in( i[ 0 ], j[ 3 ], k[ 2 ] ).r * u0 + in( i[ 1 ], j[ 3 ], k[ 2 ] ).r * u1 + in( i[ 2 ], j[ 3 ], k[ 2 ] ).r * u2 + in( i[ 3 ], j[ 3 ], k[ 2 ] ).r * u3 ) * v3 );
1786 double r3 = ( ( in( i[ 0 ], j[ 0 ], k[ 3 ] ).r * u0 + in( i[ 1 ], j[ 0 ], k[ 3 ] ).r * u1 + in( i[ 2 ], j[ 0 ], k[ 3 ] ).r * u2 + in( i[ 3 ], j[ 0 ], k[ 3 ] ).r * u3 ) * v0
1787 + ( in( i[ 0 ], j[ 1 ], k[ 3 ] ).r * u0 + in( i[ 1 ], j[ 1 ], k[ 3 ] ).r * u1 + in( i[ 2 ], j[ 1 ], k[ 3 ] ).r * u2 + in( i[ 3 ], j[ 1 ], k[ 3 ] ).r * u3 ) * v1
1788 + ( in( i[ 0 ], j[ 2 ], k[ 3 ] ).r * u0 + in( i[ 1 ], j[ 2 ], k[ 3 ] ).r * u1 + in( i[ 2 ], j[ 2 ], k[ 3 ] ).r * u2 + in( i[ 3 ], j[ 2 ], k[ 3 ] ).r * u3 ) * v2
1789 + ( in( i[ 0 ], j[ 3 ], k[ 3 ] ).r * u0 + in( i[ 1 ], j[ 3 ], k[ 3 ] ).r * u1 + in( i[ 2 ], j[ 3 ], k[ 3 ] ).r * u2 + in( i[ 3 ], j[ 3 ], k[ 3 ] ).r * u3 ) * v3 );
1790 double g0 = ( ( in( i[ 0 ], j[ 0 ], k[ 0 ] ).g * u0 + in( i[ 1 ], j[ 0 ], k[ 0 ] ).g * u1 + in( i[ 2 ], j[ 0 ], k[ 0 ] ).g * u2 + in( i[ 3 ], j[ 0 ], k[ 0 ] ).g * u3 ) * v0
1791 + ( in( i[ 0 ], j[ 1 ], k[ 0 ] ).g * u0 + in( i[ 1 ], j[ 1 ], k[ 0 ] ).g * u1 + in( i[ 2 ], j[ 1 ], k[ 0 ] ).g * u2 + in( i[ 3 ], j[ 1 ], k[ 0 ] ).g * u3 ) * v1
1792 + ( in( i[ 0 ], j[ 2 ], k[ 0 ] ).g * u0 + in( i[ 1 ], j[ 2 ], k[ 0 ] ).g * u1 + in( i[ 2 ], j[ 2 ], k[ 0 ] ).g * u2 + in( i[ 3 ], j[ 2 ], k[ 0 ] ).g * u3 ) * v2
1793 + ( in( i[ 0 ], j[ 3 ], k[ 0 ] ).g * u0 + in( i[ 1 ], j[ 3 ], k[ 0 ] ).g * u1 + in( i[ 2 ], j[ 3 ], k[ 0 ] ).g * u2 + in( i[ 3 ], j[ 3 ], k[ 0 ] ).g * u3 ) * v3 );
1794 double g1 = ( ( in( i[ 0 ], j[ 0 ], k[ 1 ] ).g * u0 + in( i[ 1 ], j[ 0 ], k[ 1 ] ).g * u1 + in( i[ 2 ], j[ 0 ], k[ 1 ] ).g * u2 + in( i[ 3 ], j[ 0 ], k[ 1 ] ).g * u3 ) * v0
1795 + ( in( i[ 0 ], j[ 1 ], k[ 1 ] ).g * u0 + in( i[ 1 ], j[ 1 ], k[ 1 ] ).g * u1 + in( i[ 2 ], j[ 1 ], k[ 1 ] ).g * u2 + in( i[ 3 ], j[ 1 ], k[ 1 ] ).g * u3 ) * v1
1796 + ( in( i[ 0 ], j[ 2 ], k[ 1 ] ).g * u0 + in( i[ 1 ], j[ 2 ], k[ 1 ] ).g * u1 + in( i[ 2 ], j[ 2 ], k[ 1 ] ).g * u2 + in( i[ 3 ], j[ 2 ], k[ 1 ] ).g * u3 ) * v2
1797 + ( in( i[ 0 ], j[ 3 ], k[ 1 ] ).g * u0 + in( i[ 1 ], j[ 3 ], k[ 1 ] ).g * u1 + in( i[ 2 ], j[ 3 ], k[ 1 ] ).g * u2 + in( i[ 3 ], j[ 3 ], k[ 1 ] ).g * u3 ) * v3 );
1798 double g2 = ( ( in( i[ 0 ], j[ 0 ], k[ 2 ] ).g * u0 + in( i[ 1 ], j[ 0 ], k[ 2 ] ).g * u1 + in( i[ 2 ], j[ 0 ], k[ 2 ] ).g * u2 + in( i[ 3 ], j[ 0 ], k[ 2 ] ).g * u3 ) * v0
1799 + ( in( i[ 0 ], j[ 1 ], k[ 2 ] ).g * u0 + in( i[ 1 ], j[ 1 ], k[ 2 ] ).g * u1 + in( i[ 2 ], j[ 1 ], k[ 2 ] ).g * u2 + in( i[ 3 ], j[ 1 ], k[ 2 ] ).g * u3 ) * v1
1800 + ( in( i[ 0 ], j[ 2 ], k[ 2 ] ).g * u0 + in( i[ 1 ], j[ 2 ], k[ 2 ] ).g * u1 + in( i[ 2 ], j[ 2 ], k[ 2 ] ).g * u2 + in( i[ 3 ], j[ 2 ], k[ 2 ] ).g * u3 ) * v2
1801 + ( in( i[ 0 ], j[ 3 ], k[ 2 ] ).g * u0 + in( i[ 1 ], j[ 3 ], k[ 2 ] ).g * u1 + in( i[ 2 ], j[ 3 ], k[ 2 ] ).g * u2 + in( i[ 3 ], j[ 3 ], k[ 2 ] ).g * u3 ) * v3 );
1802 double g3 = ( ( in( i[ 0 ], j[ 0 ], k[ 3 ] ).g * u0 + in( i[ 1 ], j[ 0 ], k[ 3 ] ).g * u1 + in( i[ 2 ], j[ 0 ], k[ 3 ] ).g * u2 + in( i[ 3 ], j[ 0 ], k[ 3 ] ).g * u3 ) * v0
1803 + ( in( i[ 0 ], j[ 1 ], k[ 3 ] ).g * u0 + in( i[ 1 ], j[ 1 ], k[ 3 ] ).g * u1 + in( i[ 2 ], j[ 1 ], k[ 3 ] ).g * u2 + in( i[ 3 ], j[ 1 ], k[ 3 ] ).g * u3 ) * v1
1804 + ( in( i[ 0 ], j[ 2 ], k[ 3 ] ).g * u0 + in( i[ 1 ], j[ 2 ], k[ 3 ] ).g * u1 + in( i[ 2 ], j[ 2 ], k[ 3 ] ).g * u2 + in( i[ 3 ], j[ 2 ], k[ 3 ] ).g * u3 ) * v2
1805 + ( in( i[ 0 ], j[ 3 ], k[ 3 ] ).g * u0 + in( i[ 1 ], j[ 3 ], k[ 3 ] ).g * u1 + in( i[ 2 ], j[ 3 ], k[ 3 ] ).g * u2 + in( i[ 3 ], j[ 3 ], k[ 3 ] ).g * u3 ) * v3 );
1806 double b0 = ( ( in( i[ 0 ], j[ 0 ], k[ 0 ] ).b * u0 + in( i[ 1 ], j[ 0 ], k[ 0 ] ).b * u1 + in( i[ 2 ], j[ 0 ], k[ 0 ] ).b * u2 + in( i[ 3 ], j[ 0 ], k[ 0 ] ).b * u3 ) * v0
1807 + ( in( i[ 0 ], j[ 1 ], k[ 0 ] ).b * u0 + in( i[ 1 ], j[ 1 ], k[ 0 ] ).b * u1 + in( i[ 2 ], j[ 1 ], k[ 0 ] ).b * u2 + in( i[ 3 ], j[ 1 ], k[ 0 ] ).b * u3 ) * v1
1808 + ( in( i[ 0 ], j[ 2 ], k[ 0 ] ).b * u0 + in( i[ 1 ], j[ 2 ], k[ 0 ] ).b * u1 + in( i[ 2 ], j[ 2 ], k[ 0 ] ).b * u2 + in( i[ 3 ], j[ 2 ], k[ 0 ] ).b * u3 ) * v2
1809 + ( in( i[ 0 ], j[ 3 ], k[ 0 ] ).b * u0 + in( i[ 1 ], j[ 3 ], k[ 0 ] ).b * u1 + in( i[ 2 ], j[ 3 ], k[ 0 ] ).b * u2 + in( i[ 3 ], j[ 3 ], k[ 0 ] ).b * u3 ) * v3 );
1810 double b1 = ( ( in( i[ 0 ], j[ 0 ], k[ 1 ] ).b * u0 + in( i[ 1 ], j[ 0 ], k[ 1 ] ).b * u1 + in( i[ 2 ], j[ 0 ], k[ 1 ] ).b * u2 + in( i[ 3 ], j[ 0 ], k[ 1 ] ).b * u3 ) * v0
1811 + ( in( i[ 0 ], j[ 1 ], k[ 1 ] ).b * u0 + in( i[ 1 ], j[ 1 ], k[ 1 ] ).b * u1 + in( i[ 2 ], j[ 1 ], k[ 1 ] ).b * u2 + in( i[ 3 ], j[ 1 ], k[ 1 ] ).b * u3 ) * v1
1812 + ( in( i[ 0 ], j[ 2 ], k[ 1 ] ).b * u0 + in( i[ 1 ], j[ 2 ], k[ 1 ] ).b * u1 + in( i[ 2 ], j[ 2 ], k[ 1 ] ).b * u2 + in( i[ 3 ], j[ 2 ], k[ 1 ] ).b * u3 ) * v2
1813 + ( in( i[ 0 ], j[ 3 ], k[ 1 ] ).b * u0 + in( i[ 1 ], j[ 3 ], k[ 1 ] ).b * u1 + in( i[ 2 ], j[ 3 ], k[ 1 ] ).b * u2 + in( i[ 3 ], j[ 3 ], k[ 1 ] ).b * u3 ) * v3 );
1814 double b2 = ( ( in( i[ 0 ], j[ 0 ], k[ 2 ] ).b * u0 + in( i[ 1 ], j[ 0 ], k[ 2 ] ).b * u1 + in( i[ 2 ], j[ 0 ], k[ 2 ] ).b * u2 + in( i[ 3 ], j[ 0 ], k[ 2 ] ).b * u3 ) * v0
1815 + ( in( i[ 0 ], j[ 1 ], k[ 2 ] ).b * u0 + in( i[ 1 ], j[ 1 ], k[ 2 ] ).b * u1 + in( i[ 2 ], j[ 1 ], k[ 2 ] ).b * u2 + in( i[ 3 ], j[ 1 ], k[ 2 ] ).b * u3 ) * v1
1816 + ( in( i[ 0 ], j[ 2 ], k[ 2 ] ).b * u0 + in( i[ 1 ], j[ 2 ], k[ 2 ] ).b * u1 + in( i[ 2 ], j[ 2 ], k[ 2 ] ).b * u2 + in( i[ 3 ], j[ 2 ], k[ 2 ] ).b * u3 ) * v2
1817 + ( in( i[ 0 ], j[ 3 ], k[ 2 ] ).b * u0 + in( i[ 1 ], j[ 3 ], k[ 2 ] ).b * u1 + in( i[ 2 ], j[ 3 ], k[ 2 ] ).b * u2 + in( i[ 3 ], j[ 3 ], k[ 2 ] ).b * u3 ) * v3 );
1818 double b3 = ( ( in( i[ 0 ], j[ 0 ], k[ 3 ] ).b * u0 + in( i[ 1 ], j[ 0 ], k[ 3 ] ).b * u1 + in( i[ 2 ], j[ 0 ], k[ 3 ] ).b * u2 + in( i[ 3 ], j[ 0 ], k[ 3 ] ).b * u3 ) * v0
1819 + ( in( i[ 0 ], j[ 1 ], k[ 3 ] ).b * u0 + in( i[ 1 ], j[ 1 ], k[ 3 ] ).b * u1 + in( i[ 2 ], j[ 1 ], k[ 3 ] ).b * u2 + in( i[ 3 ], j[ 1 ], k[ 3 ] ).b * u3 ) * v1
1820 + ( in( i[ 0 ], j[ 2 ], k[ 3 ] ).b * u0 + in( i[ 1 ], j[ 2 ], k[ 3 ] ).b * u1 + in( i[ 2 ], j[ 2 ], k[ 3 ] ).b * u2 + in( i[ 3 ], j[ 2 ], k[ 3 ] ).b * u3 ) * v2
1821 + ( in( i[ 0 ], j[ 3 ], k[ 3 ] ).b * u0 + in( i[ 1 ], j[ 3 ], k[ 3 ] ).b * u1 + in( i[ 2 ], j[ 3 ], k[ 3 ] ).b * u2 + in( i[ 3 ], j[ 3 ], k[ 3 ] ).b * u3 ) * v3 );
1823 double r = r0 * w0 + r1 * w1 + r2 * w2 + r3 * w3;
1824 double g = g0 * w0 + g1 * w1 + g2 * w2 + g3 * w3;
1825 double b = b0 * w0 + b1 * w1 + b2 * w2 + b3 * w3;
1827 double min = type_limits< value_type >::minimum( );
1828 double max = type_limits< value_type >::maximum( );
1830 r = r > min ? r : min;
1831 r = r < max ? r : max;
1832 g = g > min ? g : min;
1833 g = g < max ? g : max;
1834 b = b > min ? b : min;
1835 b = b < max ? b : max;
1837 return( ovalue_type( r, g, b ) );
1841 template <
class Array1,
class Array2 >
1842 void interpolate(
const Array1 &in, Array2 &out,
1843 typename Array1::size_type thread_idx,
typename Array1::size_type thread_numx,
1844 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
1845 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz )
1847 typedef typename Array1::size_type size_type;
1848 typedef typename Array1::value_type value_type;
1849 typedef typename Array2::value_type out_value_type;
1851 size_type i, j, k, ii[ 4 ], jj[ 4 ], kk[ 4 ];
1852 size_type iw = in.width( );
1853 size_type ih = in.height( );
1854 size_type
id = in.depth( );
1855 size_type ow = out.width( );
1856 size_type oh = out.height( );
1857 size_type od = out.depth( );
1859 double sx =
static_cast< double >( iw ) / static_cast< double >( ow );
1860 double sy =
static_cast< double >( ih ) / static_cast< double >( oh );
1861 double sz =
static_cast< double >( id ) / static_cast< double >( od );
1864 for( k = thread_idz ; k < od ; k += thread_numz )
1867 kk[ 1 ] =
static_cast< size_type
>( z );
1868 kk[ 0 ] = kk[ 1 ] > 0 ? kk[ 1 ] - 1 : kk[ 1 ];
1869 kk[ 2 ] = kk[ 1 ] <
id - 1 ? kk[ 1 ] + 1 : kk[ 1 ];
1870 kk[ 3 ] = kk[ 2 ] <
id - 1 ? kk[ 2 ] + 1 : kk[ 2 ];
1873 for( j = thread_idy ; j < oh ; j += thread_numy )
1876 jj[ 1 ] =
static_cast< size_type
>( y );
1877 jj[ 0 ] = jj[ 1 ] > 0 ? jj[ 1 ] - 1 : jj[ 1 ];
1878 jj[ 2 ] = jj[ 1 ] < ih - 1 ? jj[ 1 ] + 1 : jj[ 1 ];
1879 jj[ 3 ] = jj[ 2 ] < ih - 1 ? jj[ 2 ] + 1 : jj[ 2 ];
1882 for( i = thread_idx ; i < ow ; i += thread_numx )
1885 ii[ 1 ] =
static_cast< size_type
>( x );
1886 ii[ 0 ] = ii[ 1 ] > 0 ? ii[ 1 ] - 1 : ii[ 1 ];
1887 ii[ 2 ] = ii[ 1 ] < iw - 1 ? ii[ 1 ] + 1 : ii[ 1 ];
1888 ii[ 3 ] = ii[ 2 ] < iw - 1 ? ii[ 2 ] + 1 : ii[ 2 ];
1891 __interpolate_utility__::round( _bspline_< is_color< value_type >::value >::interpolate( in, ii, jj, kk, x, y, z ), out( i, j, k ) );
1904 inline double sinc(
double t )
1906 return( t == 0.0 ? 1.0 : std::sin( 3.1415926535897932384626433832795 * t ) / ( 3.1415926535897932384626433832795 * t ) );
1912 template <
class T,
class Allocator >
1913 static double interpolate(
const array< T, Allocator > &in,
1914 typename array< T, Allocator >::difference_type ix,
1915 typename array< T, Allocator >::difference_type iy,
1916 typename array< T, Allocator >::difference_type iz,
1917 double x,
double y,
double z )
1919 typedef typename array< T, Allocator >::difference_type difference_type;
1920 typedef typename array< T, Allocator >::value_type value_type;
1923 difference_type i, num = in.size( );
1924 for( i = 0 ; i <= ix ; i++ )
1926 pix += in[ i ] * sinc( ix - i - x );
1928 for( ; i < num ; i++ )
1930 pix += in[ i ] * sinc( i - ix + x );
1933 double min = type_limits< value_type >::minimum( );
1934 double max = type_limits< value_type >::maximum( );
1935 pix = pix > min ? pix : min;
1936 pix = pix < max ? pix : max;
1941 template <
class T,
class Allocator >
1942 static double interpolate(
const array2< T, Allocator > &in,
1943 typename array2< T, Allocator >::difference_type ix,
1944 typename array2< T, Allocator >::difference_type iy,
1945 typename array2< T, Allocator >::difference_type ,
1946 double x,
double y,
double )
1948 typedef typename array2< T, Allocator >::difference_type difference_type;
1949 typedef typename array2< T, Allocator >::value_type value_type;
1950 typedef typename array2< T, Allocator >::const_pointer const_pointer;
1953 difference_type width = in.width( );
1954 difference_type height = in.height( );
1957 for( j = 0 ; j < iy ; j++ )
1960 const_pointer p = &in( 0, j );
1962 for( i = 0 ; i <= ix ; i++ )
1964 tmpX += p[ i ] * sinc( ix - i - x );
1966 for( ; i < width ; i++ )
1968 tmpX += p[ i ] * sinc( i - ix + x );
1971 pix += tmpX * sinc( iy - j - y );
1973 for( ; j < height ; j++ )
1976 const_pointer p = &in( 0, j );
1978 for( i = 0 ; i <= ix ; i++ )
1980 tmpX += p[ i ] * sinc( ix - i - x );
1982 for( ; i < width ; i++ )
1984 tmpX += p[ i ] * sinc( i - ix + x );
1987 pix += tmpX * sinc( j - iy + y );
1990 double min = type_limits< value_type >::minimum( );
1991 double max = type_limits< value_type >::maximum( );
1992 pix = pix > min ? pix : min;
1993 pix = pix < max ? pix : max;
1998 template <
class T,
class Allocator >
1999 static double interpolate(
const array3< T, Allocator > &in,
2000 typename array3< T, Allocator >::difference_type ix,
2001 typename array3< T, Allocator >::difference_type iy,
2002 typename array3< T, Allocator >::difference_type iz,
2003 double x,
double y,
double z )
2005 typedef typename array2< T, Allocator >::difference_type difference_type;
2006 typedef typename array2< T, Allocator >::value_type value_type;
2007 typedef typename array2< T, Allocator >::const_pointer const_pointer;
2010 difference_type width = in.width( );
2011 difference_type height = in.height( );
2012 difference_type depth = in.depth( );
2015 for( k = 0 ; k < iz ; k++ )
2019 for( j = 0 ; j < iy ; j++ )
2022 const_pointer p = &in( 0, j, k );
2024 for( i = 0 ; i <= ix ; i++ )
2026 tmpX += p[ i ] * sinc( ix - i - x );
2028 for( ; i < width ; i++ )
2030 tmpX += p[ i ] * sinc( i - ix + x );
2033 tmpY += tmpX * sinc( iy - j - y );
2035 for( ; j < height ; j++ )
2038 const_pointer p = &in( 0, j, k );
2040 for( i = 0 ; i <= ix ; i++ )
2042 tmpX += p[ i ] * sinc( ix - i - x );
2044 for( ; i < width ; i++ )
2046 tmpX += p[ i ] * sinc( i - ix + x );
2049 tmpY += tmpX * sinc( j - iy + y );
2052 pix += tmpY * sinc( iz - k - z );
2054 for( ; k < depth ; k++ )
2058 for( j = 0 ; j < iy ; j++ )
2061 const_pointer p = &in( 0, j, k );
2063 for( i = 0 ; i <= ix ; i++ )
2065 tmpX += p[ i ] * sinc( ix - i - x );
2067 for( ; i < width ; i++ )
2069 tmpX += p[ i ] * sinc( i - ix + x );
2072 tmpY += tmpX * sinc( iy - j - y );
2074 for( ; j < height ; j++ )
2077 const_pointer p = &in( 0, j, k );
2079 for( i = 0 ; i <= ix ; i++ )
2081 tmpX += p[ i ] * sinc( ix - i - x );
2083 for( ; i < width ; i++ )
2085 tmpX += p[ i ] * sinc( i - ix + x );
2088 tmpY += tmpX * sinc( j - iy + y );
2091 pix += tmpY * sinc( k - iz + z );
2094 double min = type_limits< value_type >::minimum( );
2095 double max = type_limits< value_type >::maximum( );
2096 pix = pix > min ? pix : min;
2097 pix = pix < max ? pix : max;
2105 struct _sinc_< true >
2107 template <
class T,
class Allocator >
2108 static typename T::template rebind< double >::other interpolate(
const array< T, Allocator > &in,
2109 typename array< T, Allocator >::difference_type ix,
2110 typename array< T, Allocator >::difference_type iy,
2111 typename array< T, Allocator >::difference_type iz,
2112 double ,
double ,
double )
2114 return( in( ix, iy, iz ) );
2117 template <
class T,
class Allocator >
2118 static typename T::template rebind< double >::other interpolate(
const array2< T, Allocator > &in,
2119 typename array2< T, Allocator >::difference_type ix,
2120 typename array2< T, Allocator >::difference_type iy,
2121 typename array2< T, Allocator >::difference_type iz,
2122 double ,
double ,
double )
2124 return( in( ix, iy, iz ) );
2127 template <
class T,
class Allocator >
2128 static typename T::template rebind< double >::other interpolate(
const array3< T, Allocator > &in,
2129 typename array3< T, Allocator >::difference_type ix,
2130 typename array3< T, Allocator >::difference_type iy,
2131 typename array3< T, Allocator >::difference_type iz,
2132 double ,
double ,
double )
2134 return( in( ix, iy, iz ) );
2139 template <
class Array1,
class Array2 >
2140 void interpolate(
const Array1 &in, Array2 &out,
2141 typename Array1::size_type thread_idx,
typename Array1::size_type thread_numx,
2142 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
2143 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz )
2145 typedef typename Array1::size_type size_type;
2146 typedef typename Array1::difference_type difference_type;
2147 typedef typename Array1::value_type value_type;
2148 typedef typename Array2::value_type out_value_type;
2151 difference_type ii, jj, kk;
2152 size_type iw = in.width( );
2153 size_type ih = in.height( );
2154 size_type
id = in.depth( );
2155 size_type ow = out.width( );
2156 size_type oh = out.height( );
2157 size_type od = out.depth( );
2159 double sx =
static_cast< double >( iw ) / static_cast< double >( ow );
2160 double sy =
static_cast< double >( ih ) / static_cast< double >( oh );
2161 double sz =
static_cast< double >( id ) / static_cast< double >( od );
2164 for( k = thread_idz ; k < od ; k += thread_numz )
2167 kk =
static_cast< difference_type
>( z );
2170 for( j = thread_idy ; j < oh ; j += thread_numy )
2173 jj =
static_cast< difference_type
>( y );
2176 for( i = thread_idx ; i < ow ; i += thread_numx )
2179 ii =
static_cast< difference_type
>( x );
2182 __interpolate_utility__::round( _sinc_< is_color< value_type >::value >::interpolate( in, ii, jj, kk, x, y, z ), out( i, j, k ) );
2193 namespace __interpolate_controller__
2196 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2197 void nearest__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
2198 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num )
2200 __nearest__::interpolate( in, out, thread_id, thread_num, 0, 1, 0, 1 );
2203 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2204 void nearest__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
2205 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num )
2207 __nearest__::interpolate( in, out, 0, 1, thread_id, thread_num, 0, 1 );
2210 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2211 void nearest__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
2212 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num )
2214 __nearest__::interpolate( in, out, 0, 1, 0, 1, thread_id, thread_num );
2219 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2220 void mean__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
2221 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num )
2223 __mean__::interpolate( in, out, thread_id, thread_num, 0, 1, 0, 1 );
2226 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2227 void mean__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
2228 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num )
2230 __mean__::interpolate( in, out, 0, 1, thread_id, thread_num, 0, 1 );
2233 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2234 void mean__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
2235 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num )
2237 __mean__::interpolate( in, out, 0, 1, 0, 1, thread_id, thread_num );
2242 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2243 void linear__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
2244 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num )
2246 __linear__::interpolate( in, out, thread_id, thread_num, 0, 1, 0, 1 );
2249 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2250 void linear__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
2251 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num )
2253 __linear__::interpolate( in, out, 0, 1, thread_id, thread_num, 0, 1 );
2256 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2257 void linear__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
2258 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num )
2260 __linear__::interpolate( in, out, 0, 1, 0, 1, thread_id, thread_num );
2265 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2266 void cubic__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
2267 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num )
2269 __cubic__::interpolate( in, out, thread_id, thread_num, 0, 1, 0, 1 );
2272 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2273 void cubic__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
2274 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num )
2276 __cubic__::interpolate( in, out, 0, 1, thread_id, thread_num, 0, 1 );
2279 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2280 void cubic__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
2281 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num )
2283 __cubic__::interpolate( in, out, 0, 1, 0, 1, thread_id, thread_num );
2288 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2289 void bspline__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
2290 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num )
2292 __bspline__::interpolate( in, out, thread_id, thread_num, 0, 1, 0, 1 );
2295 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2296 void bspline__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
2297 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num )
2299 __bspline__::interpolate( in, out, 0, 1, thread_id, thread_num, 0, 1 );
2302 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2303 void bspline__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
2304 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num )
2306 __bspline__::interpolate( in, out, 0, 1, 0, 1, thread_id, thread_num );
2311 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2312 void sinc__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
2313 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num )
2315 __sinc__::interpolate( in, out, thread_id, thread_num, 0, 1, 0, 1 );
2318 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2319 void sinc__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
2320 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num )
2322 __sinc__::interpolate( in, out, 0, 1, thread_id, thread_num, 0, 1 );
2325 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2326 void sinc__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
2327 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num )
2329 __sinc__::interpolate( in, out, 0, 1, 0, 1, thread_id, thread_num );
2333 template <
class T1,
class T2 >
2334 class interpolate_thread :
public mist::thread< interpolate_thread< T1, T2 > >
2338 typedef typename base::thread_exit_type thread_exit_type;
2339 typedef typename T1::size_type size_type;
2340 typedef typename T1::value_type value_type;
2362 void setup_parameters(
const T1 &in, T2 &out, Mode interpolate, size_type thread_id, size_type thread_num )
2366 interpolate_ = interpolate;
2367 thread_id_ = thread_id;
2368 thread_num_ = thread_num;
2371 const interpolate_thread& operator =(
const interpolate_thread &p )
2375 base::operator =( p );
2376 thread_id_ = p.thread_id_;
2377 thread_num_ = p.thread_num_;
2380 interpolate_ = p.interpolate_;
2385 interpolate_thread( size_type
id = 0, size_type num = 1 ) : thread_id_( id ), thread_num_( num ),
2386 in_( NULL ), out_( NULL ), interpolate_( Linear )
2389 interpolate_thread(
const interpolate_thread &p ) : base( p ), thread_id_( p.thread_id_ ), thread_num_( p.thread_num_ ),
2390 in_( p.in_ ), out_( p.out_ ), interpolate_( Linear )
2396 virtual thread_exit_type thread_function( )
2398 switch( interpolate_ )
2401 nearest__( *in_, *out_, thread_id_, thread_num_ );
2405 mean__( *in_, *out_, thread_id_, thread_num_ );
2409 cubic__( *in_, *out_, thread_id_, thread_num_ );
2413 bspline__( *in_, *out_, thread_id_, thread_num_ );
2417 sinc__( *in_, *out_, thread_id_, thread_num_ );
2422 linear__( *in_, *out_, thread_id_, thread_num_ );
2462 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2472 typedef __interpolate_controller__::interpolate_thread< array< T1, Allocator1 >,
array< T2, Allocator2 > > interpolate_thread;
2474 if( thread_num == 0 )
2476 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2482 if( in.
width( ) == width )
2484 for( i = 0 ; i < in.
size( ) ; i++ )
2491 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
2493 for( i = 0 ; i < thread_num ; i++ )
2495 thread[ i ].setup_parameters( in, out, interpolate_thread::Nearest, i, thread_num );
2523 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2533 typedef __interpolate_controller__::interpolate_thread< array1< T1, Allocator1 >,
array1< T2, Allocator2 > > interpolate_thread;
2535 if( thread_num == 0 )
2537 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2542 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
size( ) ) / static_cast< double >( width ) );
2544 if( in.
width( ) == width )
2546 for( i = 0 ; i < in.
size( ) ; i++ )
2553 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
2555 for( i = 0 ; i < thread_num ; i++ )
2557 thread[ i ].setup_parameters( in, out, interpolate_thread::Nearest, i, thread_num );
2586 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2597 typedef __interpolate_controller__::interpolate_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 > > interpolate_thread;
2599 if( thread_num == 0 )
2601 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2605 out.
resize( width, height );
2606 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
2607 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
2609 if( in.
width( ) == width && in.
height( ) == height )
2611 for( i = 0 ; i < in.
size( ) ; i++ )
2618 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
2620 for( i = 0 ; i < thread_num ; i++ )
2622 thread[ i ].setup_parameters( in, out, interpolate_thread::Nearest, i, thread_num );
2652 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2659 if(
is_same_object( in, out ) || width == 0 || height == 0 || depth == 0 )
2665 typedef __interpolate_controller__::interpolate_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 > > interpolate_thread;
2667 if( thread_num == 0 )
2669 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2673 out.
resize( width, height, depth );
2674 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
2675 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
2676 out.
reso3( in.
reso3( ) *
static_cast< double >( in.
depth( ) ) / static_cast< double >( depth ) );
2678 if( in.
width( ) == width && in.
height( ) == height && in.
depth( ) == depth )
2680 for( i = 0 ; i < in.
size( ) ; i++ )
2687 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
2689 for( i = 0 ; i < thread_num ; i++ )
2691 thread[ i ].setup_parameters( in, out, interpolate_thread::Nearest, i, thread_num );
2725 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2733 else if( in.
width( ) < width )
2740 typedef __interpolate_controller__::interpolate_thread< array< T1, Allocator1 >,
array< T2, Allocator2 > > interpolate_thread;
2742 if( thread_num == 0 )
2744 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2750 if( in.
width( ) == width )
2752 for( i = 0 ; i < in.
size( ) ; i++ )
2759 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
2761 for( i = 0 ; i < thread_num ; i++ )
2763 thread[ i ].setup_parameters( in, out, interpolate_thread::Mean, i, thread_num );
2794 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2802 else if( in.
width( ) < width )
2809 typedef __interpolate_controller__::interpolate_thread< array1< T1, Allocator1 >,
array1< T2, Allocator2 > > interpolate_thread;
2811 if( thread_num == 0 )
2813 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2818 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
size( ) ) / static_cast< double >( width ) );
2820 if( in.
width( ) == width )
2822 for( i = 0 ; i < in.
size( ) ; i++ )
2829 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
2831 for( i = 0 ; i < thread_num ; i++ )
2833 thread[ i ].setup_parameters( in, out, interpolate_thread::Mean, i, thread_num );
2865 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2874 else if( in.
width( ) < width || in.
height( ) < height )
2881 typedef __interpolate_controller__::interpolate_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 > > interpolate_thread;
2883 if( thread_num == 0 )
2885 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2889 out.
resize( width, height );
2890 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
2891 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
2893 if( in.
width( ) == width && in.
height( ) == height )
2895 for( i = 0 ; i < in.
size( ) ; i++ )
2902 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
2904 for( i = 0 ; i < thread_num ; i++ )
2906 thread[ i ].setup_parameters( in, out, interpolate_thread::Mean, i, thread_num );
2939 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2950 else if( in.
width( ) < width || in.
height( ) < height || in.
depth( ) < depth )
2957 typedef __interpolate_controller__::interpolate_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 > > interpolate_thread;
2959 if( thread_num == 0 )
2961 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2965 out.
resize( width, height, depth );
2966 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
2967 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
2968 out.
reso3( in.
reso3( ) *
static_cast< double >( in.
depth( ) ) / static_cast< double >( depth ) );
2970 if( in.
width( ) == width && in.
height( ) == height && in.
depth( ) == depth )
2972 for( i = 0 ; i < in.
size( ) ; i++ )
2979 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
2981 for( i = 0 ; i < thread_num ; i++ )
2983 thread[ i ].setup_parameters( in, out, interpolate_thread::Mean, i, thread_num );
3016 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3026 typedef __interpolate_controller__::interpolate_thread< array< T1, Allocator1 >,
array< T2, Allocator2 > > interpolate_thread;
3028 if( thread_num == 0 )
3030 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3036 if( in.
width( ) == width )
3038 for( i = 0 ; i < in.
size( ) ; i++ )
3045 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3047 for( i = 0 ; i < thread_num ; i++ )
3049 thread[ i ].setup_parameters( in, out, interpolate_thread::Linear, i, thread_num );
3077 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3087 typedef __interpolate_controller__::interpolate_thread< array1< T1, Allocator1 >,
array1< T2, Allocator2 > > interpolate_thread;
3089 if( thread_num == 0 )
3091 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3096 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
size( ) ) / static_cast< double >( width ) );
3098 if( in.
width( ) == width )
3100 for( i = 0 ; i < in.
size( ) ; i++ )
3107 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3109 for( i = 0 ; i < thread_num ; i++ )
3111 thread[ i ].setup_parameters( in, out, interpolate_thread::Linear, i, thread_num );
3140 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3151 typedef __interpolate_controller__::interpolate_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 > > interpolate_thread;
3153 if( thread_num == 0 )
3155 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3159 out.
resize( width, height );
3160 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
3161 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
3163 if( in.
width( ) == width && in.
height( ) == height )
3165 for( i = 0 ; i < in.
size( ) ; i++ )
3172 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3174 for( i = 0 ; i < thread_num ; i++ )
3176 thread[ i ].setup_parameters( in, out, interpolate_thread::Linear, i, thread_num );
3206 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3213 if(
is_same_object( in, out ) || width == 0 || height == 0 || depth == 0 )
3219 typedef __interpolate_controller__::interpolate_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 > > interpolate_thread;
3221 if( thread_num == 0 )
3223 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3227 out.
resize( width, height, depth );
3228 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
3229 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
3230 out.
reso3( in.
reso3( ) *
static_cast< double >( in.
depth( ) ) / static_cast< double >( depth ) );
3232 if( in.
width( ) == width && in.
height( ) == height && in.
depth( ) == depth )
3234 for( i = 0 ; i < in.
size( ) ; i++ )
3241 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3243 for( i = 0 ; i < thread_num ; i++ )
3245 thread[ i ].setup_parameters( in, out, interpolate_thread::Linear, i, thread_num );
3278 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3288 typedef __interpolate_controller__::interpolate_thread< array< T1, Allocator1 >,
array< T2, Allocator2 > > interpolate_thread;
3290 if( thread_num == 0 )
3292 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3298 if( in.
width( ) == width )
3300 for( i = 0 ; i < in.
size( ) ; i++ )
3307 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3309 for( i = 0 ; i < thread_num ; i++ )
3311 thread[ i ].setup_parameters( in, out, interpolate_thread::Cubic, i, thread_num );
3338 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3348 typedef __interpolate_controller__::interpolate_thread< array1< T1, Allocator1 >,
array1< T2, Allocator2 > > interpolate_thread;
3350 if( thread_num == 0 )
3352 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3357 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
size( ) ) / static_cast< double >( width ) );
3359 if( in.
width( ) == width )
3361 for( i = 0 ; i < in.
size( ) ; i++ )
3368 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3370 for( i = 0 ; i < thread_num ; i++ )
3372 thread[ i ].setup_parameters( in, out, interpolate_thread::Cubic, i, thread_num );
3401 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3412 typedef __interpolate_controller__::interpolate_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 > > interpolate_thread;
3414 if( thread_num == 0 )
3416 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3420 out.
resize( width, height );
3421 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
3422 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
3424 if( in.
width( ) == width && in.
height( ) == height )
3426 for( i = 0 ; i < in.
size( ) ; i++ )
3433 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3435 for( i = 0 ; i < thread_num ; i++ )
3437 thread[ i ].setup_parameters( in, out, interpolate_thread::Cubic, i, thread_num );
3467 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3474 if(
is_same_object( in, out ) || width == 0 || height == 0 || depth == 0 )
3480 typedef __interpolate_controller__::interpolate_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 > > interpolate_thread;
3482 if( thread_num == 0 )
3484 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3488 out.
resize( width, height, depth );
3489 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
3490 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
3491 out.
reso3( in.
reso3( ) *
static_cast< double >( in.
depth( ) ) / static_cast< double >( depth ) );
3493 if( in.
width( ) == width && in.
height( ) == height && in.
depth( ) == depth )
3495 for( i = 0 ; i < in.
size( ) ; i++ )
3502 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3504 for( i = 0 ; i < thread_num ; i++ )
3506 thread[ i ].setup_parameters( in, out, interpolate_thread::Cubic, i, thread_num );
3539 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3549 typedef __interpolate_controller__::interpolate_thread< array< T1, Allocator1 >,
array< T2, Allocator2 > > interpolate_thread;
3551 if( thread_num == 0 )
3553 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3559 if( in.
width( ) == width )
3561 for( i = 0 ; i < in.
size( ) ; i++ )
3568 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3570 for( i = 0 ; i < thread_num ; i++ )
3572 thread[ i ].setup_parameters( in, out, interpolate_thread::Bspline, i, thread_num );
3599 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3609 typedef __interpolate_controller__::interpolate_thread< array1< T1, Allocator1 >,
array1< T2, Allocator2 > > interpolate_thread;
3611 if( thread_num == 0 )
3613 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3618 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
size( ) ) / static_cast< double >( width ) );
3620 if( in.
width( ) == width )
3622 for( i = 0 ; i < in.
size( ) ; i++ )
3629 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3631 for( i = 0 ; i < thread_num ; i++ )
3633 thread[ i ].setup_parameters( in, out, interpolate_thread::Bspline, i, thread_num );
3662 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3673 typedef __interpolate_controller__::interpolate_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 > > interpolate_thread;
3675 if( thread_num == 0 )
3677 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3681 out.
resize( width, height );
3682 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
3683 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
3685 if( in.
width( ) == width && in.
height( ) == height )
3687 for( i = 0 ; i < in.
size( ) ; i++ )
3694 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3696 for( i = 0 ; i < thread_num ; i++ )
3698 thread[ i ].setup_parameters( in, out, interpolate_thread::Bspline, i, thread_num );
3728 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3735 if(
is_same_object( in, out ) || width == 0 || height == 0 || depth == 0 )
3741 typedef __interpolate_controller__::interpolate_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 > > interpolate_thread;
3743 if( thread_num == 0 )
3745 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3749 out.
resize( width, height, depth );
3750 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
3751 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
3752 out.
reso3( in.
reso3( ) *
static_cast< double >( in.
depth( ) ) / static_cast< double >( depth ) );
3754 if( in.
width( ) == width && in.
height( ) == height && in.
depth( ) == depth )
3756 for( i = 0 ; i < in.
size( ) ; i++ )
3763 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3765 for( i = 0 ; i < thread_num ; i++ )
3767 thread[ i ].setup_parameters( in, out, interpolate_thread::Bspline, i, thread_num );
3801 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3811 typedef __interpolate_controller__::interpolate_thread< array< T1, Allocator1 >,
array< T2, Allocator2 > > interpolate_thread;
3813 if( thread_num == 0 )
3815 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3821 if( in.
width( ) == width )
3823 for( i = 0 ; i < in.
size( ) ; i++ )
3830 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3832 for( i = 0 ; i < thread_num ; i++ )
3834 thread[ i ].setup_parameters( in, out, interpolate_thread::Sinc, i, thread_num );
3861 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3871 typedef __interpolate_controller__::interpolate_thread< array1< T1, Allocator1 >,
array1< T2, Allocator2 > > interpolate_thread;
3873 if( thread_num == 0 )
3875 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3880 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
size( ) ) / static_cast< double >( width ) );
3882 if( in.
width( ) == width )
3884 for( i = 0 ; i < in.
size( ) ; i++ )
3891 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3893 for( i = 0 ; i < thread_num ; i++ )
3895 thread[ i ].setup_parameters( in, out, interpolate_thread::Sinc, i, thread_num );
3924 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3935 typedef __interpolate_controller__::interpolate_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 > > interpolate_thread;
3937 if( thread_num == 0 )
3939 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
3943 out.
resize( width, height );
3944 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
3945 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
3947 if( in.
width( ) == width && in.
height( ) == height )
3949 for( i = 0 ; i < in.
size( ) ; i++ )
3956 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
3958 for( i = 0 ; i < thread_num ; i++ )
3960 thread[ i ].setup_parameters( in, out, interpolate_thread::Sinc, i, thread_num );
3990 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3997 if(
is_same_object( in, out ) || width == 0 || height == 0 || depth == 0 )
4003 typedef __interpolate_controller__::interpolate_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 > > interpolate_thread;
4005 if( thread_num == 0 )
4007 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
4011 out.
resize( width, height, depth );
4012 out.
reso1( in.
reso1( ) *
static_cast< double >( in.
width( ) ) / static_cast< double >( width ) );
4013 out.
reso2( in.
reso2( ) *
static_cast< double >( in.
height( ) ) / static_cast< double >( height ) );
4014 out.
reso3( in.
reso3( ) *
static_cast< double >( in.
depth( ) ) / static_cast< double >( depth ) );
4016 if( in.
width( ) == width && in.
height( ) == height && in.
depth( ) == depth )
4018 for( i = 0 ; i < in.
size( ) ; i++ )
4025 interpolate_thread *
thread =
new interpolate_thread[ thread_num ];
4027 for( i = 0 ; i < thread_num ; i++ )
4029 thread[ i ].setup_parameters( in, out, interpolate_thread::Sinc, i, thread_num );
4048 #endif // __INCLUDE_MIST_INTERPOLATE__