36 #ifndef __INCLUDE_FILTER_LINEAR_FILTER_H__
37 #define __INCLUDE_FILTER_LINEAR_FILTER_H__
41 #ifndef __INCLUDE_MIST_H__
45 #ifndef __INCLUDE_MIST_COLOR_H__
46 #include "../config/color.h"
49 #ifndef __INCLUDE_MIST_VECTOR__
50 #include "../vector.h"
53 #ifndef __INCLUDE_MIST_TYPE_TRAIT_H__
54 #include "../config/type_trait.h"
57 #ifndef __INCLUDE_MIST_THREAD__
58 #include "../thread.h"
73 struct __promote_pixel_converter_
76 typedef double promote_type;
78 static promote_type convert_to(
const value_type &pixel )
83 static value_type convert_from(
const promote_type &pixel )
85 return( static_cast< value_type >( pixel ) );
90 struct __promote_pixel_converter_< rgb< T > >
92 typedef rgb< T > value_type;
93 typedef rgb< double > promote_type;
95 static promote_type convert_to(
const value_type &pixel )
97 return( promote_type( pixel.r, pixel.g, pixel.b ) );
100 static value_type convert_from(
const promote_type &pixel )
102 return( value_type( static_cast< T >( pixel.r ), static_cast< T >( pixel.g ), static_cast< T >( pixel.b ) ) );
107 struct __promote_pixel_converter_< bgr< T > >
109 typedef bgr< T > value_type;
110 typedef bgr< double > promote_type;
112 static promote_type convert_to(
const value_type &pixel )
114 return( promote_type( pixel.r, pixel.g, pixel.b ) );
117 static value_type convert_from(
const promote_type &pixel )
119 return( value_type( static_cast< T >( pixel.r ), static_cast< T >( pixel.g ), static_cast< T >( pixel.b ) ) );
124 struct __promote_pixel_converter_< rgba< T > >
126 typedef rgba< T > value_type;
127 typedef rgba< double > promote_type;
129 static promote_type convert_to(
const value_type &pixel )
131 return( promote_type( pixel.r, pixel.g, pixel.b ) );
134 static value_type convert_from(
const promote_type &pixel )
136 return( value_type( static_cast< T >( pixel.r ), static_cast< T >( pixel.g ), static_cast< T >( pixel.b ) ) );
141 struct __promote_pixel_converter_< bgra< T > >
143 typedef bgra< T > value_type;
144 typedef bgra< double > promote_type;
146 static promote_type convert_to(
const value_type &pixel )
148 return( promote_type( pixel.r, pixel.g, pixel.b ) );
151 static value_type convert_from(
const promote_type &pixel )
153 return( value_type( static_cast< T >( pixel.r ), static_cast< T >( pixel.g ), static_cast< T >( pixel.b ) ) );
158 struct __promote_pixel_converter_< vector2< T > >
160 typedef vector2< T > value_type;
161 typedef vector2< double > promote_type;
163 static promote_type convert_to(
const value_type &pixel )
165 return( promote_type( pixel.x, pixel.y ) );
168 static value_type convert_from(
const promote_type &pixel )
170 return( value_type( static_cast< T >( pixel.x ), static_cast< T >( pixel.y ) ) );
175 struct __promote_pixel_converter_< vector3< T > >
177 typedef vector3< T > value_type;
178 typedef vector3< double > promote_type;
180 static promote_type convert_to(
const value_type &pixel )
182 return( promote_type( pixel.x, pixel.y, pixel.z ) );
185 static value_type convert_from(
const promote_type &pixel )
187 return( value_type( static_cast< T >( pixel.x ), static_cast< T >( pixel.y ), static_cast< T >( pixel.z ) ) );
191 template <
int DIMENSION >
194 template <
class Array >
195 inline static typename Array::value_type &at( Array &in,
typename Array::size_type _1,
typename Array::size_type _2,
typename Array::size_type _3 )
197 return( in( _1, _2, _3 ) );
200 template <
class Array >
201 inline static const typename Array::value_type &at(
const Array &in,
typename Array::size_type _1,
typename Array::size_type _2,
typename Array::size_type _3 )
203 return( in( _1, _2, _3 ) );
206 template <
class Array >
207 inline static typename Array::size_type size1(
const Array &in ){
return( in.size1( ) ); }
209 template <
class Array >
210 inline static typename Array::size_type size2(
const Array &in ){
return( in.size2( ) ); }
212 template <
class Array >
213 inline static typename Array::size_type size3(
const Array &in ){
return( in.size3( ) ); }
217 struct __access__< 2 >
219 template <
class Array >
220 inline static typename Array::value_type &at( Array &in,
typename Array::size_type _1,
typename Array::size_type _2,
typename Array::size_type _3 )
222 return( in( _2, _1, _3 ) );
225 template <
class Array >
226 inline static const typename Array::value_type &at(
const Array &in,
typename Array::size_type _1,
typename Array::size_type _2,
typename Array::size_type _3 )
228 return( in( _2, _1, _3 ) );
231 template <
class Array >
232 inline static typename Array::size_type size1(
const Array &in ){
return( in.size2( ) ); }
234 template <
class Array >
235 inline static typename Array::size_type size2(
const Array &in ){
return( in.size1( ) ); }
237 template <
class Array >
238 inline static typename Array::size_type size3(
const Array &in ){
return( in.size3( ) ); }
242 struct __access__< 3 >
244 template <
class Array >
245 inline static typename Array::value_type &at( Array &in,
typename Array::size_type _1,
typename Array::size_type _2,
typename Array::size_type _3 )
247 return( in( _2, _3, _1 ) );
250 template <
class Array >
251 inline static const typename Array::value_type &at(
const Array &in,
typename Array::size_type _1,
typename Array::size_type _2,
typename Array::size_type _3 )
253 return( in( _2, _3, _1 ) );
256 template <
class Array >
257 inline static typename Array::size_type size1(
const Array &in ){
return( in.size3( ) ); }
259 template <
class Array >
260 inline static typename Array::size_type size2(
const Array &in ){
return( in.size1( ) ); }
262 template <
class Array >
263 inline static typename Array::size_type size3(
const Array &in ){
return( in.size2( ) ); }
269 template <
class Array1,
class Array2,
class Kernel,
class Functor >
270 void linear_filter(
const Array1 &in, Array2 &out,
const Kernel &kernel,
271 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
272 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz, Functor f )
274 typedef typename Array1::size_type size_type;
275 typedef typename Array1::difference_type difference_type;
276 typedef __promote_pixel_converter_< typename Array2::value_type > promote_pixel_converter;
277 typedef typename promote_pixel_converter::promote_type promote_type;
278 typedef typename Array2::value_type out_value_type;
279 typedef typename Array1::const_pointer ipointer_type;
280 typedef typename Array2::pointer opointer_type;
281 typedef typename Kernel::const_pointer kpointer_type;
282 typedef typename Kernel::value_type kvalue_type;
284 difference_type w = in.width( );
285 difference_type h = in.height( );
286 difference_type d = in.depth( );
288 difference_type fw = kernel.width( );
289 difference_type fh = kernel.height( );
290 difference_type fd = kernel.depth( );
292 const bool bprogress1 = thread_idy == 0 && d == 1;
293 const bool bprogress2 = thread_idz == 0 && d > 1;
295 difference_type rw = fw / 2;
296 difference_type rh = fh / 2;
297 difference_type rd = fd / 2;
299 difference_type i, j, k;
301 size_type fsize = fw * fh * fd;
302 difference_type *pf =
new difference_type[ fsize ];
305 difference_type count = 0;
306 difference_type cx = w / 2;
307 difference_type cy = h / 2;
308 difference_type cz = d / 2;
309 ipointer_type pc = &in( cx, cy, cz );
311 for( difference_type z = 0 ; z < fd ; z++ )
313 for( difference_type y = 0 ; y < fh ; y++ )
315 for( difference_type x = 0 ; x < fw ; x++ )
317 pf[ count++ ] = &in( x + cx - rw, y + cy - rh, z + cz - rd ) - pc;
324 for( k = thread_idz ; k < rd ; k += thread_numz )
326 for( j = thread_idy ; j < h ; j += thread_numy )
328 opointer_type op = &out( 0, j, k );
330 for( i = 0 ; i < w ; i++ )
332 promote_type value = promote_type( );
334 difference_type sl = i < rw ? rw - i : 0;
335 difference_type el = w - i <= rw ? rw + w - i : fw;
336 difference_type sm = j < rh ? rh - j : 0;
337 difference_type em = h - j <= rh ? rh + h - j : fh;
338 difference_type sn = k < rd ? rd - k : 0;
340 for( difference_type n = sn ; n < fd ; n++ )
342 for( difference_type m = sm ; m < em ; m++ )
344 for( difference_type l = sl ; l < el ; l++ )
346 kvalue_type kv = kernel( l, m, n );
347 value += kv * in( i + l - rw, j + m - rh, k + n - rd );
353 op[ i ] = promote_pixel_converter::convert_from( sum == 0 ? value : value / sum );
359 for( ; k + rd < d ; k += thread_numz )
361 for( j = thread_idy ; j < rh ; j += thread_numy )
363 opointer_type op = &out( 0, j, k );
365 for( i = 0 ; i < w ; i++ )
367 promote_type value = promote_type( );
369 difference_type sl = i < rw ? rw - i : 0;
370 difference_type el = w - i <= rw ? rw + w - i : fw;
371 difference_type sm = rh - j;
373 for( difference_type n = 0 ; n < fd ; n++ )
375 for( difference_type m = sm ; m < fh ; m++ )
377 for( difference_type l = sl ; l < el ; l++ )
379 kvalue_type kv = kernel( l, m, n );
380 value += kv * in( i + l - rw, j + m - rh, k + n - rd );
386 op[ i ] = promote_pixel_converter::convert_from( sum == 0 ? value : value / sum );
391 for( ; j + rh < h ; j += thread_numy )
393 ipointer_type ip = &in( 0, j, k );
394 opointer_type op = &out( 0, j, k );
396 for( i = 0 ; i < rw ; i++ )
398 difference_type *ppf = pf;
399 ipointer_type p = ip + i;
400 kpointer_type kp = &kernel[ 0 ];
401 promote_type value = promote_type( );
403 difference_type lnum = fh * fd;
404 difference_type sn = rw - i;
406 for( difference_type l = 0 ; l < lnum ; l++ )
408 for( difference_type n = sn ; n < fw ; n++ )
410 value += kp[ n ] * p[ ppf[ n ] ];
418 op[ i ] = promote_pixel_converter::convert_from( sum == 0 ? value : value / sum );
421 for( ; i + rw < w ; i++ )
423 ipointer_type p = ip + i;
424 promote_type value = promote_type( );
426 for( size_type n = 0 ; n < fsize ; n++ )
428 value += kernel[ n ] * p[ pf[ n ] ];
431 op[ i ] = promote_pixel_converter::convert_from( value );
436 difference_type *ppf = pf;
437 ipointer_type p = ip + i;
438 kpointer_type kp = &kernel[ 0 ];
439 promote_type value = promote_type( );
441 difference_type lnum = fh * fd;
442 difference_type en = rw + w - i;
444 for( difference_type l = 0 ; l < lnum ; l++ )
446 for( difference_type n = 0 ; n < en ; n++ )
448 value += kp[ n ] * p[ ppf[ n ] ];
456 op[ i ] = promote_pixel_converter::convert_from( sum == 0 ? value : value / sum );
461 f( static_cast< double >( j + 1 ) / static_cast< double >( h ) * 100.0 );
465 for( ; j < h ; j += thread_numy )
467 opointer_type op = &out( 0, j, k );
469 for( i = 0 ; i < w ; i++ )
471 promote_type value = promote_type( );
473 difference_type sl = i < rw ? rw - i : 0;
474 difference_type el = w - i <= rw ? rw + w - i : fw;
475 difference_type em = rh + h - j;
477 for( difference_type n = 0 ; n < fd ; n++ )
479 for( difference_type m = 0 ; m < em ; m++ )
481 for( difference_type l = sl ; l < el ; l++ )
483 kvalue_type kv = kernel( l, m, n );
484 value += kv * in( i + l - rw, j + m - rh, k + n - rd );
490 op[ i ] = promote_pixel_converter::convert_from( sum == 0 ? value : value / sum );
496 f( static_cast< double >( k + 1 ) / static_cast< double >( d ) * 100.0 );
501 for( ; k < d ; k += thread_numz )
503 for( j = thread_idy ; j < h ; j += thread_numy )
505 opointer_type op = &out( 0, j, k );
507 for( i = 0 ; i < w ; i++ )
509 promote_type value = promote_type( );
511 difference_type sl = i < rw ? rw - i : 0;
512 difference_type el = w - i <= rw ? rw + w - i : fw;
513 difference_type sm = j < rh ? rh - j : 0;
514 difference_type em = h - j <= rh ? rh + h - j : fh;
515 difference_type en = d - k <= rd ? rd + d - k : fd;
517 for( difference_type n = 0 ; n < en ; n++ )
519 for( difference_type m = sm ; m < em ; m++ )
521 for( difference_type l = sl ; l < el ; l++ )
523 kvalue_type kv = kernel( l, m, n );
524 value += kv * in( i + l - rw, j + m - rh, k + n - rd );
530 op[ i ] = promote_pixel_converter::convert_from( sum == 0 ? value : value / sum );
538 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
539 static void __linear_filter__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
const Kernel &kernel,
540 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num, Functor f )
542 linear_filter( in, out, kernel, 0, 1, thread_id, thread_num, f );
545 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
546 static void __linear_filter__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
const Kernel &kernel,
547 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num, Functor f )
549 linear_filter( in, out, kernel, thread_id, thread_num, 0, 1, f );
552 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
553 static void __linear_filter__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
const Kernel &kernel,
554 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num, Functor f )
556 linear_filter( in, out, kernel, 0, 1, thread_id, thread_num, f );
559 template <
class T1,
class T2,
class Kernel,
class Functor >
560 class linear_thread :
public mist::thread< linear_thread< T1, T2, Kernel, Functor > >
564 typedef typename base::thread_exit_type thread_exit_type;
565 typedef typename T1::size_type size_type;
566 typedef typename T1::value_type value_type;
575 const Kernel *kernel_;
580 void setup_parameters(
const T1 &in, T2 &out,
const Kernel &kernel, size_type thread_id, size_type thread_num, Functor f )
585 thread_id_ = thread_id;
586 thread_num_ = thread_num;
590 linear_thread( size_type
id = 0, size_type num = 1 ) : thread_id_( id ), thread_num_( num ),
591 in_( NULL ), out_( NULL ), kernel_( NULL )
595 linear_thread(
const linear_thread &p ) : base( p ), thread_id_( p.thread_id_ ), thread_num_( p.thread_num_ ),
596 in_( p.in_ ), out_( p.out_ ), kernel_( p.kernel_ )
602 virtual thread_exit_type thread_function( )
604 __linear_filter__( *in_, *out_, *kernel_, thread_id_, thread_num_, f_ );
610 template <
int DIMENSION >
611 struct _1D_linear_filter_
613 template <
class Array1,
class Array2,
class Kernel,
class Functor >
614 static void linear_filter(
const Array1 &in, Array2 &out,
const Kernel &kernel,
615 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
616 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz, Functor f,
double sp,
double ep )
618 typedef typename Array1::size_type size_type;
619 typedef typename Array1::value_type value_type;
620 typedef typename Kernel::value_type kvalue_type;
621 typedef typename Array1::const_pointer ipointer;
622 typedef typename Array2::pointer opointer;
623 typedef typename Array1::difference_type difference_type;
624 typedef __promote_pixel_converter_< typename Array2::value_type > promote_pixel_converter;
625 typedef typename promote_pixel_converter::promote_type promote_type;
626 typedef __access__< DIMENSION > access;
628 difference_type _1e = access::size1( in );
629 difference_type _2e = access::size2( in );
630 difference_type _3e = access::size3( in );
632 const bool bprogress1 = thread_idy == 0 && _3e == 1;
633 const bool bprogress2 = thread_idz == 0 && _3e > 1;
635 difference_type fw = kernel.size( );
636 difference_type rw = fw / 2;
638 difference_type i1, i2, i3;
639 value_type *tmp =
new value_type[ _1e ];
640 difference_type diff = &access::at( in, 1, 0, 0 ) - &access::at( in, 0, 0, 0 );
642 for( i3 = thread_idz ; i3 < _3e ; i3 += thread_numz )
644 for( i2 = thread_idy ; i2 < _2e ; i2 += thread_numy )
646 ipointer p0 = &access::at( in, 0, i2, i3 );
647 opointer op = &access::at( out, 0, i2, i3 );
651 for( i1 = 0 ; i1 + rw + 1 < fw ; i1++ )
657 for( i1 = 0 ; i1 < rw ; i1++ )
662 promote_type value = promote_type( );
664 value_type *ptmp = tmp + i1 - rw;
666 for( size_type n = rw - i1 ; n < kernel.size( ) ; n++ )
668 value += kernel[ n ] * ptmp[ n ];
672 *op = promote_pixel_converter::convert_from( sum == 0 ? value : value / sum );
676 for( ; i1 + rw < _1e ; i1++ )
681 promote_type value = promote_type( );
683 value_type *ptmp = tmp + i1 - rw;
684 for( size_type n = 0 ; n < kernel.size( ) ; n++ )
686 value += kernel[ n ] * ptmp[ n ];
689 *op = promote_pixel_converter::convert_from( value );
693 for( ; i1 < _1e ; i1++ )
695 promote_type value = promote_type( );
697 value_type *ptmp = tmp + i1 - rw;
699 size_type ne = rw + _1e - i1;
700 for( size_type n = 0 ; n < ne ; n++ )
702 value += kernel[ n ] * ptmp[ n ];
706 *op = promote_pixel_converter::convert_from( sum == 0 ? value : value / sum );
712 f( sp + static_cast< double >( i2 + 1 ) / static_cast< double >( _2e ) * ( ep - sp ) );
718 f( sp + static_cast< double >( i3 + 1 ) / static_cast< double >( _3e ) * ( ep - sp ) );
726 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
727 static void __1D_linear_filter__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
const Kernel &k1,
const Kernel & ,
const Kernel & ,
728 typename array3< T1, Allocator1 >::size_type axis,
typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num, Functor f )
730 linear_filter( in, out, k1, 0, 1, thread_id, thread_num, f );
733 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
734 static void __1D_linear_filter__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
const Kernel &k1,
const Kernel &k2,
const Kernel & ,
735 typename array3< T1, Allocator1 >::size_type axis,
typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num, Functor f )
739 _1D_linear_filter_< 1 >::linear_filter( in, out, k1, thread_id, thread_num, 0, 1, f, 0.0, 50.0 );
743 _1D_linear_filter_< 2 >::linear_filter( out, out, k2, thread_id, thread_num, 0, 1, f, 50.0, 100.0 );
747 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
748 static void __1D_linear_filter__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
const Kernel &k1,
const Kernel &k2,
const Kernel &k3,
749 typename array3< T1, Allocator1 >::size_type axis,
typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num, Functor f )
753 _1D_linear_filter_< 1 >::linear_filter( in, out, k1, 0, 1, thread_id, thread_num, f, 0.0, 100.0 / 3.0 );
757 _1D_linear_filter_< 2 >::linear_filter( out, out, k2, 0, 1, thread_id, thread_num, f, 100.0 / 3.0, 200.0 / 3.0 );
761 _1D_linear_filter_< 3 >::linear_filter( out, out, k3, 0, 1, thread_id, thread_num, f, 200.0 / 3.0, 100.0 );
765 template <
class T1,
class T2,
class Kernel,
class Functor >
766 class _1D_linear_thread :
public mist::thread< _1D_linear_thread< T1, T2, Kernel, Functor > >
770 typedef typename base::thread_exit_type thread_exit_type;
771 typedef typename T1::size_type size_type;
772 typedef typename T1::value_type value_type;
789 void setup_parameters(
const T1 &in, T2 &out,
const Kernel &k1,
const Kernel &k2,
const Kernel &k3, size_type axis, size_type thread_id, size_type thread_num, Functor f )
797 thread_id_ = thread_id;
798 thread_num_ = thread_num;
802 _1D_linear_thread( size_type
id = 0, size_type num = 1 ) : thread_id_( id ), thread_num_( num ),
803 in_( NULL ), out_( NULL ), k1_( NULL ), k2_( NULL ), k3_( NULL )
807 _1D_linear_thread(
const _1D_linear_thread &p ) : base( p ), thread_id_( p.thread_id_ ), thread_num_( p.thread_num_ ),
808 in_( p.in_ ), out_( p.out_ ), k1_( p.k1_ ), k2_( p.k2_ ), k3_( p.k3_ )
814 virtual thread_exit_type thread_function( )
816 __1D_linear_filter__( *in_, *out_, *k1_, *k2_, *k3_, axis_, thread_id_, thread_num_, f_ );
824 template <
class Array1,
class Array2,
class Functor >
825 void average_filter(
const Array1 &in, Array2 &out,
826 typename Array1::size_type fw,
typename Array1::size_type fh,
typename Array1::size_type fd,
827 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
828 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz, Functor f )
830 typedef typename Array1::size_type size_type;
831 typedef typename Array1::difference_type difference_type;
832 typedef __promote_pixel_converter_< typename Array2::value_type > promote_pixel_converter;
833 typedef typename promote_pixel_converter::promote_type promote_type;
834 typedef typename Array2::value_type out_value_type;
835 typedef typename Array1::const_pointer ipointer_type;
836 typedef typename Array2::pointer opointer_type;
838 difference_type w = in.width( );
839 difference_type h = in.height( );
840 difference_type d = in.depth( );
842 const bool bprogress1 = thread_idy == 0 && d == 1;
843 const bool bprogress2 = thread_idz == 0 && d > 1;
845 difference_type rw = fw / 2;
846 difference_type rh = fh / 2;
847 difference_type rd = fd / 2;
848 difference_type rrw = fw - rw;
850 difference_type i, j, k;
852 promote_type *sum =
new promote_type[ fw ];
854 for( k = thread_idz ; k < d ; k += thread_numz )
856 difference_type sz = k - rd;
857 difference_type ez = sz + fd - 1;
868 difference_type fdd = ez - sz + 1;
870 for( j = thread_idy ; j < h ; j += thread_numy )
872 difference_type sy = j - rh;
873 difference_type ey = sy + fh - 1;
884 difference_type fhh = ey - sy + 1;
887 promote_type __sum__ = promote_type( );
888 for( i = 0 ; i < rrw - 1 ; i++ )
890 promote_type value = promote_type( );
891 for( difference_type z = sz ; z <= ez ; z++ )
893 for( difference_type y = sy ; y <= ey ; y++ )
895 value += in( i, y, z );
903 double fsize =
static_cast< double >( fhh * fdd );
904 opointer_type op = &out( 0, j, k );
905 size_type indx = rrw - 1;
908 for( i = 0 ; i <= rw ; i++, indx++ )
910 promote_type value = promote_type( );
911 for( difference_type z = sz ; z <= ez ; z++ )
913 for( difference_type y = sy ; y <= ey ; y++ )
915 value += in( indx, y, z );
922 op[ i ] = promote_pixel_converter::convert_from( __sum__ / ( fsize * ( rrw + i ) ) );
925 for( ; i + rrw <= w ; i++, indx++ )
932 __sum__ -= sum[ indx ];
934 promote_type value = promote_type( );
935 for( difference_type z = sz ; z <= ez ; z++ )
937 for( difference_type y = sy ; y <= ey ; y++ )
939 value += in( i + rrw - 1, y, z );
946 op[ i ] = promote_pixel_converter::convert_from( __sum__ / ( fsize * fw ) );
949 for( ; i < w ; i++, indx++ )
956 __sum__ -= sum[ indx ];
958 op[ i ] = promote_pixel_converter::convert_from( __sum__ / ( fsize * ( rw + w - i ) ) );
963 f( static_cast< double >( j + 1 ) / static_cast< double >( h ) * 100.0 );
969 f( static_cast< double >( k + 1 ) / static_cast< double >( d ) * 100.0 );
977 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
978 static void __average_filter__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
979 typename array< T1, Allocator1 >::size_type fw,
typename array< T1, Allocator1 >::size_type fh,
typename array< T1, Allocator1 >::size_type fd,
980 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num, Functor f )
982 average_filter( in, out, fw, fh, fd, 0, 1, thread_id, thread_num, f );
985 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
986 static void __average_filter__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
987 typename array2< T1, Allocator1 >::size_type fw,
typename array2< T1, Allocator1 >::size_type fh,
typename array2< T1, Allocator1 >::size_type fd,
988 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num, Functor f )
990 average_filter( in, out, fw, fh, fd, thread_id, thread_num, 0, 1, f );
993 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
994 static void __average_filter__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
995 typename array3< T1, Allocator1 >::size_type fw,
typename array3< T1, Allocator1 >::size_type fh,
typename array3< T1, Allocator1 >::size_type fd,
996 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num, Functor f )
998 average_filter( in, out, fw, fh, fd, 0, 1, thread_id, thread_num, f );
1001 template <
class T1,
class T2,
class Functor >
1002 class average_thread :
public mist::thread< average_thread< T1, T2, Functor > >
1006 typedef typename base::thread_exit_type thread_exit_type;
1007 typedef typename T1::size_type size_type;
1008 typedef typename T1::value_type value_type;
1024 void setup_parameters(
const T1 &in, T2 &out, size_type fw, size_type fh, size_type fd, size_type thread_id, size_type thread_num, Functor f )
1031 thread_id_ = thread_id;
1032 thread_num_ = thread_num;
1036 average_thread( size_type
id = 0, size_type num = 1 ) : thread_id_( id ), thread_num_( num ),
1037 in_( NULL ), out_( NULL ), fw_( 0 ), fh_( 0 ), fd_( 0 )
1041 average_thread(
const average_thread &p ) : base( p ), thread_id_( p.thread_id_ ), thread_num_( p.thread_num_ ),
1042 in_( p.in_ ), out_( p.out_ ), fw_( p.fw_ ), fh_( p.fh_ ), fd_( p.fd_ )
1048 virtual thread_exit_type thread_function( )
1050 __average_filter__( *in_, *out_, fw_, fh_, fd_, thread_id_, thread_num_, f_ );
1055 template <
int DIMENSION >
1056 struct _1D_average_filter_
1058 template <
class Array1,
class Array2,
class Functor >
1059 static void average_filter(
const Array1 &in, Array2 &out,
typename Array1::difference_type fw,
1060 typename Array1::size_type thread_idy,
typename Array1::size_type thread_numy,
1061 typename Array1::size_type thread_idz,
typename Array1::size_type thread_numz, Functor f,
double sp,
double ep )
1063 typedef typename Array1::size_type size_type;
1064 typedef typename Array1::value_type value_type;
1065 typedef typename Array1::const_pointer ipointer;
1066 typedef typename Array2::pointer opointer;
1067 typedef typename Array1::difference_type difference_type;
1068 typedef __promote_pixel_converter_< typename Array2::value_type > promote_pixel_converter;
1069 typedef typename promote_pixel_converter::promote_type promote_type;
1070 typedef __access__< DIMENSION > access;
1072 difference_type _1e = access::size1( in );
1073 difference_type _2e = access::size2( in );
1074 difference_type _3e = access::size3( in );
1076 const bool bprogress1 = thread_idy == 0 && _3e == 1;
1077 const bool bprogress2 = thread_idz == 0 && _3e > 1;
1079 difference_type rw = fw / 2;
1081 difference_type i1, i2, i3;
1082 value_type *tmp =
new value_type[ _1e ];
1083 difference_type diff = &access::at( in, 1, 0, 0 ) - &access::at( in, 0, 0, 0 );
1085 for( i3 = thread_idz ; i3 < _3e ; i3 += thread_numz )
1087 for( i2 = thread_idy ; i2 < _2e ; i2 += thread_numy )
1089 ipointer p0 = &access::at( in, 0, i2, i3 );
1090 opointer op = &access::at( out, 0, i2, i3 );
1093 promote_type value = promote_type( );
1096 for( i1 = 0 ; i1 + rw + 1 < fw ; i1++ )
1103 for( i1 = 0 ; i1 <= rw ; i1++ )
1106 tmp[ i1 + rw ] = *p;
1109 *op = promote_pixel_converter::convert_from( value / static_cast< double >( fw - rw + i1 ) );
1113 for( ; i1 + rw < _1e ; i1++ )
1116 value -= tmp[ i1 - rw - 1 ];
1117 tmp[ i1 + rw ] = *p;
1120 *op = promote_pixel_converter::convert_from( value / static_cast< double >( fw ) );
1124 for( ; i1 < _1e ; i1++ )
1126 value -= tmp[ i1 - rw - 1 ];
1128 *op = promote_pixel_converter::convert_from( value / static_cast< double >( rw + _1e - i1 ) );
1134 f( sp + static_cast< double >( i2 + 1 ) / static_cast< double >( _2e ) * ( ep - sp ) );
1140 f( sp + static_cast< double >( i3 + 1 ) / static_cast< double >( _3e ) * ( ep - sp ) );
1148 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
1149 static void __1D_average_filter__(
const array< T1, Allocator1 > &in, array< T2, Allocator2 > &out,
1150 typename array< T1, Allocator1 >::size_type fw,
typename array< T1, Allocator1 >::size_type fh,
typename array< T1, Allocator1 >::size_type fd,
1151 typename array< T1, Allocator1 >::size_type thread_id,
typename array< T1, Allocator1 >::size_type thread_num, Functor f )
1153 average_filter( in, out, fw, fh, fd, 0, 1, thread_id, thread_num, f );
1156 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
1157 static void __1D_average_filter__(
const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out,
1158 typename array2< T1, Allocator1 >::size_type fw,
typename array2< T1, Allocator1 >::size_type fh,
typename array2< T1, Allocator1 >::size_type fd,
1159 typename array2< T1, Allocator1 >::size_type thread_id,
typename array2< T1, Allocator1 >::size_type thread_num, Functor f )
1161 _1D_average_filter_< 1 >::average_filter( in, out, fw, thread_id, thread_num, 0, 1, f, 0.0, 50.0 );
1162 _1D_average_filter_< 2 >::average_filter( out, out, fh, thread_id, thread_num, 0, 1, f, 50.0, 100.0 );
1165 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
1166 static void __1D_average_filter__(
const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out,
1167 typename array3< T1, Allocator1 >::size_type fw,
typename array3< T1, Allocator1 >::size_type fh,
typename array3< T1, Allocator1 >::size_type fd,
1168 typename array3< T1, Allocator1 >::size_type thread_id,
typename array3< T1, Allocator1 >::size_type thread_num, Functor f )
1170 _1D_average_filter_< 1 >::average_filter( in, out, fw, 0, 1, thread_id, thread_num, f, 0.0, 100.0 / 3.0 );
1171 _1D_average_filter_< 2 >::average_filter( out, out, fh, 0, 1, thread_id, thread_num, f, 100.0 / 3.0, 200.0 / 3.0 );
1172 _1D_average_filter_< 3 >::average_filter( out, out, fd, 0, 1, thread_id, thread_num, f, 200.0 / 3.0, 100.0 );
1175 template <
class T1,
class T2,
class Functor >
1176 class _1D_average_thread :
public mist::thread< _1D_average_thread< T1, T2, Functor > >
1180 typedef typename base::thread_exit_type thread_exit_type;
1181 typedef typename T1::size_type size_type;
1182 typedef typename T1::value_type value_type;
1198 void setup_parameters(
const T1 &in, T2 &out, size_type fw, size_type fh, size_type fd, size_type thread_id, size_type thread_num, Functor f )
1205 thread_id_ = thread_id;
1206 thread_num_ = thread_num;
1210 _1D_average_thread( size_type
id = 0, size_type num = 1 ) : thread_id_( id ), thread_num_( num ),
1211 in_( NULL ), out_( NULL ), fw_( 0 ), fh_( 0 ), fd_( 0 )
1215 _1D_average_thread(
const _1D_average_thread &p ) : base( p ), thread_id_( p.thread_id_ ), thread_num_( p.thread_num_ ),
1216 in_( p.in_ ), out_( p.out_ ), fw_( p.fw_ ), fh_( p.fh_ ), fd_( p.fd_ )
1222 virtual thread_exit_type thread_function( )
1224 __1D_average_filter__( *in_, *out_, fw_, fh_, fd_, thread_id_, thread_num_, f_ );
1230 template <
class Array >
1231 inline void compute_normalized_kernel( Array &kernel )
1233 typedef typename Array::value_type value_type;
1234 typedef typename Array::size_type size_type;
1236 value_type sum = value_type( );
1237 for( size_type i = 0 ; i < kernel.size( ) ; i++ )
1242 for( size_type i = 0 ; i < kernel.size( ) ; i++ )
1248 template <
class Array >
1249 inline void compute_gaussian_kernel( Array &kernel,
double sigma )
1251 typedef typename Array::size_type size_type;
1252 typedef typename Array::difference_type difference_type;
1253 typedef typename Array::value_type value_type;
1260 double radius = sigma * 2.0;
1261 double ax = kernel.reso1( );
1262 double ay = kernel.reso2( );
1263 double az = kernel.reso3( );
1264 double axx = ax * ax;
1265 double ayy = ay * ay;
1266 double azz = az * az;
1268 difference_type Rx =
static_cast< difference_type
>( std::ceil( radius / ax ) );
1269 difference_type Ry =
static_cast< difference_type
>( std::ceil( radius / ay ) );
1270 difference_type Rz =
static_cast< difference_type
>( std::ceil( radius / az ) );
1272 kernel.resize( Rx * 2 + 1, Ry * 2 + 1, Rz * 2 + 1 );
1274 difference_type fw = kernel.width( );
1275 difference_type fh = kernel.height( );
1276 difference_type fd = kernel.depth( );
1278 difference_type rw = fw / 2;
1279 difference_type rh = fh / 2;
1280 difference_type rd = fd / 2;
1282 double _1_sig2 = 1.0 / ( sigma * sigma * 2.0 );
1284 for( difference_type z = -rd ; z <= rd ; z++ )
1286 double zz =
static_cast< double >( z * z * azz );
1287 for( difference_type y = -rh ; y <= rh ; y++ )
1289 double yy =
static_cast< double >( y * y * ayy );
1290 for( difference_type x = -rw ; x <= rw ; x++ )
1292 double xx =
static_cast< double >( x * x * axx );
1293 double g = std::exp( -( xx + yy + zz ) * _1_sig2 );
1295 kernel( x + rw, y + rh, z + rd ) =
static_cast< value_type
>( g );
1300 for( size_type i = 0 ; i < kernel.size( ) ; i++ )
1306 template <
class Array >
1307 inline void compute_gaussian_kernel( Array &k1, Array &k2, Array &k3,
double sigma )
1309 typedef typename Array::size_type size_type;
1310 typedef typename Array::difference_type difference_type;
1311 typedef typename Array::value_type value_type;
1318 double radius = sigma * 2.0;
1319 double ax = k1.reso1( );
1320 double ay = k2.reso1( );
1321 double az = k3.reso1( );
1322 double axx = ax * ax;
1323 double ayy = ay * ay;
1324 double azz = az * az;
1326 difference_type Rx =
static_cast< difference_type
>( std::ceil( radius / ax ) );
1327 difference_type Ry =
static_cast< difference_type
>( std::ceil( radius / ay ) );
1328 difference_type Rz =
static_cast< difference_type
>( std::ceil( radius / az ) );
1330 k1.resize( Rx * 2 + 1 );
1331 k2.resize( Ry * 2 + 1 );
1332 k3.resize( Rz * 2 + 1 );
1334 difference_type fw = k1.size( );
1335 difference_type fh = k2.size( );
1336 difference_type fd = k3.size( );
1338 difference_type rw = fw / 2;
1339 difference_type rh = fh / 2;
1340 difference_type rd = fd / 2;
1342 double _1_sig2 = 1.0 / ( sigma * sigma * 2.0 );
1345 for( difference_type x = -rw ; x <= rw ; x++ )
1347 double xx =
static_cast< double >( x * x * axx );
1348 double g = std::exp( -xx * _1_sig2 );
1350 k1[ x + rw ] =
static_cast< value_type
>( g );
1353 for( size_type i = 0 ; i < k1.size( ) ; i++ )
1361 for( difference_type y = -rh ; y <= rh ; y++ )
1363 double yy =
static_cast< double >( y * y * ayy );
1364 double g = std::exp( -yy * _1_sig2 );
1366 k2[ y + rh ] =
static_cast< value_type
>( g );
1369 for( size_type i = 0 ; i < k2.size( ) ; i++ )
1377 for( difference_type z = -rd ; z <= rd ; z++ )
1379 double zz =
static_cast< double >( z * z * azz );
1380 double g = std::exp( -zz * _1_sig2 );
1382 k3[ z + rd ] =
static_cast< value_type
>( g );
1385 for( size_type i = 0 ; i < k3.size( ) ; i++ )
1449 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
1483 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
1518 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
1527 typedef __linear__::linear_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 >, Kernel, Functor > linear_thread;
1529 if( thread_num == 0 )
1531 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
1538 linear_thread *
thread =
new linear_thread[ thread_num ];
1541 for( i = 0 ; i < thread_num ; i++ )
1543 thread[ i ].setup_parameters( in, out, kernel, i, thread_num, f );
1579 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
1588 typedef __linear__::_1D_linear_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 >, Kernel, Functor > _1D_linear_thread;
1590 if( thread_num == 0 )
1592 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
1599 _1D_linear_thread *
thread =
new _1D_linear_thread[ thread_num ];
1604 for( size_type i = 0 ; i < thread_num ; i++ )
1606 thread[ i ].setup_parameters( in, out, kernel1, kernel2, kernel2, 0, i, thread_num, f );
1614 for( size_type i = 0 ; i < thread_num ; i++ )
1616 thread[ i ].setup_parameters( in, out, kernel1, kernel2, kernel2, 1, i, thread_num, f );
1649 template <
class T,
class Allocator,
class Kernel,
class Functor >
1658 typedef __linear__::_1D_linear_thread< array2< T, Allocator >,
array2< T, Allocator >, Kernel, Functor > _1D_linear_thread;
1660 if( thread_num == 0 )
1662 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
1665 _1D_linear_thread *
thread =
new _1D_linear_thread[ thread_num ];
1670 for( size_type i = 0 ; i < thread_num ; i++ )
1672 thread[ i ].setup_parameters( in, in, kernel1, kernel2, kernel2, 0, i, thread_num, f );
1680 for( size_type i = 0 ; i < thread_num ; i++ )
1682 thread[ i ].setup_parameters( in, in, kernel1, kernel2, kernel2, 1, i, thread_num, f );
1715 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
1724 typedef __linear__::linear_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 >, Kernel, Functor > linear_thread;
1726 if( thread_num == 0 )
1728 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
1736 linear_thread *
thread =
new linear_thread[ thread_num ];
1739 for( i = 0 ; i < thread_num ; i++ )
1741 thread[ i ].setup_parameters( in, out, kernel, i, thread_num, f );
1778 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel,
class Functor >
1787 typedef __linear__::_1D_linear_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 >, Kernel, Functor > _1D_linear_thread;
1789 if( thread_num == 0 )
1791 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
1799 _1D_linear_thread *
thread =
new _1D_linear_thread[ thread_num ];
1804 for( size_type i = 0 ; i < thread_num ; i++ )
1806 thread[ i ].setup_parameters( in, out, kernel1, kernel2, kernel3, 0, i, thread_num, f );
1814 for( size_type i = 0 ; i < thread_num ; i++ )
1816 thread[ i ].setup_parameters( in, out, kernel1, kernel2, kernel3, 1, i, thread_num, f );
1824 for( size_type i = 0 ; i < thread_num ; i++ )
1826 thread[ i ].setup_parameters( in, out, kernel1, kernel2, kernel3, 2, i, thread_num, f );
1860 template <
class T,
class Allocator,
class Kernel,
class Functor >
1869 typedef __linear__::_1D_linear_thread< array3< T, Allocator >,
array3< T, Allocator >, Kernel, Functor > _1D_linear_thread;
1871 if( thread_num == 0 )
1873 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
1876 _1D_linear_thread *
thread =
new _1D_linear_thread[ thread_num ];
1881 for( size_type i = 0 ; i < thread_num ; i++ )
1883 thread[ i ].setup_parameters( in, in, kernel1, kernel2, kernel3, 0, i, thread_num, f );
1891 for( size_type i = 0 ; i < thread_num ; i++ )
1893 thread[ i ].setup_parameters( in, in, kernel1, kernel2, kernel3, 1, i, thread_num, f );
1901 for( size_type i = 0 ; i < thread_num ; i++ )
1903 thread[ i ].setup_parameters( in, in, kernel1, kernel2, kernel3, 2, i, thread_num, f );
1936 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel >
1962 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel >
1986 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel >
2010 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Kernel >
2050 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2054 a[ 0 ] = 1.0; a[ 1 ] = -2.0; a[ 2 ] = 1.0;
2074 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2078 a[ 0 ] = 1.0; a[ 1 ] = -2.0; a[ 2 ] = 1.0;
2098 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2103 a( 0, 0 ) = 1.0; a( 1, 0 ) = 1.0; a( 2, 0 ) = 1.0;
2104 a( 0, 1 ) = 1.0; a( 1, 1 ) = -8.0; a( 2, 1 ) = 1.0;
2105 a( 0, 2 ) = 1.0; a( 1, 2 ) = 1.0; a( 2, 2 ) = 1.0;
2125 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2130 a( 0, 0, 0 ) = 1.0; a( 1, 0, 0 ) = 1.0; a( 2, 0, 0 ) = 1.0;
2131 a( 0, 1, 0 ) = 1.0; a( 1, 1, 0 ) = 1.0; a( 2, 1, 0 ) = 1.0;
2132 a( 0, 2, 0 ) = 1.0; a( 1, 2, 0 ) = 1.0; a( 2, 2, 0 ) = 1.0;
2133 a( 0, 0, 1 ) = 1.0; a( 1, 0, 1 ) = 1.0; a( 2, 0, 1 ) = 1.0;
2134 a( 0, 1, 1 ) = 1.0; a( 1, 1, 1 ) = -26.0; a( 2, 1, 1 ) = 1.0;
2135 a( 0, 2, 1 ) = 1.0; a( 1, 2, 1 ) = 1.0; a( 2, 2, 1 ) = 1.0;
2136 a( 0, 0, 2 ) = 1.0; a( 1, 0, 2 ) = 1.0; a( 2, 0, 2 ) = 1.0;
2137 a( 0, 1, 2 ) = 1.0; a( 1, 1, 2 ) = 1.0; a( 2, 1, 2 ) = 1.0;
2138 a( 0, 2, 2 ) = 1.0; a( 1, 2, 2 ) = 1.0; a( 2, 2, 2 ) = 1.0;
2159 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2179 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2199 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2219 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2249 struct gaussian_filter_helper
2251 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2256 __linear__::compute_gaussian_kernel( a, sigma );
2261 template <
class T,
class Allocator,
class Functor >
2266 __linear__::compute_gaussian_kernel( a, sigma );
2272 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2277 __linear__::compute_gaussian_kernel( a, sigma );
2282 template <
class T,
class Allocator,
class Functor >
2287 __linear__::compute_gaussian_kernel( a, sigma );
2295 struct gaussian_filter_helper< true >
2297 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2303 __linear__::compute_gaussian_kernel( a1, a2, a3, sigma );
2308 template <
class T,
class Allocator,
class Functor >
2314 __linear__::compute_gaussian_kernel( a1, a2, a3, sigma );
2319 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2325 __linear__::compute_gaussian_kernel( a1, a2, a3, sigma );
2330 template <
class T,
class Allocator,
class Functor >
2336 __linear__::compute_gaussian_kernel( a1, a2, a3, sigma );
2358 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2363 __linear__::compute_gaussian_kernel( a, sigma );
2384 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2389 __linear__::compute_gaussian_kernel( a, sigma );
2414 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2439 template <
class T,
class Allocator,
class Functor >
2466 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2491 template <
class T,
class Allocator,
class Functor >
2515 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2536 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2561 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2585 template <
class T,
class Allocator >
2610 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2634 template <
class T,
class Allocator >
2662 struct average_thread_helper
2664 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2677 if( thread_num == 0 )
2679 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2686 average_thread *
thread =
new average_thread[ thread_num ];
2689 for( i = 0 ; i < thread_num ; i++ )
2691 thread[ i ].setup_parameters( in, out, fw, fh, 1, i, thread_num, f );
2706 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2719 if( thread_num == 0 )
2721 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2729 average_thread *
thread =
new average_thread[ thread_num ];
2732 for( i = 0 ; i < thread_num ; i++ )
2734 thread[ i ].setup_parameters( in, out, fw, fh, fd, i, thread_num, f );
2751 struct average_thread_helper< true >
2753 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2764 typedef __linear__::_1D_average_thread< array2< T1, Allocator1 >,
array2< T2, Allocator2 >, Functor > average_thread;
2766 if( thread_num == 0 )
2768 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2775 average_thread *
thread =
new average_thread[ thread_num ];
2778 for( i = 0 ; i < thread_num ; i++ )
2780 thread[ i ].setup_parameters( in, out, fw, fh, 1, i, thread_num, f );
2795 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2806 typedef __linear__::_1D_average_thread< array3< T1, Allocator1 >,
array3< T2, Allocator2 >, Functor > average_thread;
2808 if( thread_num == 0 )
2810 thread_num =
static_cast< size_type
>(
get_cpu_num( ) );
2818 average_thread *
thread =
new average_thread[ thread_num ];
2821 for( i = 0 ; i < thread_num ; i++ )
2823 thread[ i ].setup_parameters( in, out, fw, fh, fd, i, thread_num, f );
2855 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2887 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2921 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2947 template <
class T1,
class Allocator1,
class T2,
class Allocator2,
class Functor >
2972 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
2993 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3015 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3039 template <
class T1,
class Allocator1,
class T2,
class Allocator2 >
3061 #endif // __INCLUDE_FILTER_LINEAR_FILTER__