21 {
22 double r = CIE.powtable[p.R];
23 double g = CIE.powtable[p.G];
24 double b = CIE.powtable[p.B];
25
26 double x = CIE.mRGB_XYZ[0, 0] * r + CIE.mRGB_XYZ[0, 1] * g + CIE.mRGB_XYZ[0, 2] * b / CIE.xnn;
27 double y = CIE.mRGB_XYZ[1, 0] * r + CIE.mRGB_XYZ[1, 1] * g + CIE.mRGB_XYZ[1, 2] * b / CIE.ynn;
28 double z = CIE.mRGB_XYZ[2, 0] * r + CIE.mRGB_XYZ[2, 1] * g + CIE.mRGB_XYZ[2, 2] * b / CIE.znn;
29
30 double l;
31 if (y > 0.008856)
32 {
33 y = Math.Pow(y, 1.0 / 3.0);
34 l = 116.0 * y - 16.0;
35 }
36 else
37 {
38 l = y > 0.0 ? y * 903.3 : 0.0;
39 y = 7.787 * y + 16.0 / 116.0;
40 }
41
42 x = x > 0.00856 ? Math.Pow(x, 1.0 / 3.0) : 7.787 * x + 16.0 / 116.0;
43 z = z > 0.00856 ? Math.Pow(z, 1.0 / 3.0) : 7.787 * z + 16.0 / 116.0;
44
45 return new LabPixel(l, 500.0 * (x - y), 200.0 * (y - z));
46 }
LabPixel(double l, double a, double b)
Definition: CIE.cs:13