mirror of https://github.com/SixLabors/ImageSharp
4 changed files with 280 additions and 0 deletions
@ -0,0 +1,70 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieXyy"/>-<see cref="HunterLab"/> conversions.
|
|||
/// </summary>
|
|||
public class CieXyyAndHunterLabConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002f); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(0.360555, 0.936901, 0.1001514, 31.6467056, -33.00599, 25.67032)] |
|||
public void Convert_CieXyy_to_HunterLab(float x, float y, float yl, float l, float a, float b) |
|||
{ |
|||
// Arrange
|
|||
CieXyy input = new(x, y, yl); |
|||
HunterLab expected = new(l, a, b); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<CieXyy> inputSpan = new CieXyy[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<HunterLab> actualSpan = new HunterLab[5]; |
|||
|
|||
// Act
|
|||
HunterLab actual = converter.Convert<CieXyy, HunterLab>(input); |
|||
converter.Convert<CieXyy, HunterLab>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(31.6467056, -33.00599, 25.67032, 0.360555, 0.936901, 0.1001514)] |
|||
public void Convert_HunterLab_to_CieXyy(float l, float a, float b, float x, float y, float yl) |
|||
{ |
|||
// Arrange
|
|||
HunterLab input = new(l, a, b); |
|||
CieXyy expected = new(x, y, yl); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<HunterLab> inputSpan = new HunterLab[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieXyy> actualSpan = new CieXyy[5]; |
|||
|
|||
// Act
|
|||
CieXyy actual = converter.Convert<HunterLab, CieXyy>(input); |
|||
converter.Convert<HunterLab, CieXyy>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles.Conversion; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieXyy"/>-<see cref="Lms"/> conversions.
|
|||
/// </summary>
|
|||
public class CieXyyAndLmsConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002f); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(0.360555, 0.936901, 0.1001514, 0.06631134, 0.1415282, -0.03809926)] |
|||
public void Convert_CieXyy_to_Lms(float x, float y, float yl, float l, float m, float s) |
|||
{ |
|||
// Arrange
|
|||
CieXyy input = new(x, y, yl); |
|||
Lms expected = new(l, m, s); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<CieXyy> inputSpan = new CieXyy[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<Lms> actualSpan = new Lms[5]; |
|||
|
|||
// Act
|
|||
Lms actual = converter.Convert<CieXyy, Lms>(input); |
|||
converter.Convert<CieXyy, Lms>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(0.06631134, 0.1415282, -0.03809926, 0.360555, 0.936901, 0.1001514)] |
|||
public void Convert_Lms_to_CieXyy(float l, float m, float s, float x, float y, float yl) |
|||
{ |
|||
// Arrange
|
|||
Lms input = new(l, m, s); |
|||
CieXyy expected = new(x, y, yl); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<Lms> inputSpan = new Lms[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieXyy> actualSpan = new CieXyy[5]; |
|||
|
|||
// Act
|
|||
CieXyy actual = converter.Convert<Lms, CieXyy>(input); |
|||
converter.Convert<Lms, CieXyy>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieXyy"/>-<see cref="Rgb"/> conversions.
|
|||
/// </summary>
|
|||
public class CieXyyAndRgbConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002f); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(0.360555, 0.936901, 0.1001514, 0, 0.4277014, 0)] |
|||
public void Convert_CieXyy_to_Rgb(float x, float y, float yl, float r, float g, float b) |
|||
{ |
|||
// Arrange
|
|||
CieXyy input = new(x, y, yl); |
|||
Rgb expected = new(r, g, b); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<CieXyy> inputSpan = new CieXyy[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<Rgb> actualSpan = new Rgb[5]; |
|||
|
|||
// Act
|
|||
Rgb actual = converter.Convert<CieXyy, Rgb>(input); |
|||
converter.Convert<CieXyy, Rgb>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(0, 0.4277014, 0, 0.32114, 0.59787, 0.10976)] |
|||
public void Convert_Rgb_to_CieXyy(float r, float g, float b, float x, float y, float yl) |
|||
{ |
|||
// Arrange
|
|||
Rgb input = new(r, g, b); |
|||
CieXyy expected = new(x, y, yl); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<Rgb> inputSpan = new Rgb[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieXyy> actualSpan = new CieXyy[5]; |
|||
|
|||
// Act
|
|||
CieXyy actual = converter.Convert<Rgb, CieXyy>(input); |
|||
converter.Convert<Rgb, CieXyy>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieXyy"/>-<see cref="YCbCr"/> conversions.
|
|||
/// </summary>
|
|||
public class CieXyyAndYCbCrConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002f); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 128, 128)] |
|||
[InlineData(0.360555, 0.936901, 0.1001514, 64.0204849, 91.87107, 82.33627)] |
|||
public void Convert_CieXyy_to_YCbCr(float x, float y, float yl, float y2, float cb, float cr) |
|||
{ |
|||
// Arrange
|
|||
CieXyy input = new(x, y, yl); |
|||
YCbCr expected = new(y2, cb, cr); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<CieXyy> inputSpan = new CieXyy[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<YCbCr> actualSpan = new YCbCr[5]; |
|||
|
|||
// Act
|
|||
YCbCr actual = converter.Convert<CieXyy, YCbCr>(input); |
|||
converter.Convert<CieXyy, YCbCr>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 128, 128, 0, 0, 0)] |
|||
[InlineData(64.0204849, 91.87107, 82.33627, 0.32114, 0.59787, 0.10976)] |
|||
public void Convert_YCbCr_to_CieXyy(float y2, float cb, float cr, float x, float y, float yl) |
|||
{ |
|||
// Arrange
|
|||
YCbCr input = new(y2, cb, cr); |
|||
CieXyy expected = new(x, y, yl); |
|||
ColorProfileConverter converter = new(); |
|||
|
|||
Span<YCbCr> inputSpan = new YCbCr[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieXyy> actualSpan = new CieXyy[5]; |
|||
|
|||
// Act
|
|||
CieXyy actual = converter.Convert<YCbCr, CieXyy>(input); |
|||
converter.Convert<YCbCr, CieXyy>(inputSpan, actualSpan); |
|||
|
|||
// Assert
|
|||
Assert.Equal(expected, actual, Comparer); |
|||
|
|||
for (int i = 0; i < actualSpan.Length; i++) |
|||
{ |
|||
Assert.Equal(expected, actualSpan[i], Comparer); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue