Saturday, April 25, 2015

Use imagemagick to apply a GIMP gradient colormap (.ggr file)

I love using JHelioviewer to create amazing videos of the Sun using pictures from SDO (the Solar Dynamics Observatory).

However, jHelioviewer has a maximum of 1000 frames -- which is about 3 or 4 hours of SDO images (if you use every image taken). Another problem is that is nearly impossible in jHelioviewer to crop the frame in an exact way.

I already knew how to create a movie from a sequence of images using ffmpeg. However, the AIA images you download from SDO JSOC are grayscale; i.e. they don't have the standard SDO color maps.

JHelioviewer applies the SDO color maps using these GIMP gradient files, but I didn't know how to use imagemagick to apply GIMP gradient color maps.

ImageMagick can apply color maps, but they must be in the form of a color lookup table (CLUT) image. But how does one convert a ggr file (a text file!) to a CLUT image? I found a lot of examples on the web on how to convert a CLUT to a GGR, but not the other way around.

According to this jHelioviewer wiki page, you can export the color tables from jHelioviewer using exportColorTables.java somehow, but I didn't feel like figuring out how to compile it -- and also I didn't want to install the JDK.

So I posted a question on the imagemagick forums. You can go read the forum if you like, but I've summarized it here:

  1. Create a standard hald clut image using the imagemagick program "convert" from the command line:
    1. convert hald:8 hald.png
  2. Install GIMP
    1. Install ggr files in your GIMP configuration directory (on Windows 7 this is %USERPROFILE%\.gimp-2.8\gradients)
  3. Start GIMP and open hald.png
  4. Select All
  5. In the Layers Dialog, select the Gradient Tool, then select the desired gradient
  6. Apply the gradient by selecting Colors -> Map -> Gradient Map
  7. Export the file by selecting File -> Export As ... (save it as a PNG or BMP)
The resulting hald CLUT images are here:

Now, to apply any of the above color maps to a grayscale image, you do, e.g.:

convert gray-image.jp2 sdo-aia-171-colormap.png -hald-clut color-output.jpg

No comments:

Post a Comment