public static Chromaticity1976uv Touv(this Color1931XYZ XYZ)
        {
            Chromaticity1976uv uv = default(Chromaticity1976uv);

            FastXYZ2uv(XYZ.X, XYZ.Y, XYZ.Z, out uv.u, out uv.v);
            return(uv);
        }
        public static Color1976Lab ToLab(this Color1931XYZ XYZ, Color1931XYZ whiteLab)
        {
            Color1976Lab Lab = default(Color1976Lab);

            FastXYZ2Lab(XYZ.X, XYZ.Y, XYZ.Z, whiteLab.X, whiteLab.Y, whiteLab.Z, out Lab.L, out Lab.a, out Lab.b);
            return(Lab);
        }
        public static Color1931XYZ ToXYZ(this Color1976Luv Luv, Chromaticity1976uv whiteLuv)
        {
            Color1931XYZ XYZ = default(Color1931XYZ);

            FastLuv2XYZ(Luv.L, Luv.u, Luv.v, whiteLuv.u, whiteLuv.v, out XYZ.X, out XYZ.Y, out XYZ.Z);
            return(XYZ);
        }
        public static Chromaticity1931xy Toxy(this Color1931XYZ XYZ)
        {
            Chromaticity1931xy xy = default(Chromaticity1931xy);

            FastXYZ2xy(XYZ.X, XYZ.Y, XYZ.Z, out xy.x, out xy.y);
            return(xy);
        }
        internal static ColorLMS ToLMS(this Color1931XYZ XYZ, ref ColorTransformMatrix XYZtoLMS)
        {
            ColorLMS LMS;

            XYZtoLMS.Transform(XYZ.X, XYZ.Y, XYZ.Z, out LMS.L, out LMS.M, out LMS.S);
            return(LMS);
        }
        public static Color1931XYZ ToXYZ(this Color1976Lab Lab, Color1931XYZ whiteLab)
        {
            Color1931XYZ XYZ = default(Color1931XYZ);

            FastLab2XYZ(Lab.L, Lab.a, Lab.b, whiteLab.X, whiteLab.Y, whiteLab.Z, out XYZ.X, out XYZ.Y, out XYZ.Z);
            return(XYZ);
        }
        public static Color1976Luv ToLuv(this Color1931XYZ XYZ, Color1931XYZ whiteLuv)
        {
            Color1976Luv Luv = default(Color1976Luv);

            FastXYZ2Luv(XYZ.X, XYZ.Y, XYZ.Z, whiteLuv.X, whiteLuv.Y, whiteLuv.Z, out Luv.L, out Luv.u, out Luv.v);
            return(Luv);
        }
