About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 02 Feb 2007
Hardcopy (PDF): A4 | Letter

Create A True Color Image in ds9

[CIAO 3.4 Science Threads]



Overview

Last Update: 02 Feb 2007 - new for CIAO 3.4: original version

Synopsis:

Most astronomical images map color to intensity level, e.g. lighter tones may correspond to a brighter intensity level in a greyscale image. An alternative way of presenting data is via an image that correllates color and energy.

SAOImage ds9, the imaging application distributed with CIAO, has the capability for users to create an RGB image and interactively adjust many of its parameters to achieve optimal results.

Purpose:

Use the ds9 imager to create a true color image.

Read this thread if:

you would like to apply a specific color table to filtered files in order to create a true color image. There are several output options, such as JPEG and PS, which are useful when producing images for the web and publication.

Related Links:

Proceed to the HTML or hardcopy (PDF: A4 | letter) version of the thread.




Contents



Get Started

Sample ObsID used: 198 (ACIS-S, CAS A (CHIP S3))



Create Input Files

First we need to create the input event files for dmimg2jpg. In this example, the following energy bands are used:

  • soft: 0.2-1.5 keV
  • medium: 1.5-2.5 keV
  • hard: 2.5-8.0 keV

dmcopy is used to create three filtered event files:

unix% punlearn dmcopy

unix% dmcopy infile="acisf00198N002_evt2.fits[energy=200:1500]" \
      outfile="red_198.fits"

unix% dmcopy infile="acisf00198N002_evt2.fits[energy=1500:2500]" \
      outfile="green_198.fits"

unix% dmcopy infile="acisf00198N002_evt2.fits[energy=2500:8000]" \
      outfile="blue_198.fits"

Since ds9 automatically bins the event file into an image for display, it is not necessary to apply any binning beforehand. This provides for further flexibility in manipulating the data in ds9.

Creating Fluxed Input

If there is significant exposure variation across your data, e.g. you are using both front- and back-illuminated ACIS chips or are working with a mosaic, consider creating fluxed FITS images as input for the true-color image.

To create fluxed input images:

  1. Filter the event list into three energy bands.

  2. Create an exposure map for each filtered event file by following the Single-Chip or Multiple-Chip ACIS Exposure Map thread. The monochromatic energy used in the mkinstmap step will be different for each energy band.

    After completing the thread, you will have three normalized images, one for each energy band.

  3. Use these fluxed images as input to this thread.

While creating exposure maps adds a non-trivial amount of time to the analysis, the image results can be significantly improved.



Creating an RGB Frame in ds9

To use the three-color capabilities of ds9, the data must be loaded into a special RGB frame. This frame will contain all three files, stacked together.

A. From the command line

The ds9 command-line syntax can be used to create the RGB frame and load the three filess in the correct bands:

unix% ds9 -rgb -red red_198.fits \
               -green green_198.fits \
	       -blue blue_198.fits &

ds9 will open with the three files in one frame, as shown in Figure 1 [Link to Image 1: RGB frame with three files loaded]; the "Scale" is set to "log: minmax". The RGB window [Link to Image 2: ds9 RGB window] should open as well. If it doesn't, open it from the "Frame -> RGB..." menu.

Use the binning and zoom options in ds9 to adjust the image so that the full region of interest is visible. This is similar to applying a spatial filter and binning specification when creating an image with dmcopy.

More information on the RGB command-line options is available from the ds9 Manual.


B. From the ds9 GUI

To load the files from the ds9 GUI:

  1. Launch ds9

  2. Choose "New Frame RGB" from the "Frame" menu.

    When the new frame is created, the RGB window [Link to Image 2: ds9 RGB window] should open as well. If it doesn't, open it from the "Frame -> RGB..." menu.

  3. Make sure the "Red" band is selected in the "Current" column of the RGB window, then choose "File -> Open..." in the main ds9 window and select the red (soft-band) file, red_198.fits.

  4. Change the current band to "Green" in the RGB window. Open the green (medium-band) file, green_198.fits, as you did for the red.

  5. Change the current band to "Blue" in the RGB window. Open the blue (hard-band) file, blue_198.fits, as you did for the red and green.

The resulting ds9 display is shown in Figure 1 [Link to Image 1: RGB frame with three files loaded]. The "Scale" is set to "log: minmax".

Use the binning and zoom options in ds9 to adjust the image so that the full region of interest is visible. This is similar to applying a spatial filter and binning specification when creating an image with dmcopy.



Smoothing the Data (optional)

Smoothing can help bring out finer features in the data by removing statistical noise. It is an optional step; experiment with smoothing to see if it improves the appearance of your data.

The smoothing capability in ds9 lets you interactively smooth the data, as opposed to running the CIAO tools aconvolve or csmooth. For quantitative data analysis, the configurable CIAO tools are more appropriate, but ds9 does a nice job for publication purposes.

