且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CIELAB 颜色空间中的坐标范围是多少?

更新时间:2022-06-09 05:21:49

实际上所有可能的 RGB 颜色的数量是有限的,所以 L*a*b* 空间是有界的.使用以下简单程序很容易找到坐标范围:

In practice the number of all possible RGB colours is finite, so the L*a*b* space is bounded. It is easy to find the ranges of coordinates with the following simple program:

Color c;

double maxL = double.MinValue;
double maxA = double.MinValue;
double maxB = double.MinValue;
double minL = double.MaxValue;
double minA = double.MaxValue;
double minB = double.MaxValue;

for (int r = 0; r < 256; ++r)
    for (int g = 0; g < 256; ++g)
        for (int b = 0; b < 256; ++b)
        {
            c = Color.FromArgb(r, g, b);

            Lab lab = c.ToLab();

            maxL = Math.Max(maxL, lab.L);
            maxA = Math.Max(maxA, lab.A);
            maxB = Math.Max(maxB, lab.B);
            minL = Math.Min(minL, lab.L);
            minA = Math.Min(minA, lab.A);
            minB = Math.Min(minB, lab.B);
        }

Console.WriteLine("maxL = " + maxL + ", maxA = " + maxA + ", maxB = " + maxB);
Console.WriteLine("minL = " + minL + ", minA = " + minA + ", minB = " + minB);

或使用任何其他语言的类似语言.

or a similar one using any other language.

所以,CIELAB空间坐标范围如下:

So, CIELAB space coordinate ranges are as follows:

L in [0, 100]

L in [0, 100]

[-86.185, 98.254] 中的 A

A in [-86.185, 98.254]

[-107.863, 94.482] 中的 B

B in [-107.863, 94.482]

答案是:

Lab lab = c.ToLab();

result.Add(Tuple.Create(
    1.0 * lab.L / 100,
    1.0 * (lab.A + 86.185) / 184.439,
    1.0 * (lab.B + 107.863) / 202.345);