I already have a reference colormap in the form of a raster image (basically, the vertical extrusion on a 1D colormap). How can I use it to colorise a grey-level image in GIMP ?

If gradients or palettes are the way, I see quite raw editors, but no way to import or paste a raster image.

  • 1
    Have you tried to write directly a gradient in ggr format? See also here. – Paolo Gibellini May 16 '16 at 10:58
  • Well, I would expect at least a plugin to generate it from a (1D) RGB image. As a Gimp user, I need on the shelft solutions (even with complicated workflow). If I have to do it as a programmer, then I don't do it in Gimp. Thanks for the interesting refs, anyway ! – Fabrice NEYRET May 18 '16 at 6:24
  • I agree with you, a well ready solution is always the best thing, but I'm sorry at the moment I don't know whether such a plugin exists or not. GIMP is a community-driven software, so I suggest you to request for a new feature, or to report as a bug that the colors are sorted, or to dedicate some of your time and write a little plugin. – Paolo Gibellini May 18 '16 at 11:34

If you open up the palettes tab Windows->Dockable Dialogs->Palettes , you will note that the colormap for any opened indexed image is ready to be used as a palette (if you want such a palette to become a permanent asset, just use the duplicate button on it, available at the bottom of the dialog).

To use those colors on another image, there are two options:

1 - color likeness mapping: Starting with an image in RGB mode (convert its mode back to RGB if it is indexed or grayscale, Image->Mode->RGB), convert the image to indexed - Image->Mode->Indexed - on the dialog that shows, pick the option to Use custom palette and choose the Palette of your source image. If you need the palette from the source image to be in a particular order other than the one it is put in (for example, ascending value of colors), duplicate the colormap palette of your source image (so that it is independently editable) and on the context menu of the Palette list dialog, use the Sort palette... option.

2 - color by color index number: With your target image already in indexed mode (convert to indexed as above, but use Generate optimum palette instead), use the option Colors->Map->Set Color Map... and pick the palette that represents the colormap of your source image.

3 - For mapping the Value (HSV) from your target image to colors on the corresponding indexes of the target palette (as opposed to a proximity algorithm that includes Hue like (1) or overwritting the color map, as in (2): convert your target image to grayscale (Image->mode->grayscale) and them use Colors->Map->Palette Map

| improve this answer | |
  • Thanks, looks very promising ! But my "colormap.rgb" raster image seems not to be transfered as such in gimp palette when using "make optimal palette": colors in the palette get sorted, which breaks the targetted effect. Or did I missundertood your instructions ? – Fabrice NEYRET May 15 '16 at 8:02
  • My instructions are correct - they just don't cover your use case. WHich order should GIMP keep for the palette? How is it supposed to "know" that order? Unless you load an already indexed image into it, you will have to code the transfer of the source image colors to a palette yourself - maybe using some Python scripting. – jsbueno May 15 '16 at 22:33
  • Well, my question was just "how to apply or load a colormap encoded as an image", which might translate into "how to load a gradient or palette as 1D rgb image, LUT(value) being encoded as img(x/xmax)". Maybe the answer is just that it is not possible in Gimp / no plugin is offering that (beside scripting). But I couln't know before an expert tells it. Thanks for that. (So I used an Octave script, but it's a bit tedious). – Fabrice NEYRET May 16 '16 at 7:23
  • I updated the text with information on 1) how to sort the source color-map palette and 2) How to do the mapping using the value of the target color. – jsbueno May 16 '16 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.