private static void TestCieXYZToLab(float x, float y, float z, float expectedL, float expectedA, float expectedB)
        {
            float l, a, b;

            CieLabUtils.CieXYZToLab(x, y, z, out l, out a, out b);

            Assert.That(l, Is.EqualTo(expectedL).Within(Epsilon));
            Assert.That(a, Is.EqualTo(expectedA).Within(Epsilon));
            Assert.That(b, Is.EqualTo(expectedB).Within(Epsilon));
        }
        private static void TestLabToCieXYZ(float l, float a, float b, float expectedX, float expectedY, float expectedZ)
        {
            float x, y, z;

            CieLabUtils.LabToCieXYZ(l, a, b, out x, out y, out z);

            Assert.That(x, Is.EqualTo(expectedX).Within(Epsilon));
            Assert.That(y, Is.EqualTo(expectedY).Within(Epsilon));
            Assert.That(z, Is.EqualTo(expectedZ).Within(Epsilon));
        }
        public void LabToCieXYZ_is_inverse_of_CieXYZToLab()
        {
            for (float x = 0; x <= 0.95047f; x += Step)
            {
                for (float y = Step; y <= 1.0f; y += Step)
                {
                    for (float z = 0; z <= 1.08883; z += Step)
                    {
                        float l, a, b;
                        CieLabUtils.CieXYZToLab(x, y, z, out l, out a, out b);

                        TestLabToCieXYZ(l, a, b, x, y, z);
                    }
                }
            }
        }
Exemple #4
0
        public static void LChToCieXYZ(
            float l, float c, float h,
            out float x, out float y, out float z,
            LxyModel model = LxyModel.Lab, float[] referenceWhiteXyz = null)
        {
            float lxy_l, lxy_x, lxy_y;

            LChToLxy(l, c, h, out lxy_l, out lxy_x, out lxy_y);

            switch (model)
            {
            case LxyModel.Lab:
                CieLabUtils.LabToCieXYZ(lxy_l, lxy_x, lxy_y, out x, out y, out z, referenceWhiteXyz);
                break;

            case LxyModel.Luv:
                CieLuvUtils.LuvToCieXYZ(lxy_l, lxy_x, lxy_y, out x, out y, out z, referenceWhiteXyz);
                break;

            default:
                throw new ArgumentException("Illegal model!");
            }
        }
Exemple #5
0
        public static void CieXYZToLCh(
            float x, float y, float z,
            out float l, out float c, out float h,
            LxyModel model = LxyModel.Lab, float[] referenceWhiteXyz = null)
        {
            float lxy_l, lxy_x, lxy_y;

            switch (model)
            {
            case LxyModel.Lab:
                CieLabUtils.CieXYZToLab(x, y, z, out lxy_l, out lxy_x, out lxy_y, referenceWhiteXyz);
                break;

            case LxyModel.Luv:
                CieLuvUtils.CieXYZToLuv(x, y, z, out lxy_l, out lxy_x, out lxy_y, referenceWhiteXyz);
                break;

            default:
                throw new ArgumentException("Illegal model!");
            }

            LxyToLCh(lxy_l, lxy_x, lxy_y, out l, out c, out h);
        }