IMAGE DISPLAY, ANNOTATION, AND EXAMINATION WITH TIM

ROBISHAW’S display.pro AND RELATED PROCEDURES April 1, 2009

Carl Heiles

Contents

1 USING display TO MAKE AND EXAMINE 1D OR 3D IMAGES 1

1.1 1d Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2 3d Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 Examine the 1d Image on your Terminal . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3.1 Interactively Locate Points Using trc . . . . . . . . . . . . . . . . . . . . . . 3

1.3.2 Interactively Plot the 1d Image Intensities Versus x or y As You Move Your Cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 USING dsply2d FOR 2D IMAGES 4

3 USING rgbimg FOR 3D COLOR IMAGES 5

1. USING display TO MAKE AND EXAMINE 1D OR 3D IMAGES

Tim Robishaw’s display.pro does most of what we cover in other handouts, but much more simply. Here’s an introduction to this and related programs, namely

1. display.pro . This displays 1d or 3d images, draws axes, labels axes, properly bytescales the images (either automatically or according to user specs), changes contrast…

2. trc.pro . Shorthand for trcursor, this slaps a nice crosshairs on the screen and, when you push the mouse button, records the image value and the x/y positions.

3. trp.pro . Shorthand for trprofiles, this plots image profiles (the image intensity versus the x or y coordinate).

In short, these commands do what the native IDL procedures tv, rdpix, and profiles do, except that they can give the x/y values in designated coordinate values instead of pixels, do a few other nice things, and work better.

Let’s get started at the same place as in §3 of IDIDL. Specifically, we’ll start with 1-d images, like a greyscale or false-color image, which means you are using a 256-entry color table, i.e. you have turned color decomposition off. (If this is Greek to you, read the first two sections of IDIDL.)

1.1. 1d Images

First, generate an image^{1}. In IDIDL, we matched the window size to the image size. When using display, you don’t need to do that; it’s done automatically, and it will even generate a window for you if you don’t have one open. If you want a larger image on your screen, you can define a window of your desired size and display will fill it. You have to be careful, though, about the effects of congrid (namely: it can interpolate over small features when you shrink an image—see IDIDL).

A good way to use display for this particular image:

x=findgen(480)* (360./480.)
y=findgen(240)* (180./240.) - 90.
display, img, x, y, min=0, max=2000, out=out, $
xtit='Galactic Longitude', ytit='Galactic latitude', title= 'C-Band ROSAT Sky'

Some explanation:

1. x and y are the axes values. The angles run from 0 to 360 in x and from -90 to 90 in y. The first dimension of img must have the same number of elements as x while the second dimension of img must have the same number of elements as y.

2. min and max say that the minimum data value will be converted to 0 (the minimum intensity, black for a greyscale image) and the maximum to 255 (white).

3. If you wanted to make a false-color image instead of greyscale, load in your desired color table. For example, if you want to use a native IDL color table, e.g. number 5, then before

     calling display type loadct, 5.

1There’s a nice 1d image of the X-ray sky, obtained by the ROSAT satellite, in http://astro.berkeley.edu/∼heiles/handouts/rass c.fits . Copy this file to the disk area where you are running IDL. To accomplish this, type wget http://astro.berkeley.edu/∼heiles/handouts/rass c.fits .

This file is in a format called “FITS” format, which is the standard format of most astronomical images. To read the data file into an array called img, it is easiest to use the IDL procedure called “readfits”, which resides in the Goddard IDL library, which, in turn, is already in your IDL path. All you have to do is type img = readfits('rass c.fits', headerinfo) . This returns two arrays: the image array (img) and information about the image (headerinfo); type print, headerinfo to see the header information. Now type help, img and IDL will tell you that it is a 480 × 240 FLOAT array.

4. The x, y, and image titles speak for themselves.

5. out is an output structure that contains information used for examining the image.

In addition, there are some useful additional keywords or optional inputs for display:

1. aspect allows you to change the shape of the image. aspect is the ratio of the x to the y dimensions of the output image.

2. negative: if you set this keyword, then the color table is reversed. That is, instead of black/white being min/max, black/white is max/min. For greyscale images to be printed on paper, or projected in a powerpoint presentation, you almost always want to set negative!

