Gimp-Forum.net

Full Version: How do I copy/map pixel brightness to hue?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wish to process grayscale images, and convert the gray shades (brightness 0-255) to hue (0-255), pixel for pixel.

More control over the color mapping is better, but I can make do with that by modifying the grayscale image first.

I can find no mention of such an operation. Am I missing something obvious? Is there a way for the GIMP to do this? Is there a plugin that will do it?
Starting with a color image:

  • Colors > Components > Decompose to HSL or HSV
  • Copy/paste the Value/lightness layer into the "hue" layers
  • Colors > Components > Recompose
[attachment=10464]

However if you start with a grayscale image, you will find that the Hue and Saturation layers are initially black (because gray has no specific hue and its saturation is 0), so if you recompose the image at this point you get the same image (because even if you changed the Hue, the saturation is still 0). So if you want to see color, you have to bucket-fill the saturation layer with some non-zero value (255 for full saturation in the image below) before you recompose:

[attachment=10465]

And perhaps you also want to bucket fill the luminosity layer to some uniform value (some medium gray):

[attachment=10468]
or at least reduce its constrast:

[attachment=10467]

It is quite a coincidence that in this picture, midtones (that are mostly the green hills) are converted to green which is half-way in the hue circle.
Nifty. Thanks. I found it may be possible through GEGL, but this looks a lot simpler, and uses more familiar tools.