Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I create a gradient map from an image? [solved]
#11
Thanks everybody. Combining everybody's suggestions here with a bunch of experiments got me the result I wanted. Rich2005's advice nearly got me there but I couldn't persuade the "sort palette" tool to do its job correctly. Anyway, I've documented the process this time, so I've added my notes below.

And to illustrate the result:

This image is a NASA solar flare photograph that had to have been colourized with a gradient map because these are captured at one wavelength -- but it's a good choice of colours (warning: 4096x4096 pix):

https://www.nasa.gov/sites/default/files...flare.jpeg

This NASA sunspot image is coloured blue for some reason:

https://www.nasa.gov/sites/default/files..._0131.jpeg

So using the first as a reference, I colorized the second to give:

https://i.imgur.com/yzhK8CG.jpg



Create gradient map from reference image for colourizing other images

---------------------------------------------------------------------
( The reference image should be a greycale image that had itself been
  colourized by somebody with a gradient map, so this process is
  intended to recreate the gradient map that had been used.)

Load reference image into Gimp.
file -> new -> 1024x64 (new image needs to be this wide for some reason)
view -> snap to canvas edges
foreground colour: black, background colour:white
blend tool -> shape: linear, no dithering, colour: FG to BG (RGB)
  drag mouse from bottom left to bottom right of new image
  (that gives greyscale gradient from back to white across the image)
colours -> map -> sample colourize:
  sample: reference image, destination: greyscale gradient image
  get samples, apply
colours -> info -> colourcube analysis
  (that shows 265 unique colours, which is the correct number already)
image -> mode -> indexed: optimum palette, 256 colours
windows -> dockable dialogue -> palette
  (this dialogue already shows the palette of the indexed-image at the top)
palettes -> right-click "colourmap of image #2" -> palette to gradient
windows -> dockable dialogues -> gradients
gradients -> double-click "colourmap of image #2 -> rename it -> enter

(Done. It's saved as the file ~/.gimp-2.8/gradients/thename.ggr and
 can now be used to colourize other images.)

Load image to be colourized into Gimp
gradients dialogue -> select required gradient map
colours -> map -> gradient map.
Done.
Reply
#12
With the process expounded above:
Starting with this:

   

Mapped with an ugly Blue-Red-Green gradient. The only constraint is that the Red middle color has a "Value" (in HSV) around 50, while Blue is closer to 0 and Green closer to 100 (because this kind of gradient-mapping normally preserves the luminosity curve)

   

Using the process, recover a gradient:

   

Apply the gradient again:

   

So the technique works decently, the trouble here is that the picture chosen has a lot of dark pixels, so the palette has more dark colors. On a more balanced image results ought to be better.
Reply
#13
Using the direct export palette, even after sorting the palette:

   

But maybe the gradient wasn't 100% V-increasing
Reply
#14
I think the key to making the technique work is to have an image that has the full range of luminosities from 0 to 255 so that there's at least a few pixels of each luminosity. A look at the colour "levels" (log view) of the moon image showed that the highest luminosity levels were mostly missing. I scaled levels 0-206 to 0-255 then rescaled the size to 90% which filled in any remaining gaps with Gaussian blur. I then applied the colour gradient that I'd got from the NASA solar flare image.

   

If the above image is desaturated, maintaining luminosity, then the two halves look almost identical.

   

I re-extracted the gradient map using my process from the right-hand moon and compared it with my original gradient map. Note that if the full range of luminosities is present in the gradient map, then it should go from full black to full white. They look identical to my eye, although a colourcube-analysis says that the number of colours in the combined image is almost doubled so it's not perfect.
Reply


Forum Jump: