public static unsafe ImageSource RenderLinearGamutLuv(int width, int height, RGBPrimaries <Color1931xyY> primaries, Color1931XYZ white, float leftU, float rightU, float topV, float bottomV)
        {
            ColorTransformMatrix RGBtoXYZ = ColorTransformMatrix.GetRGBtoXYZ((Color1931XYZ)primaries.Red, (Color1931XYZ)primaries.Green, (Color1931XYZ)primaries.Blue, white);
            ColorTransformMatrix XYZtoRGB = RGBtoXYZ.Invert();

            return(RenderLinearGamutLuv(width, height, XYZtoRGB, leftU, rightU, topV, bottomV));
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        // Kaiser, Bonton (1996). Human Color Vision (Second Edition), Appendix, Part IV
        public static ColorTransformMatrix GetScaledLMStoDKL(ColorLMS background)
        {
            ColorTransformMatrix LMStoDKL = new ColorTransformMatrix
                                            (
                1, 1, 0,
                1, -background.L / background.M, 0,
                -1, -1, (background.L + background.M) / background.S
                                            );

            ColorTransformMatrix DKLtoLMS = LMStoDKL.Invert();

            ColorLMS isolatingIso          = new ColorLMS(DKLtoLMS.a, DKLtoLMS.d, DKLtoLMS.g);
            float    pooledConeContrastIso = (isolatingIso / background).Length;
            ColorLMS normalizedIso         = isolatingIso / pooledConeContrastIso;

            ColorLMS isolatingRGiso          = new ColorLMS(DKLtoLMS.b, DKLtoLMS.e, DKLtoLMS.h);
            float    pooledConeCotnrastRGiso = (isolatingRGiso / background).Length;
            ColorLMS normalizedRGiso         = isolatingRGiso / pooledConeCotnrastRGiso;

            ColorLMS isolatingSiso          = new ColorLMS(DKLtoLMS.c, DKLtoLMS.f, DKLtoLMS.i);
            float    pooledConeContrastSiso = (isolatingSiso / background).Length;
            ColorLMS normalizedSiso         = isolatingSiso / pooledConeContrastSiso;

            ColorDKL unitResponse;

            LMStoDKL.Transform(normalizedIso.L, normalizedIso.M, normalizedIso.S, out unitResponse.Isochromatic, out _, out _);
            LMStoDKL.Transform(normalizedRGiso.L, normalizedRGiso.M, normalizedRGiso.S, out _, out unitResponse.RGisoluminant, out _);
            LMStoDKL.Transform(normalizedSiso.L, normalizedSiso.M, normalizedSiso.S, out _, out _, out unitResponse.Sisoluminant);

            ColorTransformMatrix rescaler = new ColorTransformMatrix
                                            (
                1 / unitResponse.Isochromatic, 0, 0,
                0, 1 / unitResponse.RGisoluminant, 0,
                0, 0, 1 / unitResponse.Sisoluminant
                                            );

            return(rescaler * LMStoDKL);
        }