Beispiel #8
0
        internal ColorRGB Transform(Color1931XYZ xyz)
        {
            ColorRGB rgb;

            Transform(xyz.X, xyz.Y, xyz.Z, out rgb.R, out rgb.G, out rgb.B);
            return(rgb);
        }
        public static ColorRGB ToRGB(this Color1931XYZ XYZ, ColorTransformMatrix XYZtoRGB)
        {
            ColorRGB RGB = default(ColorRGB);

            XYZtoRGB.Transform(XYZ.X, XYZ.Y, XYZ.Z, out RGB.R, out RGB.G, out RGB.B);
            return(RGB);
        }
        public static Color1931XYZ ToXYZ(this ColorRGB RGB, ColorTransformMatrix RGBtoXYZ)
        {
            Color1931XYZ XYZ = default(Color1931XYZ);

            RGBtoXYZ.Transform(RGB.R, RGB.G, RGB.B, out XYZ.X, out XYZ.Y, out XYZ.Z);
            return(XYZ);
        }
        public static Chromaticity1931xy Toxy(this Color1976Lab Lab, Color1931XYZ white)
        {
            Chromaticity1931xy xy = default(Chromaticity1931xy);

            FastLab2XYZ(Lab.L, Lab.a, Lab.b, white.X, white.Y, white.Z, out float X, out float Y, out float Z);
            FastXYZ2xy(X, Y, Z, out xy.x, out xy.y);
            return(xy);
        }
        public static Color1931XYZ ToXYZ(this Color1931xyY xyY)
        {
            Color1931XYZ XYZ = default(Color1931XYZ);

            XYZ.Y = xyY.Y;
            FastxyY2XYZ(xyY.x, xyY.y, xyY.Y, out XYZ.X, out XYZ.Z);
            return(XYZ);
        }
        public static Color1931xyY ToxyY(this Color1976Lab Lab, Color1931XYZ whiteLab)
        {
            Color1931xyY xyY = default(Color1931xyY);

            FastLab2XYZ(Lab.L, Lab.a, Lab.b, whiteLab.X, whiteLab.Y, whiteLab.Z, out float X, out xyY.Y, out float Z);
            FastXYZ2xy(X, xyY.Y, Z, out xyY.x, out xyY.y);
            return(xyY);
        }
        public static Color1931xyY ToxyY(this Color1931XYZ XYZ)
        {
            Color1931xyY xyY = default(Color1931xyY);

            xyY.Y = XYZ.Y;
            FastXYZ2xy(XYZ.X, XYZ.Y, XYZ.Z, out xyY.x, out xyY.y);
            return(xyY);
        }
        public static Chromaticity1976uv Touv(this Color1976Lab Lab, Color1931XYZ white)
        {
            Chromaticity1976uv uv = default(Chromaticity1976uv);

            FastLab2XYZ(Lab.L, Lab.a, Lab.b, white.X, white.Y, white.Z, out float X, out float Y, out float Z);
            FastXYZ2uv(X, Y, Z, out uv.u, out uv.v);
            return(uv);
        }
        internal static void XYZtoDKL(Color1931XYZ stimulus, ColorLMS backgroundLMS, ref ColorTransformMatrix XYZtoLMS, ref ColorTransformMatrix LMStoDKL, out ColorDKL dkl)
        {
            ColorLMS stimulusLMS;

            XYZtoLMS.Transform(stimulus.X, stimulus.Y, stimulus.Z, out stimulusLMS.L, out stimulusLMS.M, out stimulusLMS.S);

            ColorLMS deltaLMS = stimulusLMS - backgroundLMS;

            LMStoDKL.Transform(deltaLMS.L, deltaLMS.M, deltaLMS.S, out dkl.Isochromatic, out dkl.RGisoluminant, out dkl.Sisoluminant);
        }
        public static Color1931XYZ ToXYZ(int nm)
        {
            Color1931XYZ XYZ = default(Color1931XYZ);

            if (nm < ColorMatchingFunctions.Cie1931XYZ.FirstNanometers || nm > ColorMatchingFunctions.Cie1931XYZ.LastNanometers)
            {
                return(XYZ);
            }

            ColorMatchingFunctions.Cie1931XYZ.GetValuesAt(nm, out XYZ.X, out XYZ.Y, out XYZ.Z);
            return(XYZ);
        }
Beispiel #18
0
        public static ColorTransformMatrix GetRGBtoXYZ(Color1931XYZ xyz1, Color1931XYZ xyz2, Color1931XYZ xyz3, ColorRGB rgb1, ColorRGB rgb2, ColorRGB rgb3)
        {
            float a, b, c;
            float d, e, f;
            float g, h, i;

            Solve(xyz1.X, xyz2.X, xyz3.X, rgb1, rgb2, rgb3, out a, out b, out c);
            Solve(xyz1.Y, xyz2.Y, xyz3.Y, rgb1, rgb2, rgb3, out d, out e, out f);
            Solve(xyz1.Z, xyz2.Z, xyz3.Z, rgb1, rgb2, rgb3, out g, out h, out i);

            return(new ColorTransformMatrix(a, b, c, d, e, f, g, h, i));
        }
