private static void TestLChToCieXYZ(LxyModel model, float l, float c, float h, float expectedX, float expectedY, float expectedZ)
        {
            float x, y, z;

            LChUtils.LChToCieXYZ(l, c, h, out x, out y, out z, model);

            Assert.That(x, Is.EqualTo(expectedX).Within(Epsilon));
            Assert.That(y, Is.EqualTo(expectedY).Within(Epsilon));
            Assert.That(z, Is.EqualTo(expectedZ).Within(Epsilon));
        }
        private static void TestCieXYZToLCh(LxyModel model, float x, float y, float z, float expectedL, float expectedC, float expectedH)
        {
            float l, c, h;

            LChUtils.CieXYZToLCh(x, y, z, out l, out c, out h, model);

            Assert.That(l, Is.EqualTo(expectedL).Within(Epsilon));
            Assert.That(c, Is.EqualTo(expectedC).Within(Epsilon));
            Assert.That(h, Is.EqualTo(expectedH).Within(Epsilon));
        }
Example #3
0
        public static void RGBToLCh(
            this RGBColorSystem @this,
            float r, float g, float b,
            out float l, out float c, out float h,
            LxyModel model = LxyModel.Lab, float[] referenceWhite = null)
        {
            float x, y, z;

            @this.RGBToCieXYZ(r, g, b, out x, out y, out z);
            LChUtils.CieXYZToLCh(x, y, z, out l, out c, out h, model, referenceWhite);
        }
Example #4
0
        public static void LChToRGB(
            this RGBColorSystem @this,
            float l, float c, float h,
            out float r, out float g, out float b,
            LxyModel model = LxyModel.Lab, float[] referenceWhite = null)
        {
            float x, y, z;

            LChUtils.LChToCieXYZ(l, c, h, out x, out y, out z, model, referenceWhite);
            @this.CieXYZToRGB(x, y, z, out r, out g, out b);
        }
Example #5
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!");
            }
        }
Example #6
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);
        }