public void LinearRgbToCompandedRgb(
            float linearR, float linearG, float linearB,
            out float compandedR, out float compandedG, out float compandedB)
        {
            switch (_compandingFunction)
            {
            case ColorCompandingFunction.Gamma:
                compandedR = ColorCompandingUtils.ApplyGammaCompanding(linearR, _gamma);
                compandedG = ColorCompandingUtils.ApplyGammaCompanding(linearG, _gamma);
                compandedB = ColorCompandingUtils.ApplyGammaCompanding(linearB, _gamma);
                break;

            case ColorCompandingFunction.SRGB:
                compandedR = ColorCompandingUtils.ApplySRGBCompanding(linearR);
                compandedG = ColorCompandingUtils.ApplySRGBCompanding(linearG);
                compandedB = ColorCompandingUtils.ApplySRGBCompanding(linearB);
                break;

            case ColorCompandingFunction.LStar:
                compandedR = ColorCompandingUtils.ApplyLStarCompanding(linearR);
                compandedG = ColorCompandingUtils.ApplyLStarCompanding(linearG);
                compandedB = ColorCompandingUtils.ApplyLStarCompanding(linearB);
                break;

            default:
                throw new InternalException("Illegal companding function");
            }
        }
Example #2
0
        public void ApplyInverseGammaCompanding_is_correct()
        {
            Assert.That(ColorCompandingUtils.ApplyInverseGammaCompanding(0, 2.2f), Is.EqualTo(0).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplyInverseGammaCompanding(1, 2.2f), Is.EqualTo(1).Within(Epsilon));

            Assert.That(ColorCompandingUtils.ApplyInverseGammaCompanding(0.6f, 2.2f), Is.EqualTo(0.325037f).Within(Epsilon));
        }
        public void CompandedRgbToLinearRgb(
            float compandedR, float compandedG, float compandedB,
            out float linearR, out float linearG, out float linearB)
        {
            switch (_compandingFunction)
            {
            case ColorCompandingFunction.Gamma:
                linearR = ColorCompandingUtils.ApplyInverseGammaCompanding(compandedR, _gamma);
                linearG = ColorCompandingUtils.ApplyInverseGammaCompanding(compandedG, _gamma);
                linearB = ColorCompandingUtils.ApplyInverseGammaCompanding(compandedB, _gamma);
                break;

            case ColorCompandingFunction.SRGB:
                linearR = ColorCompandingUtils.ApplyInverseSRGBCompanding(compandedR);
                linearG = ColorCompandingUtils.ApplyInverseSRGBCompanding(compandedG);
                linearB = ColorCompandingUtils.ApplyInverseSRGBCompanding(compandedB);
                break;

            case ColorCompandingFunction.LStar:
                linearR = ColorCompandingUtils.ApplyInverseLStarCompanding(compandedR);
                linearG = ColorCompandingUtils.ApplyInverseLStarCompanding(compandedG);
                linearB = ColorCompandingUtils.ApplyInverseLStarCompanding(compandedB);
                break;

            default:
                throw new InternalException("Illegal companding function");
            }
        }
Example #4
0
        public void ApplyLStarCompanding_is_correct()
        {
            Assert.That(ColorCompandingUtils.ApplyLStarCompanding(0), Is.EqualTo(0).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplyLStarCompanding(1), Is.EqualTo(1).Within(Epsilon));

            Assert.That(ColorCompandingUtils.ApplyLStarCompanding(0.001f), Is.EqualTo(0.009033f).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplyLStarCompanding(0.6f), Is.EqualTo(0.818382f).Within(Epsilon));
        }
Example #5
0
 public void ApplyInverseGammaCompanding_is_inverse_of_ApplySRGBCompanding()
 {
     for (float x = 0; x <= 1; x += Step)
     {
         var a = ColorCompandingUtils.ApplySRGBCompanding(x);
         Assert.That(ColorCompandingUtils.ApplyInverseSRGBCompanding(a), Is.EqualTo(x).Within(Epsilon));
     }
 }
Example #6
0
        public void ApplyInverseSRGBCompanding_is_correct()
        {
            Assert.That(ColorCompandingUtils.ApplyInverseSRGBCompanding(0), Is.EqualTo(0).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplyInverseSRGBCompanding(1), Is.EqualTo(1).Within(Epsilon));

            Assert.That(ColorCompandingUtils.ApplyInverseSRGBCompanding(0.01f), Is.EqualTo(0.00077f).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplyInverseSRGBCompanding(0.6f), Is.EqualTo(0.318547f).Within(Epsilon));
        }
Example #7
0
        public void ApplySRGBCompanding_is_correct()
        {
            Assert.That(ColorCompandingUtils.ApplySRGBCompanding(0), Is.EqualTo(0).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplySRGBCompanding(1), Is.EqualTo(1).Within(Epsilon));

            Assert.That(ColorCompandingUtils.ApplySRGBCompanding(0.001f), Is.EqualTo(0.01292f).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplySRGBCompanding(0.6f), Is.EqualTo(0.797738f).Within(Epsilon));
        }
Example #8
0
        public void ApplyInverseLStarCompanding_is_correct()
        {
            Assert.That(ColorCompandingUtils.ApplyInverseLStarCompanding(0), Is.EqualTo(0).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplyInverseLStarCompanding(1), Is.EqualTo(1).Within(Epsilon));

            Assert.That(ColorCompandingUtils.ApplyInverseLStarCompanding(0.01f), Is.EqualTo(0.001107f).Within(Epsilon));
            Assert.That(ColorCompandingUtils.ApplyInverseLStarCompanding(0.6f), Is.EqualTo(0.2812333f).Within(Epsilon));
        }