Beispiel #19
0
        public static ColorTransformMatrix GetRGBtoXYZ(Color1931XYZ red, Color1931XYZ green, Color1931XYZ blue, Color1931XYZ white)
        {
            ColorTransformMatrix XYZ    = new ColorTransformMatrix(red, green, blue);
            ColorTransformMatrix XYZinv = XYZ.Invert();

            float Sr, Sg, Sb;

            XYZinv.Transform(white.X, white.Y, white.Z, out Sr, out Sg, out Sb);
            ColorTransformMatrix M = XYZ;

            M.a *= Sr; M.b *= Sg; M.c *= Sb;
            M.d *= Sr; M.e *= Sg; M.f *= Sb;
            M.g *= Sr; M.h *= Sg; M.i *= Sb;

            return(M);
        }
        public static Color1931XYZ ToXYZ(float[] spectrum, int nmFirst, int nmStep, ColorMatchingFunctions.XYZ matchingFunctions)
        {
            if (nmFirst < 0 || nmStep < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            Color1931XYZ XYZ = default(Color1931XYZ);

            for (int i = 0, nm = nmFirst; i < spectrum.Length; i++, nm += nmStep)
            {
                float x̄, ȳ, z̄;
                matchingFunctions.GetValuesAt(nm, out x̄, out ȳ, out z̄);

                XYZ.X += x̄ * spectrum[i];
                XYZ.Y += ȳ * spectrum[i];
                XYZ.Z += z̄ * spectrum[i];
            }

            return(XYZ);
        }
 public static Color1931XYZ ToXYZ(this Color1976LCh LCh, Color1931XYZ whiteLab)
 {
     return(ToXYZ((Color1976Lab)LCh, whiteLab));
 }
        public static ColorRGB ToRGB(this Chromaticity1931xy xy, ColorTransformMatrix XYZtoRGB)
        {
            Color1931XYZ XYZ = ToXYZ(xy, 1f);

            return(ToRGB(XYZ, XYZtoRGB));
        }
 public static ColorRGB ToRGB(this Color1976LCh LCh, ColorTransformMatrix XYZtoRGB, Color1931XYZ white)
 {
     return(ToRGB((Color1976Lab)LCh, XYZtoRGB, white));
 }
        public static Chromaticity1976uv Touv(int nm)
        {
            Color1931XYZ XYZ = ToXYZ(nm);

            return(Touv(XYZ));
        }
        public static ColorRGB ToRGB(this Color1976Lab Lab, ColorTransformMatrix XYZtoRGB, Color1931XYZ white)
        {
            Color1931XYZ XYZ = ToXYZ(Lab, white);

            return(ToRGB(XYZ, XYZtoRGB));
        }
        public static ColorRGB ToRGB(this Color1931xyY xyY, ColorTransformMatrix XYZtoRGB)
        {
            Color1931XYZ XYZ = ToXYZ(xyY);

            return(ToRGB(XYZ, XYZtoRGB));
        }
        public static ColorRGB ToRGB(int nm, ColorTransformMatrix XYZtoRGB)
        {
            Color1931XYZ XYZ = ToXYZ(nm);

            return(ToRGB(XYZ, XYZtoRGB));
        }
        public static Chromaticity1976uv Touv(this ColorHSV HSV, ColorTransformMatrix RGBtoXYZ)
        {
            Color1931XYZ XYZ = ToXYZ(HSV, RGBtoXYZ);

            return(Touv(XYZ));
        }
        internal static void DKLtoXYZ(ColorDKL dkl, ColorLMS backgroundLMS, ref ColorTransformMatrix DKLtoLMS, ref ColorTransformMatrix LMStoXYZ, out Color1931XYZ xyz)
        {
            ColorLMS diffLMS;

            DKLtoLMS.Transform(dkl.Isochromatic, dkl.RGisoluminant, dkl.Sisoluminant, out diffLMS.L, out diffLMS.M, out diffLMS.S);

            ColorLMS stimulusLMS = diffLMS + backgroundLMS;

            LMStoXYZ.Transform(stimulusLMS.L, stimulusLMS.M, stimulusLMS.S, out xyz.X, out xyz.Y, out xyz.Z);
        }
 public static Chromaticity1976uv Touv(this Color1976LCh LCh, Color1931XYZ white)
 {
     return(Touv((Color1976Lab)LCh, white));
 }