Ejemplo n.º 1
0
        public ColorXYZ(ColorLAB lab, RGBWorkingSpace ws)
        {
            ColorXYZ i = ws.ReferenceWhite.ColorXYZ;

            double delta = 6.0 / 29.0;

            double fy = (lab.L + 16) / 116.0;
            double fx = fy + (lab.A / 500.0);
            double fz = fy - (lab.B / 200.0);

            double x = (fx > delta) ? i.X * (fx * fx * fx) : (fx - 16.0 / 116.0) * 3 * (delta * delta) * i.X;
            double y = (fy > delta) ? i.Y * (fy * fy * fy) : (fy - 16.0 / 116.0) * 3 * (delta * delta) * i.Y;
            double z = (fz > delta) ? i.Z * (fz * fz * fz) : (fz - 16.0 / 116.0) * 3 * (delta * delta) * i.Z;

            this._alpha = lab.Alpha;
            this._x     = x;
            this._y     = y;
            this._z     = z;
        }
Ejemplo n.º 2
0
        public ColorLAB(ColorXYZ xyz, RGBWorkingSpace ws)
        {
            ColorXYZ i = ws.ReferenceWhite.ColorXYZ;

            double nx = xyz.X / i.X;
            double ny = xyz.Y / i.Y;
            double nz = xyz.Z / i.Z;

            double fx = (nx > 0.008856) ? System.Math.Pow(nx, (1.0 / 3.0)) : (7.787 * nx + 16.0 / 116.0);
            double fy = (ny > 0.008856) ? System.Math.Pow(ny, (1.0 / 3.0)) : (7.787 * ny + 16.0 / 116.0);
            double fz = (nz > 0.008856) ? System.Math.Pow(nz, (1.0 / 3.0)) : (7.787 * nz + 16.0 / 116.0);

            double l = (116.0 * fy) - 16;
            double a = 500.0 * (fx - fy);
            double b = 200.0 * (fy - fz);

            this._alpha = xyz.Alpha;
            this._l     = l;
            this._a     = a;
            this._b     = b;
        }
Ejemplo n.º 3
0
        public ColorXYZ(ColorRGB rgb, RGBWorkingSpace ws)
        {
            var m = ws.RGBTOXYZMatrix;

            // convert to a sRGB form
            double r = (rgb.R > 0.04045) ? System.Math.Pow((rgb.R + 0.055) / (1.055), 2.4) : (rgb.R / 12.92);
            double g = (rgb.G > 0.04045) ? System.Math.Pow((rgb.G + 0.055) / (1.055), 2.4) : (rgb.G / 12.92);
            double b = (rgb.B > 0.04045) ? System.Math.Pow((rgb.B + 0.055) / (1.055), 2.4) : (rgb.B / 12.92);


            double x = (r * m[0, 0] + g * m[0, 1] + b * m[0, 2]);
            double y = (r * m[1, 0] + g * m[1, 1] + b * m[1, 2]);
            double z = (r * m[2, 0] + g * m[2, 1] + b * m[2, 2]);

            x *= 100;
            y *= 100;
            z *= 100;

            this._alpha = rgb.Alpha;
            this._x     = x;
            this._y     = y;
            this._z     = z;
        }