3. If you want to write the image to a postscript file, you must first open it. Best is to use our psopen procedure. For example,

psopen, 'xray.ps', /times, /bold, /isolatin1, /color, xsize=6, ysize=4, /inch

which writes to the file xray.ps, uses the Times/Bold font, allows color in the image, and sets the x and y sizes to 6 and 4 inches. Then call display. After that, close the ps file with

psclose .

4. If you want to change the contrast of the image, you must do it yourself before calling display. For example, to increase the contrast so that weak features are highlighted, one often raises the image values to a power less than one.

1.2. 3d Images

Everything here is exactly as above, except that (1) your image must be a truecolor image of dimension (3, nx, ny) [i.e., 3 colors by (nx/ny) (horizontal/vertical) pixels); and (2) you need to set the true keyword when calling display.

1.3. Examine the 1d Image on your Terminal

1.3.1. Interactively Locate Points Using trc

trc is just a wrapper that calls tr rdplot with useful settings. Type

trc, x, y

Then move the cursor inside the plot window. Left clicks write and record the (x,y) values in the coordinate system you select (i.e., data, device, normal; default is data). A middle or left click will exit the program. Notice that the crosshairs are clipped at the axes: it’s often useful to make the crosshairs extend to the edges of the window. This is accomplished by passing the /noclip keyword, and since we can use minimum matching in IDL, /noc will be good enough:

trc, x, y, /noc

The positions of your left-clicks can be passed out in arrays in addition to having them printed to the screen. For more details, see the documentation of trc and tr rdplot.

1.3.2. Interactively Plot the 1d Image Intensities Versus x or y As You Move Your Cursor

trp is just a wrapper that calls tr profiles with useful settings. Type

trp, out

Notice that a new window has been created. Move the cursor inside the plot window containing the displayed image. You now see the profiles in the newly created window (labeled Profiles). Initially, you see intensity versus the x data coordinates. Left click gives intensity versus the y data coordinates. Middle click prints, the x/y values. Right click exits the program and closes the profiles window. For more, see the documentation for trp and tr profiles.

Normally trp plots profiles of the original, unscaled image. However, if you have scaled the displayed image using min and/or max, and if you want to get profiles of this scaled image, type

trp, out, /scaled

Obviously, in order for all this to work, you need to have used the OUT keyword for display prior to calling trp.

2. USING dsply2d FOR 2D IMAGES

This poorly-documented procedure is quick and automatically gives you a nice colorbar. However, it requires your images to be 541 × 541 pixels. If they are not this size, the procedure resizes them using congrid; the image always comes out square. A more flexible alternative is the 2d example in the handout “1d2d3d: One, Two, and Three Dimensional Color Images”.

2d images synthesize color and intensity, so these plots explicitly require information for the two dimensions—i.e., the two images. Define

1. c img and i img as the color image and intensity image, respectively.

2. xaxis, yaxis as the (x,y) pixel values (like x,y for display).

3. c title and y title as the titles for the two images 4. Keyword c range: a 2-element vector specifying the max and min of color used for labeling

(e.g., if colors correspond to a velocity range of -10 to 10 km/s, then c range = [-10,10]).

5. Keywords intmin, intmax as the minimum/maximum intensity values for the intensity im-

     ages (like min,max for display).

6. Keyword gamma as the contrast parameter (the intensity image is raised to this power).

7. Keywords xaxlbl, yaxlbl as the x- and y-axis labels.

8. For postscript, set keywords ps, filename and, if you want encapsulated postscript, encapsulated.

There are some other keywords; you can look at the code and experiment. As I said above, for more flexibility look at the 2d example in the handout “1d2d3d: One, Two, and Three Dimensional Color Images”.

3. USING rgbimg FOR 3D COLOR IMAGES

We have a clumsily-written but reliable procedure to produce an image like those of Figure 6 in the handout “1d2d3d: One, Two, and Three Dimensional Color Images”. A severe restriction is that the image must have dimensions 541 × 541; you can use congrid to convert your image to this size. The procedure is called rgbimg.pro and it is reasonably well-documented.

To see what kind of image and colorbar this produces, see the handout “1d2d3d: One, Two, and Three Dimensional Color Images”.