I found a bug in Gimp's preserve luminosity feature located in the color balance tool (code is in color-balance.c).

The easiest way to see the bug is to turn on preserve luminosity and adjust R G B to any amount that is equal. The result should be no change to the image at all because they should cancel each other out and the brightness should stay the same due to PL.

Any ideas on why the current PL feature isn't working correctly. At a first glance the code method for doing this looks ok... I'm not sure about the function "gimp_rgb_to_l_int" however. Specifically, I'm not sure if this is the correct formula to find the lightness. Why would it not be:

L = (R + G + B) / 3

I tried making this change, but it looks even worse. This code chunk might not be the issue, but it's the first thing that jumped out at me. Any suggestions?

- Sean

==================
snip from color-balance.c
==================
/**
 * gimp_rgb_to_l_int:
 * @red: Red channel
 * @green: Green channel
 * @blue: Blue channel
 *
 * Calculates the lightness value of an RGB triplet with the formula
 * L = (max(R, G, B) + min (R, G, B)) / 2
 *
 * Return value: Luminance vaue corresponding to the input RGB value
 **/
int
gimp_rgb_to_l_int (int red,
           int green,
           int blue)
{
  int min, max;

  if (red > green)
    {
      max = MAX (red,   blue);
      min = MIN (green, blue);
    }
  else
    {
      max = MAX (green, blue);
      min = MIN (red,   blue);
    }

  return ROUND ((max + min) / 2.0);
}

_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

Reply via email to