Choose "Smooth" from the "Analysis" menu and the ds9 display is updated with the results of smoothing. The "Smooth" option can be toggled on and off during your ds9 session.

Open the "Smoothing Parameters..." dialog box from the same menu to adjust the function and kernel radius of the smoothing. The default smoothing is a Gaussian function with radius of three, which is fine for this data. The results are shown in Figure 3 [Link to Image 3: Data smoothed with a Gaussian of radius three].



Adjusting the Scale Parameters

This data is being displayed with a "log: minmax" scale. That means that ds9 stretches the scale to encompass the range of pixel values in the file. Adjusting the minimum and maximum scale values sets a threshold for the background data and brings out features.

To change the minimum and maximum values, open the "Scale -> Scale Parameters" dialog box. The pixel distribution shown is for the band selected as "Current" in the RGB window; change the current band selected and the histogram of pixel values is updated to match.

To adjust the values, use the cursor to grab the red (minimum) or green (maximum) vertical lines on the plot and drag them to the desired location. You can type a value in to the "Low" or "High" field and hit "Apply" to set the limits.

A basic guideline for setting the low value is to minimize the contribution of the background. That is, adjust the minimum of each band until the background of the image is flat (i.e. solid black). For the maximum value, bringing it in to the last data point in the pixel distribution is usually sufficient.

For ObsID 198 with the smoothing applied, the following limits were chosen:

Band Low High
Red 0.255 10
Green 0.255 18
Blue 0.0779 5

Figure 4 [Link to Image 4: The adjusted pixel distribution for scaling] shows the image with the new pixel value limits set.



More Display Options

There are a number of other options that can be added to the image display. The two most popular are overlaying a source list and including a coordinate grid.

Overlaying a Source List

To overlay a source list on a ds9 image:

  • ASCII files: load the region file from the ds9 menu "Regions" -> "Load Regions..." -> ascii_file.reg.

  • FITS files load the region file from the ds9 menu "Regions" -> "Load Regions..." -> fits_file.fits[REGION].

    Note that the block is not necessarily named REGION; the output of the detect tools have a SRCLIST extension instead.

Read the Using CIAO Region Files thread for more information on working with regions in ds9.


Adding a Coordinate Grid

To add a coordinate grid to the image, choose the "Display Coordinate Grid" option from the "Analysis" menu. Then choose "Coordinate Grid Parameters" from the same menu to open the preferences dialog, shown in Figure 5 [Link to Image 5: Coordinate Grid parameters dialog box].

From the preferences box, you can change the color, font, line style (solid or dash), and line thickness for all elements of the grid. The font style, size, and color can be edited, and you can add titles. It is also possible to turn off the display of individual items via the "View" menu.

In Figure 6 [Link to Image 6: Final three-color image with coordinate grid overlaid] we have turned off the grid lines and border. The axes have been changed to "Exterior Axes" (from the "Type" menu). The ds9 "Edit -> Preferences -> Background Color" menu was used to make the background of the ds9 window black instead of the default white; this provides a better display for the axes on the image.



Saving the Output

Once you are happy with your true color image, there are a number of output options in ds9.

  • Image formats: from the "File -> Save Image As..." menu, you can choose JPG, PNG, or TIFF file formats.

  • Postscript: to create a postscript file, go to "File -> Print..." and select "Print To: File".

Currently it is not possible to save the state of the ds9 imager. This means that you cannot save the composite RGB frame and reopen later for further analysis. This functionality is expected to be added in a future version of ds9.



The Equivalent dmimg2jpg Command

There is another CIAO thread, Create A True Color Image, which uses the dmimg2jpg tool to create a three-color image. This method would be preferable for users looking to script the analysis.

Note that the data needs to be smoother prior to running dmimg2jpg. The tool does not have an option to apply it.

Since the tool requires images as input, a binning specification has been added to the filenames. The spatial filter is used to constrain the size of the output image.

The dmimg2jpg equivalent to running this thread (without smoothing) is:

unix% dmimg2jpg infile="red_198.fits[bin x=3650:4550:1,y=3450:4350:1]" \
      greenfile="green_198.fits[bin x=3650:4550:1,y=3450:4350:1]" \
      bluefile="blue_198.fits[bin x=3650:4550:1,y=3450:4350:1]" \
      scalefunction="log" scaleparam="1" \
      minred="0.255" mingreen="0.255" minblue="0.0779" \
      maxred="10" maxgreen="18" maxblue="5" \
      showaimpoint="no" showlabel="no" showgrid="yes" fontsize="1" \
      outfile="dmimg2jpg.jpg" psfile="dmimg2jpg.ps" 

Figure 7 [Link to Image 7: Three-color image created with dmimg2jpg] shows the dmimg2jpg output.



History

02 Feb 2007 new for CIAO 3.4: original version

Return to Threads Page: Top | All | Imag
Hardcopy (PDF): A4 | Letter
Last modified: 02 Feb 2007


The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.