public void Convert_CieXyz_to_Hsv(float x, float y, float yl, float h, float s, float v) { // Arrange var input = new CieXyz(x, y, yl); var expected = new Hsv(h, s, v); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <Hsv> actualSpan = new Hsv[5]; // Act var actual = Converter.ToHsv(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_CieXyz_to_Cmyk(float x, float y2, float z, float c, float m, float y, float k) { // Arrange var input = new CieXyz(x, y2, z); var expected = new Cmyk(c, m, y, k); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <Cmyk> actualSpan = new Cmyk[5]; // Act var actual = Converter.ToCmyk(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); } }
[InlineData(0.95047, 1, 1.08883, 100, 0, 0)] // D65 white point is HunterLab 100, 0, 0 (adaptation to C performed) public void Convert_Xyz_D65_to_HunterLab(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 }; var converter = new ColorSpaceConverter(options); var expected = new HunterLab(l, a, b); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <HunterLab> actualSpan = new HunterLab[5]; // Act var actual = converter.ToHunterLab(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_CieXyz_to_CieLch(float x, float y, float yl, float l, float c, float h) { // Arrange var input = new CieXyz(x, y, yl); var expected = new CieLch(l, c, h); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <CieLch> actualSpan = new CieLch[5]; // Act var actual = Converter.ToCieLch(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_XYZ_D65_to_SRGB(float x, float y, float z, float r, float g, float b) { // Arrange var input = new CieXyz(x, y, z); var options = new ColorSpaceConverterOptions { WhitePoint = Illuminants.D65, TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb }; var converter = new ColorSpaceConverter(options); var expected = new Rgb(r, g, b); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <Rgb> actualSpan = new Rgb[5]; // Act var actual = converter.ToRgb(input); converter.Convert(inputSpan, actualSpan); // Assert Assert.Equal(Rgb.DefaultWorkingSpace, actual.WorkingSpace, ColorSpaceComparer); Assert.Equal(expected, actual, ColorSpaceComparer); for (int i = 0; i < actualSpan.Length; i++) { Assert.Equal(expected, actualSpan[i], ColorSpaceComparer); } }
public void Convert_CieXyz_to_Lms(float x, float y, float z, float l, float m, float s) { // Arrange var input = new CieXyz(x, y, z); var converter = new ColorSpaceConverter(); var expected = new Lms(l, m, s); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <Lms> actualSpan = new Lms[5]; // Act var actual = converter.ToLms(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_CieXyz_to_YCbCr(float x, float y, float z, float y2, float cb, float cr) { // Arrange var input = new CieXyz(x, y, z); var expected = new YCbCr(y2, cb, cr); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <YCbCr> actualSpan = new YCbCr[5]; // Act var actual = Converter.ToYCbCr(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_Xyz_to_Luv(float x, float y, float z, float l, float u, float v) { // 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 CieLuv(l, u, v); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <CieLuv> actualSpan = new CieLuv[5]; // Act var actual = converter.ToCieLuv(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 SingleAndBulkTransformYieldIdenticalResults(CieXyz sourceWhitePoint, CieXyz destinationWhitePoint) { var adaptation = new VonKriesChromaticAdaptation(); var input = new CieXyz(1, 0, 1); CieXyz expected = adaptation.Transform(input, sourceWhitePoint, destinationWhitePoint); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <CieXyz> actualSpan = new CieXyz[5]; adaptation.Transform(inputSpan, actualSpan, sourceWhitePoint, destinationWhitePoint); for (int i = 0; i < inputSpan.Length; i++) { Assert.Equal(expected, actualSpan[i], ColorSpaceComparer); } }
public void Convert_XYZ_to_xyY(float xyzX, float xyzY, float xyzZ, float x, float y, float yl) { var input = new CieXyz(xyzX, xyzY, xyzZ); var expected = new CieXyy(x, y, yl); Span <CieXyz> inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span <CieXyy> actualSpan = new CieXyy[5]; // Act var actual = Converter.ToCieXyy(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); } }