37 #ifndef VIGRA_RGBVALUE_HXX
38 #define VIGRA_RGBVALUE_HXX
43 #include "numerictraits.hxx"
44 #include "accessor.hxx"
45 #include "tinyvector.hxx"
46 #include "static_assert.hxx"
52 template <
unsigned int I,
unsigned int R,
unsigned int G,
unsigned int B>
53 struct SelectColorIndexRHS;
55 template <
unsigned int R,
unsigned int G,
unsigned int B>
56 struct SelectColorIndexRHS<0, R, G, B>
61 template <
unsigned int R,
unsigned int G,
unsigned int B>
62 struct SelectColorIndexRHS<1, R, G, B>
67 template <
unsigned int R,
unsigned int G,
unsigned int B>
68 struct SelectColorIndexRHS<2, R, G, B>
77 template <
unsigned int R,
unsigned int G,
unsigned int B>
78 struct RGBValue_bad_color_indices
79 : staticAssert::AssertBool<(R < 3 && G < 3 && B < 3 &&
80 ((1 << R) + (1 << G) + (1 << B) == 7))>
125 template <class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
127 : public TinyVector<VALUETYPE, 3>
129 typedef TinyVector<VALUETYPE, 3> Base;
133 IDX0 = (RED_IDX == 0) ? 0 : (GREEN_IDX == 0) ? 1 : 2,
134 IDX1 = (RED_IDX == 1) ? 0 : (GREEN_IDX == 1) ? 1 : 2,
135 IDX2 = (RED_IDX == 2) ? 0 : (GREEN_IDX == 2) ? 1 : 2
141 typedef typename Base::value_type value_type;
144 typedef typename Base::iterator iterator;
147 typedef typename Base::const_iterator const_iterator;
150 typedef typename Base::SquaredNormType SquaredNormType;
153 typedef typename Base::NormType NormType;
155 typedef typename Base::reference reference;
156 typedef typename Base::const_reference const_reference;
157 typedef typename Base::pointer pointer;
158 typedef typename Base::const_pointer const_pointer;
159 typedef typename Base::size_type size_type;
160 typedef typename Base::difference_type difference_type;
161 typedef typename Base::scalar_multiplier scalar_multiplier;
162 typedef typename Base::ReverseCopyTag ReverseCopyTag;
169 GreenIdx = GREEN_IDX,
177 RGBValue(value_type first, value_type second, value_type third)
178 : Base(first, second, third)
180 VIGRA_STATIC_ASSERT((RGBValue_bad_color_indices<RED_IDX, GREEN_IDX, BLUE_IDX>));
185 RGBValue(value_type gray)
186 : Base(gray, gray, gray)
188 VIGRA_STATIC_ASSERT((RGBValue_bad_color_indices<RED_IDX, GREEN_IDX, BLUE_IDX>));
194 explicit RGBValue(const_pointer i)
197 VIGRA_STATIC_ASSERT((RGBValue_bad_color_indices<RED_IDX, GREEN_IDX, BLUE_IDX>));
202 RGBValue(const_pointer i, ReverseCopyTag reverse)
205 VIGRA_STATIC_ASSERT((RGBValue_bad_color_indices<RED_IDX, GREEN_IDX, BLUE_IDX>));
213 VIGRA_STATIC_ASSERT((RGBValue_bad_color_indices<RED_IDX, GREEN_IDX, BLUE_IDX>));
216 #if !defined(TEMPLATE_COPY_CONSTRUCTOR_BUG)
218 RGBValue(RGBValue const & r)
219 : Base((Base const &)r)
221 VIGRA_STATIC_ASSERT((RGBValue_bad_color_indices<RED_IDX, GREEN_IDX, BLUE_IDX>));
224 RGBValue & operator=(RGBValue const & r)
234 template <class U, unsigned int R, unsigned int G, unsigned int B>
235 RGBValue(RGBValue<U, R, G, B> const & r)
236 : Base(detail::RequiresExplicitCast<value_type>::cast(r[detail::SelectColorIndexRHS<IDX0, R, G, B>::res]),
237 detail::RequiresExplicitCast<value_type>::cast(r[detail::SelectColorIndexRHS<IDX1, R, G, B>::res]),
238 detail::RequiresExplicitCast<value_type>::cast(r[detail::SelectColorIndexRHS<IDX2, R, G, B>::res]))
240 VIGRA_STATIC_ASSERT((RGBValue_bad_color_indices<RED_IDX, GREEN_IDX, BLUE_IDX>));
245 template <class U, unsigned int R, unsigned int G, unsigned int B>
246 RGBValue & operator=(RGBValue<U, R, G, B> const & r)
248 setRed(detail::RequiresExplicitCast<value_type>::cast(r.red()));
249 setGreen(detail::RequiresExplicitCast<value_type>::cast(r.green()));
250 setBlue(detail::RequiresExplicitCast<value_type>::cast(r.blue()));
256 RGBValue(TinyVector<value_type, 3> const & r)
259 VIGRA_STATIC_ASSERT((RGBValue_bad_color_indices<RED_IDX, GREEN_IDX, BLUE_IDX>));
264 RGBValue & operator=(TinyVector<value_type, 3> const & r)
272 RGBValue operator-() const
274 return RGBValue(-(*this)[0], -(*this)[1], -(*this)[2]);
279 value_type & red() { return (*this)[RED_IDX]; }
283 value_type & green() { return (*this)[GREEN_IDX]; }
287 value_type & blue() { return (*this)[BLUE_IDX]; }
291 value_type const & red() const { return (*this)[RED_IDX]; }
295 value_type const & green() const { return (*this)[GREEN_IDX]; }
299 value_type const & blue() const { return (*this)[BLUE_IDX]; }
303 value_type luminance() const {
304 return detail::RequiresExplicitCast<value_type>::cast(0.3*red() + 0.59*green() + 0.11*blue()); }
308 NormType magnitude() const {
309 return Base::magnitude();
314 SquaredNormType squaredMagnitude() const {
315 return Base::squaredMagnitude();
322 void setRed(V value) { (*this)[RED_IDX] = detail::RequiresExplicitCast<value_type>::cast(value); }
328 void setGreen(V value) { (*this)[GREEN_IDX] = detail::RequiresExplicitCast<value_type>::cast(value); }
334 void setBlue(V value) { (*this)[BLUE_IDX] = detail::RequiresExplicitCast<value_type>::cast(value); }
338 void setRGB(V r, V g, V b)
340 (*this)[RED_IDX] = detail::RequiresExplicitCast<value_type>::cast(r);
341 (*this)[GREEN_IDX] = detail::RequiresExplicitCast<value_type>::cast(g);
342 (*this)[BLUE_IDX] = detail::RequiresExplicitCast<value_type>::cast(b);
366 template <class V1, unsigned int RIDX1, unsigned int GIDX1, unsigned int BIDX1,
367 class V2, unsigned int RIDX2, unsigned int GIDX2, unsigned int BIDX2>
370 operator==(RGBValue<V1, RIDX1, GIDX1, BIDX1> const & l,
371 RGBValue<V2, RIDX2, GIDX2, BIDX2> const & r)
373 return (l.red() == r.red()) &&
374 (l.green() == r.green()) &&
375 (l.blue() == r.blue());
379 template <class V1, unsigned int RIDX1, unsigned int GIDX1, unsigned int BIDX1,
380 class V2, unsigned int RIDX2, unsigned int GIDX2, unsigned int BIDX2>
383 operator!=(RGBValue<V1, RIDX1, GIDX1, BIDX1> const & l,
384 RGBValue<V2, RIDX2, GIDX2, BIDX2> const & r)
386 return (l.red() != r.red()) ||
387 (l.green() != r.green()) ||
388 (l.blue() != r.blue());
457 #if !defined(NO_PARTIAL_TEMPLATE_SPECIALIZATION)
459 template <class T, unsigned int R, unsigned int G, unsigned int B>
460 struct NumericTraits<RGBValue<T, R, G, B> >
462 typedef RGBValue<T, R, G, B> Type;
463 typedef RGBValue<typename NumericTraits<T>::Promote, R, G, B> Promote;
464 typedef RGBValue<typename NumericTraits<T>::RealPromote, R, G, B> RealPromote;
465 typedef RGBValue<typename NumericTraits<T>::ComplexPromote, R, G, B> ComplexPromote;
468 typedef typename NumericTraits<T>::isIntegral isIntegral;
469 typedef VigraFalseType isScalar;
470 typedef typename NumericTraits<T>::isSigned isSigned;
471 typedef VigraFalseType isOrdered;
472 typedef VigraFalseType isComplex;
475 return Type(NumericTraits<T>::zero());
478 return Type(NumericTraits<T>::one());
480 static Type nonZero() {
481 return Type(NumericTraits<T>::nonZero());
484 static Promote toPromote(Type const & v) {
487 static RealPromote toRealPromote(Type const & v) {
488 return RealPromote(v);
490 static Type fromPromote(Promote const & v) {
491 return Type(NumericTraits<T>::fromPromote(v.red()),
492 NumericTraits<T>::fromPromote(v.green()),
493 NumericTraits<T>::fromPromote(v.blue()));
495 static Type fromRealPromote(RealPromote const & v) {
496 return Type(NumericTraits<T>::fromRealPromote(v.red()),
497 NumericTraits<T>::fromRealPromote(v.green()),
498 NumericTraits<T>::fromRealPromote(v.blue()));
502 template <class T, unsigned int R, unsigned int G, unsigned int B>
503 struct NormTraits<RGBValue<T, R, G, B> >
505 typedef RGBValue<T, R, G, B> Type;
506 typedef typename Type::SquaredNormType SquaredNormType;
507 typedef typename Type::NormType NormType;
510 template <class T1, unsigned int R, unsigned int G, unsigned int B, class T2>
511 struct PromoteTraits<RGBValue<T1, R, G, B>, RGBValue<T2, R, G, B> >
513 typedef RGBValue<typename PromoteTraits<T1, T2>::Promote, R, G, B> Promote;
516 template <class T, unsigned int R, unsigned int G, unsigned int B>
517 struct PromoteTraits<RGBValue<T, R, G, B>, double >
519 typedef RGBValue<typename NumericTraits<T>::RealPromote, R, G, B> Promote;
522 template <class T, unsigned int R, unsigned int G, unsigned int B>
523 struct PromoteTraits<double, RGBValue<T, R, G, B> >
525 typedef RGBValue<typename NumericTraits<T>::RealPromote, R, G, B> Promote;
528 template<class T, unsigned int R, unsigned int G, unsigned int B>
529 struct CanSkipInitialization<RGBValue<T, R, G, B> >
531 typedef typename CanSkipInitialization<T>::type type;
532 static const bool value = type::asBool;
538 #define RGBVALUE_NUMTRAITS(T) \
540 struct NumericTraits<RGBValue<T, 0, 1, 2> >\
542 typedef RGBValue<T> Type; \
543 typedef RGBValue<NumericTraits<T>::Promote> Promote; \
544 typedef RGBValue<NumericTraits<T>::RealPromote> RealPromote; \
545 typedef RGBValue<NumericTraits<T>::ComplexPromote> ComplexPromote; \
546 typedef T ValueType; \
548 typedef NumericTraits<T>::isIntegral isIntegral; \
549 typedef VigraFalseType isScalar; \
550 typedef NumericTraits<T>::isSigned isSigned; \
551 typedef VigraFalseType isOrdered; \
552 typedef VigraFalseType isComplex; \
554 static RGBValue<T> zero() { \
555 return RGBValue<T>(NumericTraits<T>::zero()); \
557 static RGBValue<T> one() { \
558 return RGBValue<T>(NumericTraits<T>::one()); \
560 static RGBValue<T> nonZero() { \
561 return RGBValue<T>(NumericTraits<T>::nonZero()); \
564 static Promote toPromote(RGBValue<T> const & v) { \
567 static RealPromote toRealPromote(RGBValue<T> const & v) { \
568 return RealPromote(v); \
570 static RGBValue<T> fromPromote(Promote const & v) { \
572 RGBValue<T>::iterator d = res.begin();\
573 Promote::const_iterator s = v.begin();\
574 for(; d != res.end(); ++d, ++s)\
575 *d = NumericTraits<T>::fromPromote(*s);\
578 static RGBValue<T> fromRealPromote(RealPromote const & v) {\
580 RGBValue<T>::iterator d = res.begin();\
581 RealPromote::const_iterator s = v.begin();\
582 for(; d != res.end(); ++d, ++s)\
583 *d = NumericTraits<T>::fromRealPromote(*s);\
588 struct NormTraits<RGBValue<T, 0, 1, 2> >\
590 typedef RGBValue<T> Type;\
591 typedef Type::SquaredNormType SquaredNormType; \
592 typedef Type::NormType NormType; \
595 #define RGBVALUE_PROMTRAITS1(type1) \
597 struct PromoteTraits<RGBValue<type1, 0, 1, 2>, RGBValue<type1, 0, 1, 2> > \
599 typedef RGBValue<PromoteTraits<type1, type1>::Promote> Promote; \
600 static Promote toPromote(RGBValue<type1> const & v) { \
601 return static_cast<Promote>(v); } \
604 struct PromoteTraits<RGBValue<type1, 0, 1, 2>, double > \
606 typedef RGBValue<typename NumericTraits<type1>::RealPromote> Promote; \
609 struct PromoteTraits<double, RGBValue<type1, 0, 1, 2> > \
611 typedef RGBValue<typename NumericTraits<type1>::RealPromote> Promote; \
614 #define RGBVALUE_PROMTRAITS2(type1, type2) \
616 struct PromoteTraits<RGBValue<type1, 0, 1, 2>, RGBValue<type2, 0, 1, 2> > \
618 typedef RGBValue<PromoteTraits<type1, type2>::Promote> Promote; \
619 static Promote toPromote(RGBValue<type1> const & v) { \
620 return static_cast<Promote>(v); } \
621 static Promote toPromote(RGBValue<type2> const & v) { \
622 return static_cast<Promote>(v); } \
625 RGBVALUE_NUMTRAITS(unsigned char)
626 RGBVALUE_NUMTRAITS(int)
627 RGBVALUE_NUMTRAITS(float)
628 RGBVALUE_NUMTRAITS(double)
629 RGBVALUE_PROMTRAITS1(unsigned char)
630 RGBVALUE_PROMTRAITS1(int)
631 RGBVALUE_PROMTRAITS1(float)
632 RGBVALUE_PROMTRAITS1(double)
633 RGBVALUE_PROMTRAITS2(float, unsigned char)
634 RGBVALUE_PROMTRAITS2(unsigned char, float)
635 RGBVALUE_PROMTRAITS2(int, unsigned char)
636 RGBVALUE_PROMTRAITS2(unsigned char, int)
637 RGBVALUE_PROMTRAITS2(int, float)
638 RGBVALUE_PROMTRAITS2(float, int)
639 RGBVALUE_PROMTRAITS2(double, unsigned char)
640 RGBVALUE_PROMTRAITS2(unsigned char, double)
641 RGBVALUE_PROMTRAITS2(int, double)
642 RGBVALUE_PROMTRAITS2(double, int)
643 RGBVALUE_PROMTRAITS2(double, float)
644 RGBVALUE_PROMTRAITS2(float, double)
646 #undef RGBVALUE_NUMTRAITS
647 #undef RGBVALUE_PROMTRAITS1
648 #undef RGBVALUE_PROMTRAITS2
663 template <class V1, unsigned int RIDX1, unsigned int GIDX1, unsigned int BIDX1,
664 class V2, unsigned int RIDX2, unsigned int GIDX2, unsigned int BIDX2>
666 RGBValue<V1, RIDX1, GIDX1, BIDX1> &
667 operator+=(RGBValue<V1, RIDX1, GIDX1, BIDX1> & l,
668 RGBValue<V2, RIDX2, GIDX2, BIDX2> const & r)
671 l.green() += r.green();
672 l.blue() += r.blue();
677 template <class V1, unsigned int RIDX1, unsigned int GIDX1, unsigned int BIDX1,
678 class V2, unsigned int RIDX2, unsigned int GIDX2, unsigned int BIDX2>
680 RGBValue<V1, RIDX1, GIDX1, BIDX1> &
681 operator-=(RGBValue<V1, RIDX1, GIDX1, BIDX1> & l,
682 RGBValue<V2, RIDX2, GIDX2, BIDX2> const & r)
685 l.green() -= r.green();
686 l.blue() -= r.blue();
691 template <class V1, unsigned int RIDX1, unsigned int GIDX1, unsigned int BIDX1,
692 class V2, unsigned int RIDX2, unsigned int GIDX2, unsigned int BIDX2>
694 RGBValue<V1, RIDX1, GIDX1, BIDX1> &
695 operator*=(RGBValue<V1, RIDX1, GIDX1, BIDX1> & l,
696 RGBValue<V2, RIDX2, GIDX2, BIDX2> const & r)
698 l.red() = V1(l.red() * r.red());
699 l.green() = V1(l.green() * r.green());
700 l.blue() = V1(l.blue() * r.blue());
705 template <class V, unsigned int RIDX, unsigned int GIDX, unsigned int BIDX>
707 RGBValue<V, RIDX, GIDX, BIDX> &
708 operator*=(RGBValue<V, RIDX, GIDX, BIDX> & l, double r)
710 l.red() = V(l.red() * r);
711 l.green() = V(l.green() * r);
712 l.blue() = V(l.blue() * r);
717 template <class V1, unsigned int RIDX1, unsigned int GIDX1, unsigned int BIDX1,
718 class V2, unsigned int RIDX2, unsigned int GIDX2, unsigned int BIDX2>
720 RGBValue<V1, RIDX1, GIDX1, BIDX1> &
721 operator/=(RGBValue<V1, RIDX1, GIDX1, BIDX1> & l,
722 RGBValue<V2, RIDX2, GIDX2, BIDX2> const & r)
724 l.red() = V1(l.red() / r.red());
725 l.green() = V1(l.green() / r.green());
726 l.blue() = V1(l.blue() / r.blue());
731 template <class V, unsigned int RIDX, unsigned int GIDX, unsigned int BIDX>
733 RGBValue<V, RIDX, GIDX, BIDX> &
734 operator/=(RGBValue<V, RIDX, GIDX, BIDX> & l, double r)
736 l.red() = V(l.red() / r);
737 l.green() = V(l.green() / r);
738 l.blue() = V(l.blue() / r);
742 using VIGRA_CSTD::abs;
745 template <class T, unsigned int RIDX, unsigned int GIDX, unsigned int BIDX>
747 RGBValue<T, RIDX, GIDX, BIDX>
748 abs(RGBValue<T, RIDX, GIDX, BIDX> const & v)
750 return RGBValue<T, RIDX, GIDX, BIDX>(abs(v.red()), abs(v.green()), abs(v.blue()));
754 template <class V1, unsigned int R, unsigned int G, unsigned int B, class V2>
756 typename PromoteTraits<RGBValue<V1, R, G, B>,
757 RGBValue<V2, R, G, B> >::Promote
758 operator+(RGBValue<V1, R, G, B> const & r1,
759 RGBValue<V2, R, G, B> const & r2)
761 typename PromoteTraits<RGBValue<V1, R, G, B>,
762 RGBValue<V2, R, G, B> >::Promote res(r1);
770 template <class V1, unsigned int R, unsigned int G, unsigned int B, class V2>
772 typename PromoteTraits<RGBValue<V1, R, G, B>,
773 RGBValue<V2, R, G, B> >::Promote
774 operator-(RGBValue<V1, R, G, B> const & r1,
775 RGBValue<V2, R, G, B> const & r2)
777 typename PromoteTraits<RGBValue<V1, R, G, B>,
778 RGBValue<V2, R, G, B> >::Promote res(r1);
786 template <class V1, unsigned int R, unsigned int G, unsigned int B, class V2>
788 typename PromoteTraits<RGBValue<V1, R, G, B>,
789 RGBValue<V2, R, G, B> >::Promote
790 operator*(RGBValue<V1, R, G, B> const & r1,
791 RGBValue<V2, R, G, B> const & r2)
793 typename PromoteTraits<RGBValue<V1, R, G, B>,
794 RGBValue<V2, R, G, B> >::Promote res(r1);
802 template <class V, unsigned int R, unsigned int G, unsigned int B>
804 typename NumericTraits<RGBValue<V, R, G, B> >::RealPromote
805 operator*(double v, RGBValue<V, R, G, B> const & r)
807 typename NumericTraits<RGBValue<V, R, G, B> >::RealPromote res(r);
815 template <class V, unsigned int R, unsigned int G, unsigned int B>
817 typename NumericTraits<RGBValue<V, R, G, B> >::RealPromote
818 operator*(RGBValue<V, R, G, B> const & r, double v)
820 typename NumericTraits<RGBValue<V, R, G, B> >::RealPromote res(r);
828 template <class V1, unsigned int R, unsigned int G, unsigned int B, class V2>
830 typename PromoteTraits<RGBValue<V1, R, G, B>,
831 RGBValue<V2, R, G, B> >::Promote
832 operator/(RGBValue<V1, R, G, B> const & r1,
833 RGBValue<V2, R, G, B> const & r2)
835 typename PromoteTraits<RGBValue<V1, R, G, B>,
836 RGBValue<V2, R, G, B> >::Promote res(r1);
844 template <class V, unsigned int R, unsigned int G, unsigned int B>
846 typename NumericTraits<RGBValue<V, R, G, B> >::RealPromote
847 operator/(RGBValue<V, R, G, B> const & r, double v)
849 typename NumericTraits<RGBValue<V, R, G, B> >::RealPromote res(r);
857 template <class V1, unsigned int R, unsigned int G, unsigned int B, class V2>
859 typename PromoteTraits<RGBValue<V1, R, G, B>,
860 RGBValue<V2, R, G, B> >::Promote
861 cross(RGBValue<V1, R, G, B> const & r1,
862 RGBValue<V2, R, G, B> const & r2)
864 typedef typename PromoteTraits<RGBValue<V1, R, G, B>,
865 RGBValue<V2, R, G, B> >::Promote
868 return Res(r1.green()*r2.blue() - r1.blue()*r2.green(),
869 r1.blue()*r2.red() - r1.red()*r2.blue(),
870 r1.red()*r2.green() - r1.green()*r2.red());
874 template <class V1, unsigned int RIDX1, unsigned int GIDX1, unsigned int BIDX1,
875 class V2, unsigned int RIDX2, unsigned int GIDX2, unsigned int BIDX2>
877 typename PromoteTraits<V1, V2>::Promote
878 dot(RGBValue<V1, RIDX1, GIDX1, BIDX1> const & r1,
879 RGBValue<V2, RIDX2, GIDX2, BIDX2> const & r2)
881 return r1.red()*r2.red() + r1.green()*r2.green() + r1.blue()*r2.blue();
884 using VIGRA_CSTD::ceil;
888 template <class V, unsigned int RIDX, unsigned int GIDX, unsigned int BIDX>
890 RGBValue<V, RIDX, GIDX, BIDX>
891 ceil(RGBValue<V, RIDX, GIDX, BIDX> const & r)
893 return RGBValue<V, RIDX, GIDX, BIDX>(ceil(r.red()),
898 using VIGRA_CSTD::floor;
902 template <class V, unsigned int RIDX, unsigned int GIDX, unsigned int BIDX>
904 RGBValue<V, RIDX, GIDX, BIDX>
905 floor(RGBValue<V, RIDX, GIDX, BIDX> const & r)
907 return RGBValue<V, RIDX, GIDX, BIDX>(floor(r.red()),
930 template <class RGBVALUE>
932 : public VectorAccessor<RGBVALUE>
936 typedef typename RGBVALUE::value_type component_type;
940 template <class RGBIterator>
941 component_type const & red(RGBIterator const & rgb) const
946 template <class V, class RGBIterator>
947 void setRGB(V r, V g, V b, RGBIterator const & rgb) const
949 (*rgb).setRGB( r, g, b );
956 template <class V, class RGBIterator>
957 void setRed(V value, RGBIterator const & rgb) const
959 (*rgb).setRed(value);
964 template <class RGBIterator, class DIFFERENCE>
965 component_type const & red(RGBIterator const & rgb, DIFFERENCE diff) const
967 return rgb[diff].red();
973 template <class V, class RGBIterator, class DIFFERENCE>
974 void setRed(V value, RGBIterator const & rgb, DIFFERENCE diff) const
976 rgb[diff].setRed(value);
981 template <class RGBIterator>
982 component_type const & green(RGBIterator const & rgb) const
984 return (*rgb).green();
990 template <class V, class RGBIterator>
991 void setGreen(V value, RGBIterator const & rgb) const
993 (*rgb).setGreen(value);
998 template <class RGBIterator, class DIFFERENCE>
999 component_type const & green(RGBIterator const & rgb, DIFFERENCE d) const
1001 return rgb[d].green();
1007 template <class V, class RGBIterator, class DIFFERENCE>
1008 void setGreen(V value, RGBIterator const & rgb, DIFFERENCE d) const
1010 rgb[d].setGreen(value);
1015 template <class RGBIterator>
1016 component_type const & blue(RGBIterator const & rgb) const
1018 return (*rgb).blue();
1024 template <class V, class RGBIterator>
1025 void setBlue(V value, RGBIterator const & rgb) const
1027 (*rgb).setBlue(value);
1032 template <class RGBIterator, class DIFFERENCE>
1033 component_type const & blue(RGBIterator const & rgb, DIFFERENCE d) const
1035 return rgb[d].blue();
1041 template <class V, class RGBIterator, class DIFFERENCE>
1042 void setBlue(V value, RGBIterator const & rgb, DIFFERENCE d) const
1044 rgb[d].setBlue(value);
1061 template <class RGBVALUE>
1065 typedef typename RGBVALUE::value_type value_type;
1069 template <class ITERATOR>
1070 value_type const & operator()(ITERATOR const & i) const {
1076 template <class ITERATOR, class DIFFERENCE>
1077 value_type const & operator()(ITERATOR const & i, DIFFERENCE d) const
1085 template <class V, class ITERATOR>
1086 void set(V value, ITERATOR const & i) const {
1094 template <class V, class ITERATOR, class DIFFERENCE>
1095 void set(V value, ITERATOR const & i, DIFFERENCE d) const
1112 template <class RGBVALUE>
1116 typedef typename RGBVALUE::value_type value_type;
1120 template <class ITERATOR>
1121 value_type const & operator()(ITERATOR const & i) const {
1122 return (*i).green();
1127 template <class ITERATOR, class DIFFERENCE>
1128 value_type const & operator()(ITERATOR const & i, DIFFERENCE d) const
1130 return i[d].green();
1136 template <class V, class ITERATOR>
1137 void set(V value, ITERATOR const & i) const {
1138 (*i).setGreen(value);
1145 template <class V, class ITERATOR, class DIFFERENCE>
1146 void set(V value, ITERATOR const & i, DIFFERENCE d) const
1148 i[d].setGreen(value);
1163 template <class RGBVALUE>
1167 typedef typename RGBVALUE::value_type value_type;
1171 template <class ITERATOR>
1172 value_type const & operator()(ITERATOR const & i) const {
1178 template <class ITERATOR, class DIFFERENCE>
1179 value_type const & operator()(ITERATOR const & i, DIFFERENCE d) const
1187 template <class V, class ITERATOR>
1188 void set(V value, ITERATOR const & i) const {
1189 (*i).setBlue(value);
1196 template <class V, class ITERATOR, class DIFFERENCE>
1197 void set(V value, ITERATOR const & i, DIFFERENCE d) const
1199 i[d].setBlue(value);
1214 template <class RGBVALUE>
1215 class RGBToGrayAccessor
1218 typedef typename RGBVALUE::value_type value_type;
1222 template <class ITERATOR>
1223 value_type operator()(ITERATOR const & i) const {
1224 return (*i).luminance(); }
1228 template <class ITERATOR, class DIFFERENCE>
1229 value_type operator()(ITERATOR const & i, DIFFERENCE d) const
1231 return i[d].luminance();
1248 template <class VALUETYPE>
1249 class GrayToRGBAccessor
1252 typedef typename vigra::RGBValue<VALUETYPE> value_type;
1256 template <class ITERATOR>
1257 value_type operator()(ITERATOR const & i) const {
1258 return value_type(*i,*i,*i); }
1262 template <class ITERATOR, class DIFFERENCE>
1263 value_type operator()(ITERATOR const & i, DIFFERENCE d) const
1265 return value_type(i[d],i[d],i[d]);