Boost GIL


reduce.hpp
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_GIL_REDUCE_HPP
9 #define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_GIL_REDUCE_HPP
10 
11 #ifdef BOOST_GIL_DOXYGEN_ONLY
12 #undef BOOST_GIL_REDUCE_CODE_BLOAT
13 #endif
14 
15 #ifdef BOOST_GIL_REDUCE_CODE_BLOAT
16 
17 #include <boost/gil/extension/dynamic_image/dynamic_at_c.hpp>
18 
19 #include <boost/gil/metafunctions.hpp>
20 #include <boost/gil/typedefs.hpp>
21 
22 #include <boost/mpl/back.hpp>
23 #include <boost/mpl/insert.hpp>
24 #include <boost/mpl/insert_range.hpp>
25 #include <boost/mpl/long.hpp>
26 #include <boost/mpl/logical.hpp>
27 #include <boost/mpl/range_c.hpp>
28 #include <boost/mpl/vector.hpp>
29 #include <boost/mpl/vector_c.hpp>
30 #include <boost/mpl/transform.hpp>
31 
32 // Max number of cases in the cross-expension of binary operation for it to be reduced as unary
33 #define GIL_BINARY_REDUCE_LIMIT 226
34 
35 namespace boost { namespace mpl {
36 
37 // Constructs for static-to-dynamic integer convesion
38 
47 
48 template <typename SrcTypes, typename DstTypes>
49 struct mapping_vector {};
50 
51 template <typename SrcTypes, typename DstTypes, long K>
52 struct at_c<mapping_vector<SrcTypes,DstTypes>, K> {
53  static const std::size_t value=size<DstTypes>::value - order<DstTypes, typename gil::at_c<SrcTypes,K>::type>::type::value +1;
54  typedef size_t<value> type;
55 };
56 
57 template <typename SrcTypes, typename DstTypes>
58 struct size<mapping_vector<SrcTypes,DstTypes> > {
59  typedef typename size<SrcTypes>::type type;
60  static const std::size_t value=type::value;
61 };
62 
71 
72 namespace detail {
73  template <typename SFirst, std::size_t NLeft>
74  struct copy_to_vector_impl {
75  private:
76  typedef typename deref<SFirst>::type T;
77  typedef typename next<SFirst>::type next;
78  typedef typename copy_to_vector_impl<next, NLeft-1>::type rest;
79  public:
80  typedef typename push_front<rest, T>::type type;
81  };
82 
83  template <typename SFirst>
84  struct copy_to_vector_impl<SFirst,1> {
85  typedef vector<typename deref<SFirst>::type> type;
86  };
87 }
88 
89 template <typename Src>
90 struct copy_to_vector {
91  typedef typename detail::copy_to_vector_impl<typename begin<Src>::type, size<Src>::value>::type type;
92 };
93 
94 template <>
95 struct copy_to_vector<set<> > {
96  typedef vector0<> type;
97 };
98 
99 } } // boost::mpl
100 
101 namespace boost { namespace gil {
102 
103 
111 
112 
113 
114 
124 
125 template <typename Types, typename Op>
126 struct unary_reduce_impl {
127  typedef typename mpl::transform<Types, detail::reduce<Op, mpl::_1> >::type reduced_t;
128  typedef typename mpl::copy<reduced_t, mpl::inserter<mpl::set<>, mpl::insert<mpl::_1,mpl::_2> > >::type unique_t;
129  static const bool is_single=mpl::size<unique_t>::value==1;
130 };
131 
132 template <typename Types, typename Op, bool IsSingle=unary_reduce_impl<Types,Op>::is_single>
133 struct unary_reduce : public unary_reduce_impl<Types,Op> {
134  typedef typename unary_reduce_impl<Types,Op>::reduced_t reduced_t;
135  typedef typename unary_reduce_impl<Types,Op>::unique_t unique_t;
136 
137  static unsigned short inline map_index(std::size_t index) {
138  typedef typename mpl::mapping_vector<reduced_t, unique_t> indices_t;
139  return gil::at_c<indices_t, unsigned short>(index);
140  }
141  template <typename Bits> BOOST_FORCEINLINE static typename Op::result_type applyc(const Bits& bits, std::size_t index, Op op) {
142  return apply_operation_basec<unique_t>(bits,map_index(index),op);
143  }
144 
145  template <typename Bits> BOOST_FORCEINLINE static typename Op::result_type apply(Bits& bits, std::size_t index, Op op) {
146  return apply_operation_base<unique_t>(bits,map_index(index),op);
147  }
148 };
149 
150 template <typename Types, typename Op>
151 struct unary_reduce<Types,Op,true> : public unary_reduce_impl<Types,Op> {
152  typedef typename unary_reduce_impl<Types,Op>::unique_t unique_t;
153  static unsigned short inline map_index(std::size_t index) { return 0; }
154 
155  template <typename Bits> BOOST_FORCEINLINE static typename Op::result_type applyc(const Bits& bits, std::size_t index, Op op) {
156  return op(*gil_reinterpret_cast_c<const typename mpl::front<unique_t>::type*>(&bits));
157  }
158 
159  template <typename Bits> BOOST_FORCEINLINE static typename Op::result_type apply(Bits& bits, std::size_t index, Op op) {
160  return op(*gil_reinterpret_cast<typename mpl::front<unique_t>::type*>(&bits));
161  }
162 };
163 
164 
177 
178 namespace detail {
179  struct pair_generator {
180  template <typename Vec2> struct apply {
181  typedef std::pair<const typename mpl::at_c<Vec2,0>::type*, const typename mpl::at_c<Vec2,1>::type*> type;
182  };
183  };
184 
185  // When the types are not too large, applies reduce on their cross product
186  template <typename Unary1, typename Unary2, typename Op, bool IsComplex>
187  struct binary_reduce_impl {
188  //private:
189  typedef typename mpl::copy_to_vector<typename Unary1::unique_t>::type vec1_types;
190  typedef typename mpl::copy_to_vector<typename Unary2::unique_t>::type vec2_types;
191 
192  typedef mpl::cross_vector<mpl::vector2<vec1_types, vec2_types>, pair_generator> BIN_TYPES;
193  typedef unary_reduce<BIN_TYPES,Op> bin_reduced_t;
194 
195  static unsigned short inline map_index(std::size_t index1, std::size_t index2) {
196  unsigned short r1=Unary1::map_index(index1);
197  unsigned short r2=Unary2::map_index(index2);
198  return bin_reduced_t::map_index(r2*mpl::size<vec1_types>::value + r1);
199  }
200  public:
201  typedef typename bin_reduced_t::unique_t unique_t;
202 
203  template <typename Bits1, typename Bits2>
204  static typename Op::result_type inline apply(const Bits1& bits1, std::size_t index1, const Bits2& bits2, std::size_t index2, Op op) {
205  std::pair<const void*,const void*> pr(&bits1, &bits2);
206  return apply_operation_basec<unique_t>(pr, map_index(index1,index2),op);
207  }
208  };
209 
210  // When the types are large performs a double-dispatch. Binary reduction is not done.
211  template <typename Unary1, typename Unary2, typename Op>
212  struct binary_reduce_impl<Unary1,Unary2,Op,true> {
213  template <typename Bits1, typename Bits2>
214  static typename Op::result_type inline apply(const Bits1& bits1, std::size_t index1, const Bits2& bits2, std::size_t index2, Op op) {
215  return apply_operation_base<Unary1::unique_t,Unary2::unique_t>(bits1, index1, bits2, index2, op);
216  }
217  };
218 }
219 
220 
221 template <typename Types1, typename Types2, typename Op>
222 struct binary_reduce {
223 //private:
224  typedef unary_reduce<Types1,Op> unary1_t;
225  typedef unary_reduce<Types2,Op> unary2_t;
226 
227  static const std::size_t CROSS_SIZE = mpl::size<typename unary1_t::unique_t>::value *
228  mpl::size<typename unary2_t::unique_t>::value;
229 
230  typedef detail::binary_reduce_impl<unary1_t,unary2_t,Op, (CROSS_SIZE>GIL_BINARY_REDUCE_LIMIT)> impl;
231 public:
232  template <typename Bits1, typename Bits2>
233  static typename Op::result_type inline apply(const Bits1& bits1, std::size_t index1, const Bits2& bits2, std::size_t index2, Op op) {
234  return impl::apply(bits1,index1,bits2,index2,op);
235  }
236 };
237 
238 template <typename Types, typename UnaryOp>
239 BOOST_FORCEINLINE typename UnaryOp::result_type apply_operation(variant<Types>& arg, UnaryOp op) {
240  return unary_reduce<Types,UnaryOp>::template apply(arg._bits, arg._index ,op);
241 }
242 
243 template <typename Types, typename UnaryOp>
244 BOOST_FORCEINLINE typename UnaryOp::result_type apply_operation(const variant<Types>& arg, UnaryOp op) {
245  return unary_reduce<Types,UnaryOp>::template applyc(arg._bits, arg._index ,op);
246 }
247 
248 template <typename Types1, typename Types2, typename BinaryOp>
249 BOOST_FORCEINLINE typename BinaryOp::result_type apply_operation(const variant<Types1>& arg1, const variant<Types2>& arg2, BinaryOp op) {
250  return binary_reduce<Types1,Types2,BinaryOp>::template apply(arg1._bits, arg1._index, arg2._bits, arg2._index, op);
251 }
252 
253 #undef GIL_BINARY_REDUCE_LIMIT
254 
255 } } // namespace gil
256 
257 
258 namespace boost { namespace mpl {
277 
278 template <typename VecOfVecs, typename TypeGen>
279 struct cross_vector {};
280 
283 template <typename VecOfVecs, typename TypeGen, std::size_t K>
284 struct cross_iterator {
285  typedef mpl::random_access_iterator_tag category;
286 };
287 
291 
297 template <typename VecOfVecs, typename TypeGen, std::size_t K>
298 struct deref<cross_iterator<VecOfVecs,TypeGen,K> > {
299 private:
300  typedef typename detail::select_subvector_c<VecOfVecs, K>::type DerefTypes;
301 public:
302  typedef typename TypeGen::template apply<DerefTypes>::type type;
303 };
304 
307 template <typename VecOfVecs, typename TypeGen, std::size_t K>
308 struct next<cross_iterator<VecOfVecs,TypeGen,K> > {
309  typedef cross_iterator<VecOfVecs,TypeGen,K+1> type;
310 };
311 
314 template <typename VecOfVecs, typename TypeGen, std::size_t K>
315 struct prior<cross_iterator<VecOfVecs,TypeGen,K> > {
316  typedef cross_iterator<VecOfVecs,TypeGen,K-1> type;
317 };
318 
321 template <typename VecOfVecs, typename TypeGen, std::size_t K, typename Distance>
322 struct advance<cross_iterator<VecOfVecs,TypeGen,K>, Distance > {
323  typedef cross_iterator<VecOfVecs,TypeGen,K+Distance::value> type;
324 };
325 
328 // (shortened the names of the template arguments - otherwise doxygen cannot parse this...)
329 template <typename VecOfVecs, typename TypeGen, std::size_t K1, std::size_t K2>
330 struct distance<cross_iterator<VecOfVecs,TypeGen,K1>, cross_iterator<VecOfVecs,TypeGen,K2> > {
331  typedef size_t<K2-K1> type;
332 };
333 
339 template <typename VecOfVecs, typename TypeGen>
340 struct size<cross_vector<VecOfVecs,TypeGen> > {
341  typedef typename fold<VecOfVecs, size_t<1>, times<_1, size<_2> > >::type type;
342  static const std::size_t value=type::value;
343 };
344 
347 template <typename VecOfVecs, typename TypeGen>
348 struct empty<cross_vector<VecOfVecs,TypeGen> > {
349  typedef typename empty<VecOfVecs>::type type;
350 };
351 
354 template <typename VecOfVecs, typename TypeGen, typename K>
355 struct at<cross_vector<VecOfVecs,TypeGen>, K> {
356 private:
357  typedef cross_iterator<VecOfVecs,TypeGen,K::value> KthIterator;
358 public:
359  typedef typename deref<KthIterator>::type type;
360 };
361 
364 template <typename VecOfVecs, typename TypeGen>
365 struct begin<cross_vector<VecOfVecs,TypeGen> > {
366  typedef cross_iterator<VecOfVecs,TypeGen,0> type;
367 };
368 
371 template <typename VecOfVecs, typename TypeGen>
372 struct end<cross_vector<VecOfVecs,TypeGen> > {
373 private:
374  typedef cross_vector<VecOfVecs,TypeGen> this_t;
375 public:
376  typedef cross_iterator<VecOfVecs,TypeGen,size<this_t>::value> type;
377 };
378 
381 template <typename VecOfVecs, typename TypeGen>
382 struct front<cross_vector<VecOfVecs,TypeGen> > {
383 private:
384  typedef cross_vector<VecOfVecs,TypeGen> this_t;
385 public:
386  typedef typename deref<typename begin<this_t>::type>::type type;
387 };
388 
391 template <typename VecOfVecs, typename TypeGen>
392 struct back<cross_vector<VecOfVecs,TypeGen> > {
393 private:
394  typedef cross_vector<VecOfVecs,TypeGen> this_t;
395  typedef typename size<this_t>::type size;
396  typedef typename minus<size, size_t<1> >::type last_index;
397 public:
398  typedef typename at<this_t, last_index>::type type;
399 };
400 
403 template <typename VecOfVecs, typename TypeGen, typename OPP>
404 struct transform<cross_vector<VecOfVecs,TypeGen>, OPP > {
405  typedef typename lambda<OPP>::type Op;
406  struct adapter {
407  template <typename Elements>
408  struct apply {
409  typedef typename TypeGen::template apply<Elements>::type orig_t;
410  typedef typename Op::template apply<orig_t>::type type;
411  };
412  };
413  typedef cross_vector<VecOfVecs, adapter > type;
414 };
415 
416 } } // boost::mpl
417 
418 namespace boost { namespace gil {
419 
420 template <typename Types, typename T> struct type_to_index;
421 template <typename V> struct view_is_basic;
422 struct rgb_t;
423 struct lab_t;
424 struct hsb_t;
425 struct cmyk_t;
426 struct rgba_t;
427 struct error_t;
428 
429 
430 namespace detail {
436  template <typename Op, typename T>
437  struct reduce {
438  typedef T type;
439  };
440 
447 
448  template <typename Op, typename View, bool IsBasic>
449  struct reduce_view_basic {
450  typedef View type;
451  };
452 
453  template <typename Op, typename Loc>
454  struct reduce<Op, image_view<Loc> >
455  : public reduce_view_basic<Op,image_view<Loc>,view_is_basic<image_view<Loc> >::value> {};
456 
463 
464  template <typename Op, typename Img, bool IsBasic>
465  struct reduce_image_basic {
466  typedef Img type;
467  };
468 
469  template <typename Op, typename V, typename Alloc>
470  struct reduce<Op, image<V,Alloc> > : public reduce_image_basic<Op,image<V,Alloc>,image_is_basic<image<V,Alloc> >::value > {};
471 
478 
479  template <typename Op, typename V1, typename V2, bool AreBasic>
480  struct reduce_views_basic {
481  typedef std::pair<const V1*, const V2*> type;
482  };
483 
484  template <typename Op, typename L1, typename L2>
485  struct reduce<Op, std::pair<const image_view<L1>*, const image_view<L2>*> >
486  : public reduce_views_basic<Op,image_view<L1>,image_view<L2>,
487  mpl::and_<view_is_basic<image_view<L1> >, view_is_basic<image_view<L2> > >::value >
488  {};
489 
490 
496 
497  template <typename Cs>
498  struct reduce_color_space {
499  typedef Cs type;
500  };
501 
502  template <> struct reduce_color_space<lab_t> { typedef rgb_t type; };
503  template <> struct reduce_color_space<hsb_t> { typedef rgb_t type; };
504  template <> struct reduce_color_space<cmyk_t> { typedef rgba_t type; };
505 
506  /*
514 
515  template <typename Vec, int Basis, int VecSize>
516  struct type_vec_to_integer_impl {
517  typedef typename mpl::back<Vec>::type last;
518  typedef typename mpl::pop_back<Vec>::type rest;
519  static const int value = type_vec_to_integer_impl<rest, Basis, VecSize-1>::value * Basis + last::value;
520  };
521 
522  template <typename Vec, int Basis>
523  struct type_vec_to_integer_impl<Vec,Basis,0> {
524  static const int value=0;
525  };
526 
527  template <typename Vec, int Basis=10>
528  struct type_vec_to_integer {
529  static const int value = type_vec_to_integer_impl<Vec,Basis, mpl::size<Vec>::value>::value;
530  };
531 
532  // Given two color spaces and the mapping of the channels between them, returns the reduced pair of color spaces
533  // The default version performs no reduction
534  template <typename SrcColorSpace, typename DstColorSpace, int Mapping>
535  struct reduce_color_spaces_impl {
536  typedef SrcColorSpace first_t;
537  typedef DstColorSpace second_t;
538  };
539 
540  // 012: RGB-RGB, bgr-bgr, lab-lab, hsb-hsb
541  template <typename SrcColorSpace, typename DstColorSpace>
542  struct reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,12> {
543  typedef rgb_t first_t;
544  typedef rgb_t second_t;
545  };
546 
547  // 210: RGB-bgr, bgr-RGB
548  template <typename SrcColorSpace, typename DstColorSpace>
549  struct reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,210> {
550  typedef rgb_t first_t;
551  typedef bgr_t second_t;
552  };
553 
554  // 0123: RGBA-RGBA, bgra-bgra, argb-argb, abgr-abgr cmyk-cmyk
555  template <typename SrcColorSpace, typename DstColorSpace>
556  struct reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,123> {
557  typedef rgba_t first_t;
558  typedef rgba_t second_t;
559  };
560 
561  // 3210: RGBA-abgr, bgra-argb, argb-bgra, abgr-RGBA
562  template <typename SrcColorSpace, typename DstColorSpace>
563  struct reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,3210> {
564  typedef rgba_t first_t;
565  typedef abgr_t second_t;
566  };
567 
568  // 1230: RGBA-argb, bgra-abgr
569  template <typename SrcColorSpace, typename DstColorSpace>
570  struct reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,1230> {
571  typedef rgba_t first_t;
572  typedef argb_t second_t;
573  };
574 
575  // 2103: RGBA-bgra, bgra-RGBA (uses subclass to ensure that base color space is not reduced to derived)
576  template <typename SrcColorSpace, typename DstColorSpace>
577  struct reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,2103> {
578  typedef rgba_t first_t;
579  typedef bgra_t second_t;
580  };
581 
582  // 3012: argb-RGBA, abgr-bgra
583  template <typename SrcColorSpace, typename DstColorSpace>
584  struct reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,3012> {
585  typedef argb_t first_t;
586  typedef rgba_t second_t;
587  };
588 
589  // 0321: argb-abgr, abgr-argb
590  template <typename SrcColorSpace, typename DstColorSpace>
591  struct reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,321> {
592  typedef argb_t first_t;
593  typedef abgr_t second_t;
594  };
595 
596  template <typename SrcColorSpace, typename DstColorSpace>
597  struct reduce_color_spaces {
598  typedef typename channel_order<SrcColorSpace>::type src_order_t;
599  typedef typename channel_order<DstColorSpace>::type dst_order_t;
600  typedef typename mpl::transform<src_order_t, type_to_index<dst_order_t,mpl::_1> >::type mapping;
601  static const int mapping_val = type_vec_to_integer<mapping>::value;
602 
603  typedef typename reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,mapping_val>::first_t _first_t;
604  typedef typename reduce_color_spaces_impl<SrcColorSpace,DstColorSpace,mapping_val>::second_t _second_t;
605  typedef typename mpl::and_<color_space_is_base<DstColorSpace>, mpl::not_< color_space_is_base<_second_t> > > swap_t;
606  public:
607  typedef typename mpl::if_<swap_t, _second_t, _first_t>::type first_t;
608  typedef typename mpl::if_<swap_t, _first_t, _second_t>::type second_t;
609  };
610 */
611 // TODO: Use the old code for reduce_color_spaces above to do color layout reduction
612  template <typename SrcLayout, typename DstLayout>
613  struct reduce_color_layouts {
614  typedef SrcLayout first_t;
615  typedef DstLayout second_t;
616  };
617 
623 
624  struct copy_pixels_fn;
625 
626  /*
627  // 1D reduce for copy_pixels reduces the channel to mutable and the color space to its base with same dimensions
628  template <typename View>
629  struct reduce_view_basic<copy_pixels_fn,View,true> {
630  private:
631  typedef typename reduce_color_space<typename View::color_space_t>::type Cs; // reduce the color space
632  typedef layout<Cs, typename View::channel_mapping_t> layout_t;
633  public:
634  typedef typename derived_view_type<View, use_default, layout_t, use_default, use_default, mpl::true_>::type type;
635  };
636 */
637  // Incompatible views cannot be used in copy_pixels - will throw std::bad_cast
638  template <typename V1, typename V2, bool Compatible>
639  struct reduce_copy_pixop_compat {
640  typedef error_t type;
641  };
642 
643  // For compatible basic views, reduce their color spaces based on their channel mapping.
644  // Make the source immutable and the destination mutable (they should already be that way)
645  template <typename V1, typename V2>
646  struct reduce_copy_pixop_compat<V1,V2,true> {
647  typedef layout<typename V1::color_space_t, typename V1::channel_mapping_t> layout1;
648  typedef layout<typename V2::color_space_t, typename V2::channel_mapping_t> layout2;
649 
650  typedef typename reduce_color_layouts<layout1,layout2>::first_t L1;
651  typedef typename reduce_color_layouts<layout1,layout2>::second_t L2;
652 
653  typedef typename derived_view_type<V1, use_default, L1, use_default, use_default, use_default, mpl::false_>::type DV1;
654  typedef typename derived_view_type<V2, use_default, L2, use_default, use_default, use_default, mpl::true_ >::type DV2;
655 
656  typedef std::pair<const DV1*, const DV2*> type;
657  };
658 
659  // The general 2D version branches into compatible and incompatible views
660  template <typename V1, typename V2>
661  struct reduce_views_basic<copy_pixels_fn, V1, V2, true>
662  : public reduce_copy_pixop_compat<V1, V2, mpl::and_<views_are_compatible<V1,V2>, view_is_mutable<V2> >::value > {
663  };
664 
670 
671  struct destructor_op;
672  template <typename View> struct reduce_view_basic<destructor_op,View,true> { typedef gray8_view_t type; };
673 
679 
680  struct any_type_get_dimensions;
681  template <typename View> struct reduce_view_basic<any_type_get_dimensions,View,true> { typedef gray8_view_t type; };
682  template <typename Img> struct reduce_image_basic<any_type_get_dimensions,Img,true> { typedef gray8_image_t type; };
683 
689 
690  struct any_type_get_num_channels;
691  template <typename View> struct reduce_view_basic<any_type_get_num_channels,View,true> {
692  typedef typename View::color_space_t::base Cs;
693  typedef typename view_type<uint8_t,typename reduce_color_space<Cs>::type>::type type;
694  };
695  template <typename Img> struct reduce_image_basic<any_type_get_num_channels,Img,true> {
696  typedef typename Img::color_space_t::base Cs;
697  typedef typename image_type<uint8_t,typename reduce_color_space<Cs>::type>::type type;
698  };
699 
705 
706  template <typename Sampler, typename MapFn> struct resample_pixels_fn;
707 
708  template <typename S, typename M, typename V, bool IsBasic>
709  struct reduce_view_basic<resample_pixels_fn<S,M>, V, IsBasic> : public reduce_view_basic<copy_pixels_fn, V, IsBasic> {};
710 
711  template <typename S, typename M, typename V1, typename V2, bool IsBasic>
712  struct reduce_views_basic<resample_pixels_fn<S,M>, V1, V2, IsBasic> : public reduce_views_basic<copy_pixels_fn, V1, V2, IsBasic> {};
713 
720 
721 
722  template <typename CC> class copy_and_convert_pixels_fn;
723 
724  // the only thing for 1D reduce is making them all mutable...
725  template <typename CC, typename View, bool IsBasic>
726  struct reduce_view_basic<copy_and_convert_pixels_fn<CC>, View, IsBasic>
727  : public derived_view_type<View, use_default, use_default, use_default, use_default, mpl::true_> {
728  };
729 
730  // For 2D reduce, if they have the same channels and color spaces (i.e. the same pixels) then copy_and_convert is just copy.
731  // In this case, reduce their common color space. In general make the first immutable and the second mutable
732  template <typename CC, typename V1, typename V2, bool AreBasic>
733  struct reduce_views_basic<copy_and_convert_pixels_fn<CC>, V1, V2, AreBasic> {
734  typedef is_same<typename V1::pixel_t, typename V2::pixel_t> Same;
735 
736  typedef reduce_color_space<typename V1::color_space_t::base> CsR;
737  typedef typename mpl::if_<Same, typename CsR::type, typename V1::color_space_t>::type Cs1;
738  typedef typename mpl::if_<Same, typename CsR::type, typename V2::color_space_t>::type Cs2;
739 
740  typedef typename derived_view_type<V1, use_default, layout<Cs1, typename V1::channel_mapping_t>, use_default, use_default, mpl::false_>::type DV1;
741  typedef typename derived_view_type<V2, use_default, layout<Cs2, typename V2::channel_mapping_t>, use_default, use_default, mpl::true_ >::type DV2;
742 
743  typedef std::pair<const DV1*, const DV2*> type;
744  };
745 
746 
747  //integral_image_generator
748  //resize_clobber_image_fnobj
749  //image_default_construct_fnobj
750  //fill_converted_pixels_fn
751  //bind(gil::detail::copy_pixels_fn(), _1, dst)
752  //bind(gil::detail::copy_pixels_fn(), src,_1)
753 
754  //bind(detail::copy_and_convert_pixels_fn(), _1, dst)
755  //bind(detail::copy_and_convert_pixels_fn(), src, _1)
756  //gil::detail::fill_pixels_fn<Value>(val)
757 
758  //detail::copy_construct_in_place_fn<base_t>
759  //detail::equal_to_fn<typename variant<Types>::base_t>
760 
761  //detail::any_image_get_view<typename any_image<Types>::view_t>
762  //detail::any_image_get_const_view<typename any_image<Types>::view_t>
763  //detail::flipped_up_down_view_fn<any_image_view<ViewTypes> >
764  //detail::flipped_left_right_view_fn<typename any_image_view<ViewTypes>::dynamic_step_t>
765  //detail::tranposed_view_fn<typename any_image_view<ViewTypes>::dynamic_step_t>
766  //detail::rotated90cw_view_fn<typename any_image_view<ViewTypes>::dynamic_step_t>
767  //detail::rotated90ccw_view_fn<typename any_image_view<ViewTypes>::dynamic_step_t>
768  //detail::rotated180_view_fn<typename any_image_view<ViewTypes>::dynamic_step_t>
769  //detail::subimage_view_fn<any_image_view<ViewTypes> >
770  //detail::subsampled_view_fn<typename any_image_view<ViewTypes>::dynamic_step_t>
771  //detail::nth_channel_view_fn<typename nth_channel_view_type<any_image_view<ViewTypes> >
772  //detail::color_converted_view_fn<DstP,typename color_convert_view_type<any_image_view<ViewTypes>, DstP>::type >
773 }
774 
775 }} // namespace boost::gil
776 
777 #endif // defined(BOOST_GIL_REDUCE_CODE_BLOAT)
778 
779 #endif
add_reference< E >::type at_c(detail::homogeneous_color_base< E, L, N > &p)
Provides mutable access to the K-th element, in physical order.
Definition: color_base.hpp:381
BOOST_FORCEINLINE UnaryOp::result_type apply_operation(variant< Types > &arg, UnaryOp op)
Invokes a generic mutable operation (represented as a unary function object) on a variant...
Definition: apply_operation.hpp:31