I’m trying to write a program to read GIMP curves files and apply them to an image. I have successfully implemented the curves for the red, green and blue channels, but I can’t get it working for the value pseudochannel.
For the colour channels I just create a lookup table from the curves, and iterate through the pixels doing something like:
red = redlookup[red]
green = greenlookup[green]
blue = bluelookup[blue]
Good so far, I get exactly the same results in my program and GIMP.
In the GIMP page linked above, it is claimed that the value channel is defined as v = max(r, g, b)
but I don’t understand how to adjust each colour channel from looking up this value. I’m currently knee deep in GIMP source code but it is quite convoluted.
In summary: if I have an array valuelookup
representing the curve for the value pseudochannel, how can I use it to adjust the RGB values for each pixel in an image?
GIMP defines the channels as follows:
Value
The curve represents the Value, i.e. the brightness of pixels as you can see them in the composite image.
Red; Green; Blue
The curve represents the quantity of color in each of the three RGB channels. Here, dark means little of the color. Light means a lot of the color.
The values range from 0 to 255.
4