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);
        }
        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);
        }
Exemplo 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);
        }