Re: [Gimp-docs] Feedback on first pushed commits



On 04/28/2017 04:35 AM, Marco Ciampa via gimp-docs-list wrote:

Is this right?

src/menus/colors/desaturate/desaturate.xml:108(phrase)

        <para>The shades of gray will be calculated as</para>
          <informalequation>
            <mediaobject>
              <textobject>
                <phrase>
                  Lightness (HSL)) = &frac12; &times; (max(R,G,B) + min(R,G,B))
                </phrase>
              </textobject>
            </mediaobject>
          </informalequation>
        </listitem>


If you mean the formula for Lightness, it's correct:

From 2.8 docs:
Lightness

    The graylevel will be calculated as
    Lightness = ½ × (max(R,G,B) + min(R,G,B))

From posted 2.9 docs:
Lightness (HSL)

    The shades of gray will be calculated as
    Lightness (HSL)) = ½ × (max(R,G,B) + min(R,G,B))

From Wikipedia (https://en.wikipedia.org):
In the HSL "bi-hexcone" model, lightness is defined as the average of the largest and smallest color components (fig. 12c).

From GIMP code (app/operations/gimpoperationdesaturate.c):
    case GIMP_DESATURATE_LIGHTNESS:
      /* This is the formula for Lightness in the HSL "bi-hexcone"
       * model: https://en.wikipedia.org/wiki/HSL_and_HSV
       */
      while (samples--)
        {
          gfloat min, max, value;

          max = MAX (src[0], src[1]);
          max = MAX (max, src[2]);
          min = MIN (src[0], src[1]);
          min = MIN (min, src[2]);

          value = (max + min) / 2;

Not to be confused with LAB/LCH Lightness, which is calculated from XYZ, not from RGB (http://brucelindbloom.com/index.html?Eqn_XYZ_to_Lab.html).

Best,
Elle


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]