예제 #1
0
    public void SamplesJzCzhz()
    {
        // red
        var c1 = new JzCzhzColor(0.6004, 0.2418, 39.58);

        // white (D65)
        var c2 = new JzCzhzColor(0.9886, 0.0003, 211.6);

        // gray (D65)
        var c3 = new JzCzhzColor(0.5446, 0.0003, 211.6);

        // black
        var c4 = new JzCzhzColor(0, 0, 0);
    }
예제 #2
0
    public void Convert_JzCzhz_to_Jzazbz(double jz,
                                         double az,
                                         double bz,
                                         double jhz,
                                         double cz,
                                         double hz)
    {
        // arrange
        var input     = new JzCzhzColor(jhz, cz, hz);
        var converter = new ConverterBuilder()
                        .FromJzCzhz()
                        .ToJzazbz()
                        .Build();

        // act
        var output = converter.Convert(input);

        // assert
        Assert.Equal(jz, output.Jz, DoubleComparer);
        Assert.Equal(az, output.az, DoubleComparer);
        Assert.Equal(bz, output.bz, DoubleComparer);
    }
예제 #3
0
    public void Convert_JzCzhz_to_XYZ(double x,
                                      double y,
                                      double z,
                                      double jz,
                                      double cz,
                                      double hz)
    {
        // arrange
        var input     = new JzCzhzColor(jz, cz, hz);
        var converter = new ConverterBuilder()
                        .FromJzCzhz(Illuminants.D65)
                        .ToXYZ(Illuminants.D65)
                        .Build();

        // act
        var output = converter.Convert(input);

        // assert
        Assert.Equal(x, output.X, DoubleComparer);
        Assert.Equal(y, output.Y, DoubleComparer);
        Assert.Equal(z, output.Z, DoubleComparer);
    }
예제 #4
0
    public void ComputingColorDifference()
    {
        // CIE Delta-E 1976
        {
            var differenceCalculator = new CIE76ColorDifference();
            var labColor1            = new LabColor(55, 80, 50);
            var labColor2            = new LabColor(18, 36, -60);
            var difference           = differenceCalculator.ComputeDifference(in labColor1, in labColor2); // 124.1169

            Assert.Equal(124.11688039908189, difference);
        }

        // CMC l:c 1984
        {
            var differenceThreshold  = CMCColorDifferenceThreshold.Acceptability; // or "Imperceptibility"
            var differenceCalculator = new CMCColorDifference(differenceThreshold);
            var labColor1            = new LabColor(55, 80, 50);
            var labColor2            = new LabColor(18, 36, -60);
            var difference           = differenceCalculator.ComputeDifference(in labColor1, in labColor2); // 69.7388

            Assert.Equal(69.7387994508022, difference);
        }

        // CIE Delta-E 1994
        {
            var application          = CIE94ColorDifferenceApplication.GraphicArts; // or "Textiles"
            var differenceCalculator = new CIE94ColorDifference(application);
            var labColor1            = new LabColor(55, 80, 50);
            var labColor2            = new LabColor(18, 36, -60);
            var difference           = differenceCalculator.ComputeDifference(in labColor1, in labColor2); // 60.7882

            Assert.Equal(60.78823549707133, difference);
        }

        // CIE Delta-E 2000
        {
            var differenceCalculator = new CIEDE2000ColorDifference();
            var labColor1            = new LabColor(55, 80, 50);
            var labColor2            = new LabColor(18, 36, -60);
            var difference           = differenceCalculator.ComputeDifference(in labColor1, in labColor2); // 52.2320

            Assert.Equal(52.23202852556586, difference);
        }

        // Delta Ez
        {
            var differenceCalculator = new JzCzhzDEzColorDifference();
            var color1     = new JzCzhzColor(0.3, 0.4, 165);
            var color2     = new JzCzhzColor(0.8, 0.6, 25);
            var difference = differenceCalculator.ComputeDifference(in color1, in color2); // 1.0666

            Assert.Equal(1.066630832433185, difference);
        }

        // Euclidean distance
        {
            // example for euclidean distance in the XYZ color space
            var differenceCalculator = new EuclideanDistanceColorDifference <XYZColor>();
            var color1     = new XYZColor(0.5, 0.5, 0.5);
            var color2     = new XYZColor(0.2, 0.4, 0.6);
            var difference = differenceCalculator.ComputeDifference(in color1, in color2); // 0.3317

            Assert.Equal(0.33166247903553997, difference);
        }
    }
예제 #5
0
    public void ToString_Simple()
    {
        var color = new JzCzhzColor(jz: 0.6, cz: 0.3, hz: 150);

        Assert.Equal("JzCzhz [Jz=0.6, Cz=0.3, hz=150]", color.ToString());
    }