Skip to content

Commit a7edf1b

Browse files
Some renaming and docs
1 parent 9fdf204 commit a7edf1b

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

src/ImageSharp/ColorProfiles/ColorConversionOptions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ColorConversionOptions
1818
/// <summary>
1919
/// Initializes a new instance of the <see cref="ColorConversionOptions"/> class.
2020
/// </summary>
21-
public ColorConversionOptions() => this.AdaptationMatrix = LmsAdaptationMatrix.Bradford;
21+
public ColorConversionOptions() => this.AdaptationMatrix = KnownChromaticAdaptationMatrices.Bradford;
2222

2323
/// <summary>
2424
/// Gets the memory allocator.
@@ -38,15 +38,16 @@ public class ColorConversionOptions
3838
/// <summary>
3939
/// Gets the source working space used for companding in conversions from/to XYZ color space.
4040
/// </summary>
41-
public RgbWorkingSpace RgbWorkingSpace { get; init; } = RgbWorkingSpaces.SRgb;
41+
public RgbWorkingSpace RgbWorkingSpace { get; init; } = KnownRgbWorkingSpaces.SRgb;
4242

4343
/// <summary>
4444
/// Gets the destination working space used for companding in conversions from/to XYZ color space.
4545
/// </summary>
46-
public RgbWorkingSpace TargetRgbWorkingSpace { get; init; } = RgbWorkingSpaces.SRgb;
46+
public RgbWorkingSpace TargetRgbWorkingSpace { get; init; } = KnownRgbWorkingSpaces.SRgb;
4747

4848
/// <summary>
4949
/// Gets the transformation matrix used in conversion to perform chromatic adaptation.
50+
/// <see cref="KnownChromaticAdaptationMatrices"/> for further information. Default is Bradford.
5051
/// </summary>
5152
public Matrix4x4 AdaptationMatrix
5253
{

src/ImageSharp/ColorProfiles/LmsAdaptationMatrix.cs renamed to src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@
66
namespace SixLabors.ImageSharp.ColorProfiles;
77

88
/// <summary>
9-
/// Matrices used for transformation from <see cref="CieXyz"/> to <see cref="Lms"/>, defining the cone response domain.
9+
/// Provides matrices for chromatic adaptation, facilitating the adjustment of color values
10+
/// under different light sources to maintain color constancy. This class supports common
11+
/// adaptation transforms based on the von Kries coefficient law, which assumes independent
12+
/// scaling of the cone responses in the human eye. These matrices can be applied to convert
13+
/// color coordinates between different illuminants, ensuring consistent color appearance
14+
/// across various lighting conditions.
1015
/// </summary>
1116
/// <remarks>
12-
/// Matrix data obtained from:
13-
/// Two New Von Kries Based Chromatic Adaptation Transforms Found by Numerical Optimization
14-
/// S. Bianco, R. Schettini
15-
/// DISCo, Department of Informatics, Systems and Communication, University of Milan-Bicocca, viale Sarca 336, 20126 Milan, Italy
16-
/// https://web.stanford.edu/~sujason/ColorBalancing/Papers/Two%20New%20von%20Kries%20Based%20Chromatic%20Adaptation.pdf
17+
/// Supported adaptation matrices include the Bradford, von Kries, and Sharp transforms.
18+
/// These matrices are typically used in conjunction with color space conversions, such as from XYZ
19+
/// to RGB, to achieve accurate color rendition in digital imaging applications.
1720
/// </remarks>
18-
public static class LmsAdaptationMatrix
21+
22+
public static class KnownChromaticAdaptationMatrices
1923
{
2024
/// <summary>
21-
/// Von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez adjusted for D65)
25+
/// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez adjusted for D65)
2226
/// </summary>
2327
public static readonly Matrix4x4 VonKriesHPEAdjusted
2428
= Matrix4x4.Transpose(new Matrix4x4
@@ -36,7 +40,7 @@ public static readonly Matrix4x4 VonKriesHPEAdjusted
3640
});
3741

3842
/// <summary>
39-
/// Von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez for equal energy)
43+
/// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez for equal energy)
4044
/// </summary>
4145
public static readonly Matrix4x4 VonKriesHPE
4246
= Matrix4x4.Transpose(new Matrix4x4

src/ImageSharp/ColorProfiles/RgbWorkingSpaces.cs renamed to src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

44
using SixLabors.ImageSharp.ColorProfiles;
@@ -10,7 +10,7 @@ namespace SixLabors.ColorProfiles;
1010
/// <summary>
1111
/// Chromaticity coordinates based on: <see href="http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html"/>
1212
/// </summary>
13-
public static class RgbWorkingSpaces
13+
public static class KnownRgbWorkingSpaces
1414
{
1515
/// <summary>
1616
/// sRgb working space.

tests/ImageSharp.Tests/ColorProfiles/RgbAndCieXyzConversionTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void Convert_XYZ_D50_To_SRGB(float x, float y, float z, float r, float g,
2828
{
2929
// Arrange
3030
CieXyz input = new(x, y, z);
31-
ColorConversionOptions options = new() { WhitePoint = Illuminants.D50, TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
31+
ColorConversionOptions options = new() { WhitePoint = Illuminants.D50, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb };
3232
ColorProfileConverter converter = new(options);
3333
Rgb expected = new(r, g, b);
3434

@@ -61,7 +61,7 @@ public void Convert_XYZ_D65_To_SRGB(float x, float y, float z, float r, float g,
6161
{
6262
// Arrange
6363
CieXyz input = new(x, y, z);
64-
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
64+
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb };
6565
ColorProfileConverter converter = new(options);
6666
Rgb expected = new(r, g, b);
6767

@@ -94,7 +94,7 @@ public void Convert_SRGB_To_XYZ_D50(float r, float g, float b, float x, float y,
9494
{
9595
// Arrange
9696
Rgb input = new(r, g, b);
97-
ColorConversionOptions options = new() { TargetWhitePoint = Illuminants.D50, RgbWorkingSpace = RgbWorkingSpaces.SRgb };
97+
ColorConversionOptions options = new() { TargetWhitePoint = Illuminants.D50, RgbWorkingSpace = KnownRgbWorkingSpaces.SRgb };
9898
ColorProfileConverter converter = new(options);
9999
CieXyz expected = new(x, y, z);
100100

@@ -127,7 +127,7 @@ public void Convert_SRGB_To_XYZ_D65(float r, float g, float b, float x, float y,
127127
{
128128
// Arrange
129129
Rgb input = new(r, g, b);
130-
ColorConversionOptions options = new() { TargetWhitePoint = Illuminants.D65, RgbWorkingSpace = RgbWorkingSpaces.SRgb };
130+
ColorConversionOptions options = new() { TargetWhitePoint = Illuminants.D65, RgbWorkingSpace = KnownRgbWorkingSpaces.SRgb };
131131
ColorProfileConverter converter = new(options);
132132
CieXyz expected = new(x, y, z);
133133

0 commit comments

Comments
 (0)