mirror of https://github.com/SixLabors/ImageSharp
3 changed files with 216 additions and 0 deletions
@ -0,0 +1,72 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieLuv"/>-<see cref="Lms"/> conversions.
|
|||
/// </summary>
|
|||
public class CieLuvAndLmsConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002F); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(36.0555, 93.6901, 10.01514, 0.164352, 0.03267485, 0.0483408)] |
|||
public void Convert_CieLuv_to_Lms(float l, float u, float v, float l2, float m, float s) |
|||
{ |
|||
// Arrange
|
|||
CieLuv input = new(l, u, v); |
|||
Lms expected = new(l2, m, s); |
|||
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetWhitePoint = Illuminants.D65 }; |
|||
ColorProfileConverter converter = new(options); |
|||
|
|||
Span<CieLuv> inputSpan = new CieLuv[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<Lms> actualSpan = new Lms[5]; |
|||
|
|||
// Act
|
|||
Lms actual = converter.Convert<CieLuv, Lms>(input); |
|||
converter.Convert<CieLuv, 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.164352, 0.03267485, 0.0483408, 36.0555, 93.69009, 10.01514)] |
|||
public void Convert_Lms_to_CieLuv(float l2, float m, float s, float l, float u, float v) |
|||
{ |
|||
// Arrange
|
|||
Lms input = new(l2, m, s); |
|||
CieLuv expected = new(l, u, v); |
|||
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetWhitePoint = Illuminants.D65 }; |
|||
ColorProfileConverter converter = new(options); |
|||
|
|||
Span<Lms> inputSpan = new Lms[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieLuv> actualSpan = new CieLuv[5]; |
|||
|
|||
// Act
|
|||
CieLuv actual = converter.Convert<Lms, CieLuv>(input); |
|||
converter.Convert<Lms, CieLuv>(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,72 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieLuv"/>-<see cref="Rgb"/> conversions.
|
|||
/// </summary>
|
|||
public class CieLuvAndRgbConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002F); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 0, 0)] |
|||
[InlineData(36.0555, 93.6901, 10.01514, 0.6444615, 0.1086071, 0.2213444)] |
|||
public void Convert_CieLuv_to_Rgb(float l, float u, float v, float r, float g, float b) |
|||
{ |
|||
// Arrange
|
|||
CieLuv input = new(l, u, v); |
|||
Rgb expected = new(r, g, b); |
|||
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetWhitePoint = Illuminants.D65 }; |
|||
ColorProfileConverter converter = new(options); |
|||
|
|||
Span<CieLuv> inputSpan = new CieLuv[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<Rgb> actualSpan = new Rgb[5]; |
|||
|
|||
// Act
|
|||
Rgb actual = converter.Convert<CieLuv, Rgb>(input); |
|||
converter.Convert<CieLuv, 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.6444615, 0.1086071, 0.2213444, 36.0555, 93.69012, 10.01514)] |
|||
public void Convert_Rgb_to_CieLuv(float r, float g, float b, float l, float u, float v) |
|||
{ |
|||
// Arrange
|
|||
Rgb input = new(r, g, b); |
|||
CieLuv expected = new(l, u, v); |
|||
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetWhitePoint = Illuminants.D65 }; |
|||
ColorProfileConverter converter = new(options); |
|||
|
|||
Span<Rgb> inputSpan = new Rgb[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieLuv> actualSpan = new CieLuv[5]; |
|||
|
|||
// Act
|
|||
CieLuv actual = converter.Convert<Rgb, CieLuv>(input); |
|||
converter.Convert<Rgb, CieLuv>(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,72 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests <see cref="CieLuv"/>-<see cref="YCbCr"/> conversions.
|
|||
/// </summary>
|
|||
public class CieLuvAndYCbCrConversionTests |
|||
{ |
|||
private static readonly ApproximateColorProfileComparer Comparer = new(.0002F); |
|||
|
|||
[Theory] |
|||
[InlineData(0, 0, 0, 0, 128, 128)] |
|||
[InlineData(36.0555, 93.6901, 10.01514, 71.8283, 119.3174, 193.9839)] |
|||
public void Convert_CieLuv_to_YCbCr(float l, float u, float v, float y, float cb, float cr) |
|||
{ |
|||
// Arrange
|
|||
CieLuv input = new(l, u, v); |
|||
YCbCr expected = new(y, cb, cr); |
|||
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetWhitePoint = Illuminants.D65 }; |
|||
ColorProfileConverter converter = new(options); |
|||
|
|||
Span<CieLuv> inputSpan = new CieLuv[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<YCbCr> actualSpan = new YCbCr[5]; |
|||
|
|||
// Act
|
|||
YCbCr actual = converter.Convert<CieLuv, YCbCr>(input); |
|||
converter.Convert<CieLuv, 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(71.8283, 119.3174, 193.9839, 36.00565, 93.44593, 10.2234)] |
|||
public void Convert_YCbCr_to_CieLuv(float y, float cb, float cr, float l, float u, float v) |
|||
{ |
|||
// Arrange
|
|||
YCbCr input = new(y, cb, cr); |
|||
CieLuv expected = new(l, u, v); |
|||
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetWhitePoint = Illuminants.D65 }; |
|||
ColorProfileConverter converter = new(options); |
|||
|
|||
Span<YCbCr> inputSpan = new YCbCr[5]; |
|||
inputSpan.Fill(input); |
|||
|
|||
Span<CieLuv> actualSpan = new CieLuv[5]; |
|||
|
|||
// Act
|
|||
CieLuv actual = converter.Convert<YCbCr, CieLuv>(input); |
|||
converter.Convert<YCbCr, CieLuv>(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