37 #ifndef VIGRA_COLORCONVERSIONS_HXX
38 #define VIGRA_COLORCONVERSIONS_HXX
41 #include "mathutil.hxx"
42 #include "rgbvalue.hxx"
43 #include "functortraits.hxx"
50 template<
class ValueType>
51 inline ValueType gammaCorrection(
double value,
double gamma)
53 typedef typename NumericTraits<ValueType>::RealPromote Promote;
54 return NumericTraits<ValueType>::fromRealPromote(
55 RequiresExplicitCast<Promote>::cast(
61 template<
class ValueType>
62 inline ValueType gammaCorrection(
double value,
double gamma,
double norm)
64 typedef typename NumericTraits<ValueType>::RealPromote Promote;
65 return NumericTraits<ValueType>::fromRealPromote(
66 RequiresExplicitCast<Promote>::cast(
69 : norm*
std::pow(value/norm, gamma)));
72 template<
class ValueType>
73 inline ValueType sRGBCorrection(
double value,
double norm)
76 typedef typename NumericTraits<ValueType>::RealPromote Promote;
77 return NumericTraits<ValueType>::fromRealPromote(
78 RequiresExplicitCast<ValueType>::cast(
81 : norm*(1.055*
std::pow(value, 0.41666666666666667) - 0.055)));
84 template<
class ValueType>
85 inline ValueType inverse_sRGBCorrection(
double value,
double norm)
88 typedef typename NumericTraits<ValueType>::RealPromote Promote;
89 return NumericTraits<ValueType>::fromRealPromote(
90 RequiresExplicitCast<ValueType>::cast(
275 template <
class From,
class To = From>
316 detail::gammaCorrection<To>(rgb[0], 0.45, max_),
317 detail::gammaCorrection<To>(rgb[1], 0.45, max_),
318 detail::gammaCorrection<To>(rgb[2], 0.45, max_));
326 class RGB2RGBPrimeFunctor<unsigned char, unsigned char>
328 unsigned char lut_[256];
336 typedef TinyVector<unsigned char, 3>
value_type;
340 for(
int i=0; i<256; ++i)
342 lut_[i] = detail::gammaCorrection<unsigned char>(i, 0.45, 255.0);
348 for(
int i=0; i<256; ++i)
350 lut_[i] = detail::gammaCorrection<unsigned char>(i, 0.45, max);
355 TinyVector<unsigned char, 3>
operator()(V
const & rgb)
const
357 return TinyVector<unsigned char, 3>(lut_[rgb[0]], lut_[rgb[1]], lut_[rgb[2]]);
361 template <
class From,
class To>
362 class FunctorTraits<RGB2RGBPrimeFunctor<From, To> >
363 :
public FunctorTraitsBase<RGB2RGBPrimeFunctor<From, To> >
366 typedef VigraTrueType isUnaryFunctor;
393 template <
class From,
class To = From>
434 detail::sRGBCorrection<To>(rgb[0], max_),
435 detail::sRGBCorrection<To>(rgb[1], max_),
436 detail::sRGBCorrection<To>(rgb[2], max_));
444 class RGB2sRGBFunctor<unsigned char, unsigned char>
446 unsigned char lut_[256];
454 typedef TinyVector<unsigned char, 3>
value_type;
458 for(
int i=0; i<256; ++i)
460 lut_[i] = detail::sRGBCorrection<unsigned char>(i, 255.0);
466 for(
int i=0; i<256; ++i)
468 lut_[i] = detail::sRGBCorrection<unsigned char>(i, max);
473 TinyVector<unsigned char, 3>
operator()(V
const & rgb)
const
475 return TinyVector<unsigned char, 3>(lut_[rgb[0]], lut_[rgb[1]], lut_[rgb[2]]);
479 template <
class From,
class To>
480 class FunctorTraits<RGB2sRGBFunctor<From, To> >
481 :
public FunctorTraitsBase<RGB2sRGBFunctor<From, To> >
484 typedef VigraTrueType isUnaryFunctor;
508 template <
class From,
class To = From>
533 : max_(255.0), gamma_(1.0/0.45)
540 : max_(max), gamma_(1.0/0.45)
548 detail::gammaCorrection<To>(rgb[0], gamma_, max_),
549 detail::gammaCorrection<To>(rgb[1], gamma_, max_),
550 detail::gammaCorrection<To>(rgb[2], gamma_, max_));
559 class RGBPrime2RGBFunctor<unsigned char, unsigned char>
561 unsigned char lut_[256];
569 typedef TinyVector<unsigned char, 3>
value_type;
573 for(
int i=0; i<256; ++i)
575 lut_[i] = detail::gammaCorrection<unsigned char>(i, 1.0/0.45, 255.0);
581 for(
int i=0; i<256; ++i)
583 lut_[i] = detail::gammaCorrection<unsigned char>(i, 1.0/0.45, max);
588 TinyVector<unsigned char, 3>
operator()(V
const & rgb)
const
590 return TinyVector<unsigned char, 3>(lut_[rgb[0]], lut_[rgb[1]], lut_[rgb[2]]);
594 template <
class From,
class To>
595 class FunctorTraits<RGBPrime2RGBFunctor<From, To> >
596 :
public FunctorTraitsBase<RGBPrime2RGBFunctor<From, To> >
599 typedef VigraTrueType isUnaryFunctor;
626 template <
class From,
class To = From>
666 detail::inverse_sRGBCorrection<To>(rgb[0], max_),
667 detail::inverse_sRGBCorrection<To>(rgb[1], max_),
668 detail::inverse_sRGBCorrection<To>(rgb[2], max_));
676 class sRGB2RGBFunctor<unsigned char, unsigned char>
678 unsigned char lut_[256];
686 typedef TinyVector<unsigned char, 3>
value_type;
690 for(
int i=0; i<256; ++i)
692 lut_[i] = detail::inverse_sRGBCorrection<unsigned char>(i, 255.0);
698 for(
int i=0; i<256; ++i)
700 lut_[i] = detail::inverse_sRGBCorrection<unsigned char>(i, max);
705 TinyVector<unsigned char, 3>
operator()(V
const & rgb)
const
707 return TinyVector<unsigned char, 3>(lut_[rgb[0]], lut_[rgb[1]], lut_[rgb[2]]);
711 template <
class From,
class To>
712 class FunctorTraits<sRGB2RGBFunctor<From, To> >
713 :
public FunctorTraitsBase<sRGB2RGBFunctor<From, To> >
716 typedef VigraTrueType isUnaryFunctor;
785 typedef detail::RequiresExplicitCast<component_type> Convert;
790 result[0] = Convert::cast(0.412453*red + 0.357580*green + 0.180423*blue);
791 result[1] = Convert::cast(0.212671*red + 0.715160*green + 0.072169*blue);
792 result[2] = Convert::cast(0.019334*red + 0.119193*green + 0.950227*blue);
801 class FunctorTraits<RGB2XYZFunctor<T> >
802 :
public FunctorTraitsBase<RGB2XYZFunctor<T> >
805 typedef VigraTrueType isUnaryFunctor;
858 : gamma_(1.0/ 0.45), max_(max)
865 typedef detail::RequiresExplicitCast<component_type> Convert;
866 component_type red = detail::gammaCorrection<component_type>(rgb[0]/max_, gamma_);
867 component_type green = detail::gammaCorrection<component_type>(rgb[1]/max_, gamma_);
868 component_type blue = detail::gammaCorrection<component_type>(rgb[2]/max_, gamma_);
870 result[0] = Convert::cast(0.412453*red + 0.357580*green + 0.180423*blue);
871 result[1] = Convert::cast(0.212671*red + 0.715160*green + 0.072169*blue);
872 result[2] = Convert::cast(0.019334*red + 0.119193*green + 0.950227*blue);
882 class FunctorTraits<RGBPrime2XYZFunctor<T> >
883 :
public FunctorTraitsBase<RGBPrime2XYZFunctor<T> >
886 typedef VigraTrueType isUnaryFunctor;
914 typedef typename NumericTraits<T>::RealPromote component_type;
952 typedef detail::RequiresExplicitCast<component_type> Convert;
953 component_type red = Convert::cast( 3.2404813432*xyz[0] - 1.5371515163*xyz[1] - 0.4985363262*xyz[2]);
954 component_type green = Convert::cast(-0.9692549500*xyz[0] + 1.8759900015*xyz[1] + 0.0415559266*xyz[2]);
955 component_type blue = Convert::cast( 0.0556466391*xyz[0] - 0.2040413384*xyz[1] + 1.0573110696*xyz[2]);
956 return value_type(NumericTraits<T>::fromRealPromote(red * max_),
957 NumericTraits<T>::fromRealPromote(green * max_),
958 NumericTraits<T>::fromRealPromote(blue * max_));
963 class FunctorTraits<XYZ2RGBFunctor<T> >
964 :
public FunctorTraitsBase<XYZ2RGBFunctor<T> >
967 typedef VigraTrueType isUnaryFunctor;
991 typedef typename NumericTraits<T>::RealPromote component_type;
1017 : gamma_(0.45), max_(component_type(255.0))
1024 : gamma_(0.45), max_(max)
1032 typedef detail::RequiresExplicitCast<component_type> Convert;
1033 component_type red = Convert::cast( 3.2404813432*xyz[0] - 1.5371515163*xyz[1] - 0.4985363262*xyz[2]);
1034 component_type green = Convert::cast(-0.9692549500*xyz[0] + 1.8759900015*xyz[1] + 0.0415559266*xyz[2]);
1035 component_type blue = Convert::cast( 0.0556466391*xyz[0] - 0.2040413384*xyz[1] + 1.0573110696*xyz[2]);
1036 return value_type(NumericTraits<T>::fromRealPromote(detail::gammaCorrection<component_type>(red, gamma_) * max_),
1037 NumericTraits<T>::fromRealPromote(detail::gammaCorrection<component_type>(green, gamma_) * max_),
1038 NumericTraits<T>::fromRealPromote(detail::gammaCorrection<component_type>(blue, gamma_) * max_));
1043 class FunctorTraits<XYZ2RGBPrimeFunctor<T> >
1044 :
public FunctorTraitsBase<XYZ2RGBPrimeFunctor<T> >
1047 typedef VigraTrueType isUnaryFunctor;
1106 kappa_(24389.0/27.0),
1107 epsilon_(216.0/24389.0)
1114 if(xyz[1] == NumericTraits<T>::zero())
1116 result[0] = NumericTraits<component_type>::zero();
1117 result[1] = NumericTraits<component_type>::zero();
1118 result[2] = NumericTraits<component_type>::zero();
1122 typedef detail::RequiresExplicitCast<component_type> Convert;
1127 component_type denom = Convert::cast(xyz[0] + 15.0*xyz[1] + 3.0*xyz[2]);
1131 result[1] = Convert::cast(13.0*L*(uprime - 0.197839));
1132 result[2] = Convert::cast(13.0*L*(vprime - 0.468342));
1138 double gamma_, kappa_, epsilon_;
1142 class FunctorTraits<XYZ2LuvFunctor<T> >
1143 :
public FunctorTraitsBase<XYZ2LuvFunctor<T> >
1146 typedef VigraTrueType isUnaryFunctor;
1183 ikappa_(27.0/24389.0)
1192 if(luv[0] == NumericTraits<T>::zero())
1194 result[0] = NumericTraits<component_type>::zero();
1195 result[1] = NumericTraits<component_type>::zero();
1196 result[2] = NumericTraits<component_type>::zero();
1200 typedef detail::RequiresExplicitCast<component_type> Convert;
1201 component_type uprime = Convert::cast(luv[1] / 13.0 / luv[0] + 0.197839);
1202 component_type vprime = Convert::cast(luv[2] / 13.0 / luv[0] + 0.468342);
1204 result[1] = Convert::cast(
1208 result[0] = Convert::cast(9.0*uprime*result[1] / 4.0 / vprime);
1209 result[2] = Convert::cast(((9.0 / vprime - 15.0)*result[1] - result[0])/ 3.0);
1215 double gamma_, ikappa_;
1219 class FunctorTraits<Luv2XYZFunctor<T> >
1220 :
public FunctorTraitsBase<Luv2XYZFunctor<T> >
1223 typedef VigraTrueType isUnaryFunctor;
1279 kappa_(24389.0/27.0),
1280 epsilon_(216.0/24389.0)
1288 typedef detail::RequiresExplicitCast<component_type> Convert;
1295 : 116.0 * ygamma - 16.0);
1298 result[1] = Convert::cast(500.0*(xgamma - ygamma));
1299 result[2] = Convert::cast(200.0*(ygamma - zgamma));
1304 double gamma_, kappa_, epsilon_;
1308 class FunctorTraits<XYZ2LabFunctor<T> >
1309 :
public FunctorTraitsBase<XYZ2LabFunctor<T> >
1312 typedef VigraTrueType isUnaryFunctor;
1351 ikappa_(27.0/24389.0)
1359 typedef detail::RequiresExplicitCast<component_type> Convert;
1363 :
std::pow((lab[0] + 16.0) / 116.0, gamma_));
1375 double gamma_, ikappa_;
1379 class FunctorTraits<Lab2XYZFunctor<T> >
1380 :
public FunctorTraitsBase<Lab2XYZFunctor<T> >
1383 typedef VigraTrueType isUnaryFunctor;
1459 return xyz2luv(rgb2xyz(rgb));
1468 class FunctorTraits<RGB2LuvFunctor<T> >
1469 :
public FunctorTraitsBase<RGB2LuvFunctor<T> >
1472 typedef VigraTrueType isUnaryFunctor;
1548 return xyz2lab(rgb2xyz(rgb));
1557 class FunctorTraits<RGB2LabFunctor<T> >
1558 :
public FunctorTraitsBase<RGB2LabFunctor<T> >
1561 typedef VigraTrueType isUnaryFunctor;
1578 typedef typename NumericTraits<T>::RealPromote component_type;
1611 return xyz2rgb(luv2xyz(luv));
1616 class FunctorTraits<Luv2RGBFunctor<T> >
1617 :
public FunctorTraitsBase<Luv2RGBFunctor<T> >
1620 typedef VigraTrueType isUnaryFunctor;
1637 typedef typename NumericTraits<T>::RealPromote component_type;
1677 return xyz2rgb(lab2xyz(lab));
1682 class FunctorTraits<Lab2RGBFunctor<T> >
1683 :
public FunctorTraitsBase<Lab2RGBFunctor<T> >
1686 typedef VigraTrueType isUnaryFunctor;
1755 return xyz2luv(rgb2xyz(rgb));
1764 class FunctorTraits<RGBPrime2LuvFunctor<T> >
1765 :
public FunctorTraitsBase<RGBPrime2LuvFunctor<T> >
1768 typedef VigraTrueType isUnaryFunctor;
1837 return xyz2lab(rgb2xyz(rgb));
1846 class FunctorTraits<RGBPrime2LabFunctor<T> >
1847 :
public FunctorTraitsBase<RGBPrime2LabFunctor<T> >
1850 typedef VigraTrueType isUnaryFunctor;
1867 typedef typename NumericTraits<T>::RealPromote component_type;
1907 return xyz2rgb(luv2xyz(luv));
1912 class FunctorTraits<Luv2RGBPrimeFunctor<T> >
1913 :
public FunctorTraitsBase<Luv2RGBPrimeFunctor<T> >
1916 typedef VigraTrueType isUnaryFunctor;
1933 typedef typename NumericTraits<T>::RealPromote component_type;
1973 return xyz2rgb(lab2xyz(lab));
1978 class FunctorTraits<Lab2RGBPrimeFunctor<T> >
1979 :
public FunctorTraitsBase<Lab2RGBPrimeFunctor<T> >
1982 typedef VigraTrueType isUnaryFunctor;
2064 typedef detail::RequiresExplicitCast<component_type> Convert;
2070 result[0] = Convert::cast(0.299*red + 0.587*green + 0.114*blue);
2071 result[1] = Convert::cast(-0.1687358916*red - 0.3312641084*green + 0.5*blue);
2072 result[2] = Convert::cast(0.5*red - 0.4186875892*green - 0.0813124108*blue);
2081 class FunctorTraits<RGBPrime2YPrimePbPrFunctor<T> >
2082 :
public FunctorTraitsBase<RGBPrime2YPrimePbPrFunctor<T> >
2085 typedef VigraTrueType isUnaryFunctor;
2102 typedef typename NumericTraits<T>::RealPromote component_type;
2104 component_type max_;
2141 typedef detail::RequiresExplicitCast<component_type> Convert;
2142 component_type nred = Convert::cast(ypbpr[0] + 1.402*ypbpr[2]);
2143 component_type ngreen = Convert::cast(ypbpr[0] - 0.3441362862*ypbpr[1] - 0.7141362862*ypbpr[2]);
2144 component_type nblue = Convert::cast(ypbpr[0] + 1.772*ypbpr[1]);
2145 return result_type(NumericTraits<T>::fromRealPromote(nred * max_),
2146 NumericTraits<T>::fromRealPromote(ngreen * max_),
2147 NumericTraits<T>::fromRealPromote(nblue * max_));
2152 class FunctorTraits<YPrimePbPr2RGBPrimeFunctor<T> >
2153 :
public FunctorTraitsBase<YPrimePbPr2RGBPrimeFunctor<T> >
2156 typedef VigraTrueType isUnaryFunctor;
2237 typedef detail::RequiresExplicitCast<component_type> Convert;
2243 result[0] = Convert::cast(0.299*red + 0.587*green + 0.114*blue);
2244 result[1] = Convert::cast(0.596*red - 0.274*green - 0.322*blue);
2245 result[2] = Convert::cast(0.212*red - 0.523*green + 0.311*blue);
2254 class FunctorTraits<RGBPrime2YPrimeIQFunctor<T> >
2255 :
public FunctorTraitsBase<RGBPrime2YPrimeIQFunctor<T> >
2258 typedef VigraTrueType isUnaryFunctor;
2275 typedef typename NumericTraits<T>::RealPromote component_type;
2277 component_type max_;
2314 typedef detail::RequiresExplicitCast<component_type> Convert;
2315 component_type nred = Convert::cast(yiq[0] + 0.9548892043*yiq[1] + 0.6221039350*yiq[2]);
2316 component_type ngreen = Convert::cast(yiq[0] - 0.2713547827*yiq[1] - 0.6475120259*yiq[2]);
2317 component_type nblue = Convert::cast(yiq[0] - 1.1072510054*yiq[1] + 1.7024603738*yiq[2]);
2318 return result_type(NumericTraits<T>::fromRealPromote(nred * max_),
2319 NumericTraits<T>::fromRealPromote(ngreen * max_),
2320 NumericTraits<T>::fromRealPromote(nblue * max_));
2325 class FunctorTraits<YPrimeIQ2RGBPrimeFunctor<T> >
2326 :
public FunctorTraitsBase<YPrimeIQ2RGBPrimeFunctor<T> >
2329 typedef VigraTrueType isUnaryFunctor;
2410 typedef detail::RequiresExplicitCast<component_type> Convert;
2416 result[0] = Convert::cast(0.299*red + 0.587*green + 0.114*blue);
2417 result[1] = Convert::cast(-0.1471376975*red - 0.2888623025*green + 0.436*blue);
2418 result[2] = Convert::cast(0.6149122807*red - 0.5149122807*green - 0.100*blue);
2427 class FunctorTraits<RGBPrime2YPrimeUVFunctor<T> >
2428 :
public FunctorTraitsBase<RGBPrime2YPrimeUVFunctor<T> >
2431 typedef VigraTrueType isUnaryFunctor;
2448 typedef typename NumericTraits<T>::RealPromote component_type;
2450 component_type max_;
2487 typedef detail::RequiresExplicitCast<component_type> Convert;
2488 component_type nred = Convert::cast(yuv[0] + 1.140*yuv[2]);
2489 component_type ngreen = Convert::cast(yuv[0] - 0.3946517044*yuv[1] - 0.580681431*yuv[2]);
2490 component_type nblue = Convert::cast(yuv[0] + 2.0321100920*yuv[1]);
2491 return result_type(NumericTraits<T>::fromRealPromote(nred * max_),
2492 NumericTraits<T>::fromRealPromote(ngreen * max_),
2493 NumericTraits<T>::fromRealPromote(nblue * max_));
2498 class FunctorTraits<YPrimeUV2RGBPrimeFunctor<T> >
2499 :
public FunctorTraitsBase<YPrimeUV2RGBPrimeFunctor<T> >
2502 typedef VigraTrueType isUnaryFunctor;
2573 typedef detail::RequiresExplicitCast<component_type> Convert;
2579 result[0] = Convert::cast(16.0 + 65.481*red + 128.553*green + 24.966*blue);
2580 result[1] = Convert::cast(128.0 - 37.79683972*red - 74.20316028*green + 112.0*blue);
2581 result[2] = Convert::cast(128.0 + 112.0*red - 93.78601998*green - 18.21398002*blue);
2590 class FunctorTraits<RGBPrime2YPrimeCbCrFunctor<T> >
2591 :
public FunctorTraitsBase<RGBPrime2YPrimeCbCrFunctor<T> >
2594 typedef VigraTrueType isUnaryFunctor;
2611 typedef typename NumericTraits<T>::RealPromote component_type;
2613 component_type max_;
2650 typedef detail::RequiresExplicitCast<component_type> Convert;
2651 component_type y = Convert::cast(ycbcr[0] - 16.0);
2652 component_type cb = Convert::cast(ycbcr[1] - 128.0);
2653 component_type cr = Convert::cast(ycbcr[2] - 128.0);
2655 component_type nred = Convert::cast(0.00456621*y + 0.006258928571*cr);
2656 component_type ngreen = Convert::cast(0.00456621*y - 0.001536322706*cb - 0.003188108420*cr);
2657 component_type nblue = Convert::cast(0.00456621*y + 0.007910714286*cb);
2658 return result_type(NumericTraits<T>::fromRealPromote(nred * max_),
2659 NumericTraits<T>::fromRealPromote(ngreen * max_),
2660 NumericTraits<T>::fromRealPromote(nblue * max_));
2665 class FunctorTraits<YPrimeCbCr2RGBPrimeFunctor<T> >
2666 :
public FunctorTraitsBase<YPrimeCbCr2RGBPrimeFunctor<T> >
2669 typedef VigraTrueType isUnaryFunctor;
2775 inline TinyVector<float, 3>
2776 polar2Lab(
double color,
double brightness,
double saturation)
2778 double angle = (color+39.9977)/180.0*M_PI;
2779 double normsat = saturation*133.809;
2782 result[0] = float(100.0*brightness);
2790 TinyVector<float, 3>
2793 return polar2Lab(polar[0], polar[1], polar[2]);
2813 TinyVector<float, 3>
2817 result[1] = float(lab[0]/100.0);
2818 double angle = (lab[1] == 0.0 && lab[2] == 0.0)
2821 result[0] = angle < 0.0 ?
2822 float(angle + 360.0) :
2824 result[2] = float(
VIGRA_CSTD::sqrt(lab[1]*lab[1] + lab[2]*lab[2])/133.809);
2861 inline TinyVector<float, 3>
2862 polar2Luv(
double color,
double brightness,
double saturation)
2864 double angle = (color+12.1727)/180.0*M_PI;
2865 double normsat = saturation*179.04;
2868 result[0] = float(100.0*brightness);
2875 TinyVector<float, 3>
2878 return polar2Luv(polar[0], polar[1], polar[2]);
2898 TinyVector<float, 3>
2902 result[1] = float(luv[0]/100.0);
2903 double angle = (luv[1] == 0.0 && luv[2] == 0.0)
2906 result[0] = angle < 0.0 ?
2907 float(angle + 360.0) :
2946 inline TinyVector<float, 3>
2949 double angle = (color+18.6481)/180.0*M_PI;
2950 double normsat = saturation*0.533887;
2953 result[0] = float(brightness);
2960 TinyVector<float, 3>
2983 TinyVector<float, 3>
2987 result[1] = float(ypbpr[0]);
2988 double angle = (ypbpr[1] == 0.0 && ypbpr[2] == 0.0)
2991 result[0] = angle < 0.0 ?
2992 float(angle + 360.0) :
2994 result[2] = float(
VIGRA_CSTD::sqrt(ypbpr[1]*ypbpr[1] + ypbpr[2]*ypbpr[2])/0.533887);
3031 inline TinyVector<float, 3>
3034 double angle = (color+18.6482)/180.0*M_PI;
3035 double normsat = saturation*119.591;
3038 result[0] = float(brightness*219.0 + 16.0);
3045 TinyVector<float, 3>
3068 TinyVector<float, 3>
3072 result[1] = float((ycbcr[0]-16.0)/219.0);
3073 double cb = ycbcr[1]-128.0;
3074 double cr = ycbcr[2]-128.0;
3075 double angle = (cb == 0.0 && cr == 0.0)
3078 result[0] = angle < 0.0 ?
3079 float(angle + 360.0) :
3118 inline TinyVector<float, 3>
3121 double angle = (color-19.5807)/180.0*M_PI;
3122 double normsat = saturation*0.632582;
3125 result[0] = float(brightness);
3132 TinyVector<float, 3>
3155 TinyVector<float, 3>
3159 result[1] = float(yiq[0]);
3160 double angle = (yiq[1] == 0.0 && yiq[2] == 0.0)
3163 result[0] = angle < 0.0 ?
3164 float(angle + 360.0) :
3166 result[2] = float(
VIGRA_CSTD::sqrt(yiq[1]*yiq[1] + yiq[2]*yiq[2])/0.632582);
3203 inline TinyVector<float, 3>
3206 double angle = (color+13.4569)/180.0*M_PI;
3207 double normsat = saturation*0.632324;
3210 result[0] = float(brightness);
3217 TinyVector<float, 3>
3240 TinyVector<float, 3>
3244 result[1] = float(yuv[0]);
3245 double angle = (yuv[1] == 0.0 && yuv[2] == 0.0)
3248 result[0] = angle < 0.0 ?
3249 float(angle + 360.0) :
3251 result[2] = float(
VIGRA_CSTD::sqrt(yuv[1]*yuv[1] + yuv[2]*yuv[2])/0.632324);