Last modified: 13 Jan 2022

URL: https://cxc.cfa.harvard.edu/ciao/threads/auxlut/

Using Contrib Color Look-Up Tables

CIAO 4.16 Science Threads


Overview

Synopsis:

Users can follow this thread if they wish to use the contributed color look-up tables in ds9, matplotlib, or dmimg2jpg.

Purpose:

One of the easiest customizations that users can do in CIAO is to use a non-standard color look-up table (LUT) or some times called color map.

Beyond the aesthetics of a particular color choice, different LUT's can be used to convey additional meaning: highlighting certain regions, emphasizing gradients, and provide additional reference between datasets.

This thread will show you how to load the contributed color look-up tables into ds9, matplotlib, and dmimg2jpg

Related Links:

Last Update: 13 Jan 2022 - Review for CIAO 4.14. No changes.


Contents


Get Started

Download the sample data: 214 (CAS A)

unix% download_chandra_obsid 214 evt2

Background Information

Many different fields of science rely on different color look-up tables (LUT's): medical imaging, cartography, meteorology, fluid dynamics, as well as astronomy. It is not surprising then that there are many different color maps available. The largest repository seems to be cpt-city which has 100's of different color maps from both the scientific community as well as the realm of artistic/graphic-design. ds9 version 7 now has a direct link to cpt-city and all their color maps are now available in ds9's .sao format.

The color map chosen is up to the user to decide based on what information they are trying to convey. For most scientific purposes, the only common restriction would be that colors are unique: having the color "white" show up at both a low intensity level and a high pixel intensity level in the color map may lead to ambiguity. This is not an absolute rule as one may choose to obscure certain regimes of the data with the same color to draw focus on a different area.

Examples of which color map to use when

If one were to have an image whose pixels represent the incident integrated flux, a colored gradient, one maybe chosen to symbolically match the energy band pass, may be a good choice (Figure 1 and Figure 2). An image showing temperatures is often shown using a rainbow color scheme (Figure 3). And an image showing color, that is the ratio of two images in different energy bands, may best be shown with a color map that smoothly varies between two colors (Figure 4).

Figure 1: Image of Low Energy Events

[Thumbnail image: ]

[Version: full-size]

[Print media version: ]

Figure 1: Image of Low Energy Events

This smoothed image shows the number of counts at low energies. The color red symbolically represents low energies and the gradation from black through red to white represent intensity.

Figure 2: Image of High Energy Events

[Thumbnail image: ]

[Version: full-size]

[Print media version: ]

Figure 2: Image of High Energy Events

This smoothed image shows the number of counts at high energies. The color blue symbolically represents high energies and the gradation from black through blue to white represent intensity. Note in particular the bright bulge seen south east of the center (lower right) compared to the low energy image.

Figure 3: Pseudo Temperature Map

[Thumbnail image: ]

[Version: full-size]

[Print media version: ]

Figure 3: Pseudo Temperature Map

This smoothed image shows the mean energy of the events in each pixel. Red and white pixels represent events with low mean energy (cooler) while green and blue pixels represent regions where events have higher mean energy (hotter) which is concentrated in the same bulge seen in Figure 2.

Figure 4: Hardness Ratio

[Thumbnail image: ]

[Version: full-size]

[Print media version: ]

Figure 4: Hardness Ratio

The hardness ratio (ratio of high energy to low energy events) is another way to communicate energy dependence in a dataset. As it represents a transition between two states (hard and soft, or high energy and low energy), a color map that varies between two colors is a natural choice. Here again we have chosen a color map with red representing low energies and blue representing high energies.


Contributed Look-Up Tables

These LUT's were extracted from two different software package and the data were reformatted to ds9's .lut format.

  • HEAsoft's XImage package, a multi-mission X-ray image display and analysis program
  • National Institutes of Health's ImageJ package, a public domain Java image processing program inspired by [National Institutes for Health] Image.

Note: Some of these color maps may be identical or nearly identical to one or more of those already available in ds9, matplotlib, or dmimg2jpg

XImage

grey
Click on colorbars to see example.
bbximage_bb
blue1blue1
blue2blue2
blue3blue3
blue4blue4
bluebase1bluebase1
bluebase2bluebase2
bluebase3bluebase3
bluebase4bluebase4
bluebase5bluebase5
bluebase6bluebase6
bluebase7bluebase7
bluebase8bluebase8
bluebase9bluebase9
bluyelbluyel
brownbrown
eyellow1eyellow1
gray1gray1
gray2gray2
green1green1
green2green2
green3green3
green4green4
green5green5
green6green6
green7green7
green8green8
green9green9
invgrayinvgray
invgray1invgray1
invspecinvspec
pink1pink1
pink2pink2
pink3pink3
pink4pink4
pinkbase1pinkbase1
pinkbase2pinkbase2
pinkbase3pinkbase3
pinkbase4pinkbase4
pinkbase5pinkbase5
purbypurby
purple1purple1
purple2purple2
purple3purple3
purple4purple4
purybpuryb
red1red1
red2red2
redbase1redbase1
redbase2redbase2
redbase3redbase3
redbase4redbase4
redbase5redbase5
redbase6redbase6
rgb4rgb4
rgb6rgb6
spectrumspectrum
vt1vt1
vt2vt2
vt3vt3
vt4vt4
vt5vt5
vt6vt6
vt7vt7
yellow1yellow1
yyyy

ImageJ

grey
Click on colorbars to see example.
000-gray000-gray
001-fire001-fire
002-spectrum002-spectrum
003-ice003-ice
004-phase004-phase
005-random005-random
16_colors16_colors
16_equal16_equal
16_ramps16_ramps
20_colors20_colors
32_colors32_colors
5_ramps5_ramps
6_reserved_colors6_reserved_colors
6_shades6_shades
amberamber
auxctqauxctq
blue_orangeblue_orange
blue_orange_icbblue_orange_icb
brainbrain
brgbcmywbrgbcmyw
cellscells
cequalcequal
cmy-cyancmy-cyan
cmy-magnetacmy-magneta
cmy-yellowcmy-yellow
cmycmy
coldcold
cti_rascti_ras
edgesedges
gem-16gem-16
gem-256gem-256
goldgold
gyr_centregyr_centre
heartheart
huehue
hue_ramps_08hue_ramps_08
hue_ramps_16hue_ramps_16
icoolicool
imaniman
invert_grayinvert_gray
isocontourisocontour
log_downlog_down
log_uplog_up
mixedmixed
neon-blueneon-blue
neon-greenneon-green
neon-magentaneon-magenta
neon-redneon-red
pastelpastel
rgb-bluergb-blue
rgb-greenrgb-green
rgb-redrgb-red
royalroyal
sepiasepia
siemenssiemens
smartsmart
split_blackblue_redwhitesplit_blackblue_redwhite
split_blackwhite_gesplit_blackwhite_ge
split_blackwhite_warmmetalsplit_blackwhite_warmmetal
split_bluered_warmmetalsplit_bluered_warmmetal
system_lutsystem_lut
thal_16thal_16
thal_256thal_256
thalliumthallium
topographytopography
unionjackunionjack
vividvivid
warholwarhol

How to Use Contributed LUT's

All the color look-up tables will be located in $ASCDS_CONTRIB/data. You can access them by name by using the ximage_lut.par and imagej_lut.par parameter files.

unix% plist ximage_lut

Parameters for /soft/ciao-4.4/contrib/param/ximage_lut.par

#
# Color Lookup Tables extracted from NASA XImage package
#
#    http://heasarc.gsfc.nasa.gov/xanadu/ximage/ximage.html
#
# converted to the ".lut" format used by ds9, chips, and dmimg2jpg
#
#
           (bb = ${ASCDS_CONTRIB}/data/bb.lut -> /soft/ciao-4.4/contrib/data/bb.lut) Color Lookup Table
        (blue1 = ${ASCDS_CONTRIB}/data/blue1.lut -> /soft/ciao-4.4/contrib/data/blue1.lut) Color Lookup Table
        (blue2 = ${ASCDS_CONTRIB}/data/blue2.lut -> /soft/ciao-4.4/contrib/data/blue2.lut) Color Lookup Table
        (blue3 = ${ASCDS_CONTRIB}/data/blue3.lut -> /soft/ciao-4.4/contrib/data/blue3.lut) Color Lookup Table
        (blue4 = ${ASCDS_CONTRIB}/data/blue4.lut -> /soft/ciao-4.4/contrib/data/blue4.lut) Color Lookup Table
  ...

unix% plist imagej_lut

Parameters for /export/ciao-4.4/contrib/param/imagej_lut.par

#
#
# Color Lookup Tables extracted from the NIH's ImageJ package
#
#  http://rsbweb.nih.gov/ij/
#  
# converted to the ".lut" format used by ds9, chips, and dmimg2jpg
#
     (000-gray = ${ASCDS_CONTRIB}/data/000-gray.lut -> /export/ciao-4.4/contrib/data/000-gray.lut) Color Lookup Table
     (001-fire = ${ASCDS_CONTRIB}/data/001-fire.lut -> /export/ciao-4.4/contrib/data/001-fire.lut) Color Lookup Table
 (002-spectrum = ${ASCDS_CONTRIB}/data/002-spectrum.lut -> /export/ciao-4.4/contrib/data/002-spectrum.lut) Color Lookup Table
      (003-ice = ${ASCDS_CONTRIB}/data/003-ice.lut -> /export/ciao-4.4/contrib/data/003-ice.lut) Color Lookup Table
   ...

Using contributed LUT's in ds9

As with most things in ds9, there are at least 3 different ways to load a new color map: via the GUI, on the command line, and via XPA. Only the first two are shown here.

On the command line, you use the -cmap load command

unix% ds9 acisf00214N000_evt2.fits -cmap load $ASCDS_CONTRIB/data/heart.lut

Figure 5: ImageJ "heart" LUT in ds9

[Thumbnail image: ]

[Version: full-size]

[Print media version: ]

Figure 5: ImageJ "heart" LUT in ds9

The "heart" color look-up table from ImageJ being used in ds9. The data have been smoothed with a 3 pixel Gaussian.

Alternatively, in the ds9 GUI, you can load the color map by going to Color -> Colomap Parameters ... In the sub-window, then go to File -> Load Colormap ..., navigate to the CIAO contrib/data directory and select the file name.

When a custom color map is loaded, it will be available under the top level "Color" menu. Prior to version 7, the name of the new color map would simply be appended to the list of those built-in. In version 7, custom color maps have their own sub-menu.


Using contributed LUT's in matplotlib

In this example we use the parameter module to retrieve the file name from the imagej_lut.par file. We then parse this file into the red, green, blue, and alpha (transparency) channels used by the ListedColormap class.

% python

import paramio as pio
from pycrates import read_file
import matplotlib.pylab as plt
from matplotlib.colors import ListedColormap

heart_lut = pio.pget("imagej_lut", "heart")
tab = open(heart_lut,"r").readlines()
rgb = [ x.strip().split() for x in tab if not x.startswith("#")]
rgba= [ [float(x[0]),float(x[1]),float(x[2]),1.0] for x in rgb ]
heart_lut_cmap = ListedColormap(rgba)

img = read_file('img_sm_asinh.fits')
imgvals = img.get_image().values
plt.imshow(imgvals, origin='lower', cmap=heart_lut_cmap)
plt.savefig("matplotlib.png")

Figure 6: ImageJ "heart" LUT in matplotlib

[Thumbnail image: ]

[Version: full-size]

[Print media version: ]

Figure 6: ImageJ "heart" LUT in matplotlib

The "heart" color look-up table from ImageJ being used in matplotlib. The input file was created by applying an asinh transform to a smoothed image from the event file using dmimgcalc.

Note: the data are shown in logical image pixel coordinates.


Using contributed LUT's in dmimg2jpg

The look-up table can be fed directly to dmimg2jpg. In the follow example we make use of a parameter redirect to locate the file name.

unix% dmimg2jpg infile=img_sm.fits outfile=img_sm.jpg \
  lutfile=")imagej_lut.heart" \
  scalefun=log mode=h clobber=yes

Figure 7: ImageJ "heart" LUT in dmimg2jpg

[Thumbnail image: ]

[Version: full-size]

[Print media version: ]

Figure 7: ImageJ "heart" LUT in dmimg2jpg

The "heart" color look-up table from ImageJ being used in dmimg2jpg.

History

10 Oct 2012 Initial version.
13 Dec 2012 Review for CIAO 4.5; added note about adding color bar via chips gui and added several inf@Vis articles on the use of color to the Related Links section.
24 Apr 2013 To avoid a naming conflict, ximage.par and imagej.par have been renamed ximage_lut.par and imagej_lut.par
25 Nov 2013 Review for CIAO 4.6.
16 Dec 2014 Reviewed for CIAO 4.7; no changes.
01 Feb 2016 Updated ds9 links.
29 Dec 2016 Reviewed for CIAO4.9. No changes.
28 Mar 2019 Updated to use matplotlib.
13 Jan 2022 Review for CIAO 4.14. No changes.