public void Convert_LinearRgb_to_CieLab(float r, float g, float b2, float l, float a, float b)
        {
            // Arrange
            var input    = new LinearRgb(r, g, b2);
            var expected = new CieLab(l, a, b);

            Span <LinearRgb> inputSpan = new LinearRgb[5];

            inputSpan.Fill(input);

            Span <CieLab> actualSpan = new CieLab[5];

            // Act
            var actual = Converter.ToCieLab(input);

            Converter.Convert(inputSpan, actualSpan);

            // Assert
            Assert.Equal(expected, actual, ColorSpaceComparer);

            for (int i = 0; i < actualSpan.Length; i++)
            {
                Assert.Equal(expected, actualSpan[i], ColorSpaceComparer);
            }
        }
        public void Convert_Lch_to_Lab(float l, float c, float h, float l2, float a, float b)
        {
            // Arrange
            var input    = new CieLch(l, c, h);
            var expected = new CieLab(l2, a, b);

            Span <CieLch> inputSpan = new CieLch[5];

            inputSpan.Fill(input);

            Span <CieLab> actualSpan = new CieLab[5];

            // Act
            var actual = Converter.ToCieLab(input);

            Converter.Convert(inputSpan, actualSpan);

            // Assert
            Assert.Equal(expected, actual, ColorSpaceComparer);

            for (int i = 0; i < actualSpan.Length; i++)
            {
                Assert.Equal(expected, actualSpan[i], ColorSpaceComparer);
            }
        }
        public void Convert_Hsv_to_CieLab(float h, float s, float v, float l, float a, float b)
        {
            // Arrange
            var input    = new Hsv(h, s, v);
            var expected = new CieLab(l, a, b);

            Span <Hsv> inputSpan = new Hsv[5];

            inputSpan.Fill(input);

            Span <CieLab> actualSpan = new CieLab[5];

            // Act
            var actual = Converter.ToCieLab(input);

            Converter.Convert(inputSpan, actualSpan, actualSpan.Length);

            // Assert
            Assert.Equal(expected, actual, ColorSpaceComparer);

            for (int i = 0; i < actualSpan.Length; i++)
            {
                Assert.Equal(expected, actualSpan[i], ColorSpaceComparer);
            }
        }
        public void Convert_Cmyk_to_CieLab(float c, float m, float y, float k, float l, float a, float b)
        {
            // Arrange
            var input    = new Cmyk(c, m, y, k);
            var expected = new CieLab(l, a, b);

            Span <Cmyk> inputSpan = new Cmyk[5];

            inputSpan.Fill(input);

            Span <CieLab> actualSpan = new CieLab[5];

            // Act
            var actual = Converter.ToCieLab(input);

            Converter.Convert(inputSpan, actualSpan);

            // Assert
            Assert.Equal(expected, actual, ColorSpaceComparer);

            for (int i = 0; i < actualSpan.Length; i++)
            {
                Assert.Equal(expected, actualSpan[i], ColorSpaceComparer);
            }
        }
        public void Convert_YCbCr_to_CieLab(float y, float cb, float cr, float l, float a, float b)
        {
            // Arrange
            var input    = new YCbCr(y, cb, cr);
            var expected = new CieLab(l, a, b);

            Span <YCbCr> inputSpan = new YCbCr[5];

            inputSpan.Fill(input);

            Span <CieLab> actualSpan = new CieLab[5];

            // Act
            var actual = Converter.ToCieLab(input);

            Converter.Convert(inputSpan, actualSpan, actualSpan.Length);

            // Assert
            Assert.Equal(expected, actual, ColorSpaceComparer);

            for (int i = 0; i < actualSpan.Length; i++)
            {
                Assert.Equal(expected, actualSpan[i], ColorSpaceComparer);
            }
        }
        public void Convert_Xyz_to_Lab(float x, float y, float z, float l, float a, float b)
        {
            // Arrange
            var input   = new CieXyz(x, y, z);
            var options = new ColorSpaceConverterOptions {
                WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65
            };
            var converter = new ColorSpaceConverter(options);
            var expected  = new CieLab(l, a, b);

            Span <CieXyz> inputSpan = new CieXyz[5];

            inputSpan.Fill(input);

            Span <CieLab> actualSpan = new CieLab[5];

            // Act
            var actual = converter.ToCieLab(input);

            converter.Convert(inputSpan, actualSpan);

            // Assert
            Assert.Equal(expected, actual, ColorSpaceComparer);

            for (int i = 0; i < actualSpan.Length; i++)
            {
                Assert.Equal(expected, actualSpan[i], ColorSpaceComparer);
            }
        }
        public void Convert_Lch_to_Lab(float l, float c, float h, float l2, float a, float b)
        {
            // Arrange
            CieLch input = new CieLch(l, c, h);

            // Act
            CieLab output = Converter.ToCieLab(input);

            // Assert
            Assert.Equal(l2, output.L, FloatRoundingComparer);
            Assert.Equal(a, output.A, FloatRoundingComparer);
            Assert.Equal(b, output.B, FloatRoundingComparer);
        }
        public void Convert_Xyz_to_Lab(float x, float y, float z, float l, float a, float b)
        {
            // Arrange
            var input     = new CieXyz(x, y, z);
            var converter = new ColorSpaceConverter {
                WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65
            };

            // Act
            var output = converter.ToCieLab(input);

            // Assert
            Assert.Equal(l, output.L, FloatRoundingComparer);
            Assert.Equal(a, output.A, FloatRoundingComparer);
            Assert.Equal(b, output.B, FloatRoundingComparer);
        }
Example #9
0
 public float ColorSpaceConvert()
 {
     return(ColorSpaceConverter.ToCieLab(CieXyz).L);
 }