What are the ranges of coordinates in the CIELAB color space?

折月煮酒 提交于 2019-11-30 01:58:38
BartoszKP

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.

So, CIELAB space coordinate ranges are as follows:

L in [0, 100]

A in [-86.185, 98.254]

B in [-107.863, 94.482]

and the answer is:

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);
bortizj

Normally, the following values work because it is the standard output of common color conversion algorithms:

  • L* axis (lightness) ranges from 0 to 100

  • a* and b* (color attributes) axis range from -128 to +127

More information can be found here.

If the Lab-conversion code is implemented in accord with the Lab-colors definition (see, for example Lab color space), then function f(...), which is used for defining L, a and b changes within [4/29,1], thefore

L = 116 * f(y) - 16 is in [0,100]
a = 500 * (f(x)-f(y)) is in [-500*25/29, 500*25/29]
b = 200 * (f(y)-f(z)) is in [-200*25/29, 200*25/29]

Some people (like bortizj in his reply) normalize these values to range, which a byte-variable can hold. So you have to analyze the code in order to determine, what range it produces. But again, the formulas in Wiki will give you the range above. The same range will give you the code here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!