R. W. O'CONNELL
December 2001
IDL EXERCISES III:
IMAGE PROCESSING
In doing Part II of the Exercises, you should have copied to your
local directory all the test data files (*.FITS) from the
IDL exercises data directory. Also, as described in Part II,
check to see that your windows system is properly configured before
starting exercise (1).
0) Start IDL.
[On most UNIX systems, just type "idl".
This will start IDL running in the command-line
mode using the window from which you called it. IDL V.5
also offers a widgit-based interface, the IDL Development
Environment, which is invoked by the command "idlde".
This offers convenience features to the experienced user,
but it is correspondingly more complicated and not
recommended for learning the basics.]
Before starting the exercises, give the IDL command:
ON_ERROR,1
This will return control to the main program level if
an error occurs in a called routine.
1) CRYPTO-IMAGE
The image file "mystery-image.fits" contains an encrypted,
low-contrast, 2-D message. See if you can determine what it is by
using any of the tools you have tried so far: plotting, IMLIST,
CTVSCL, CONTRAST, CURVAL, different color tables, histograms, and
so forth. If you try more than one, which method is most
efficient? Once you find the message, develop a method for making
it stand out (i.e. maximize the signal-to-noise) in a TVLASER
hardcopy.
2) IMAGE COMPARISONS
Read in the two images of M87 (courtesy of Brian McNamara).
These are roughly co-centered. One was taken in the B band, the
other in the I band.
Compare the general statistics for the two images: mean, min, max,
variance. One image contains some flagged bad pixels; which is
it?
Load a black-on-white color table. (See the IDL Guide
for a sample script. Alternatively, you can LOADCT,0 and then use
CONTRAST to flip the color table.)
Using a 0.3 power law display to preserve the dynamic range,
display the images in two windows, with the [MIN,MAX] for each
adjusted to show as much of the range of intensity values as
possible. The central density of the two displays should be
roughly the same. What differences between the two images are
apparent?
Now use the AstUseLib BLINK command to blink between the two
windows. Are differences easier to see? Increase the rate of
the blink to 2 per second. [Stop the blink by putting the mouse
on the command window and pressing any key.]
Now load one of the following standard IDL color tables: 11, 25,
31, or 33. Use the MOUSSE routine REFSCL to place a color
table reference over one of the two image windows. Now use the
MOUSSE routine CROLL to "roll" the color table and note how
different color table settings affect the appearance of the
images. You can repeat with any or all of the other suggested
tables.
3) UNSHARP MASKING
Reload the black-on-white color tables.
M87 represents a modestly complicated scene with a diffuse
background, a structured extended source (the famous nonthermal
jet), and a set of unresolved globular star clusters, the
brightest of which can be seen in the outer parts of the image.
There are many image processing techniques available to extract
information on the structure of a scene like this by enhancing
lower contrast features. Here, we'll illustrate two simple ones
which suppress low-frequency structure (the diffuse background).
Use the M87 I band image for these:
i) Edge detection: this is fast, if crude. Results also
depend on the orientation of structures in the image.
Simply display IMAGE - SHIFT(IMAGE,K,K) , where K is a
small integer (2 is a good starting value). For best
appearance, adjust the display to show a small range of
values around zero (e.g. -3 to +3).
When properly adjusted, your display should readily show
both the jet (in the bright central parts of the galaxy)
and the faint globular clusters scattered throughout the
frame. You can try various color tables to adjust the
appearance, although B&W may actually be the most useful.
Make a hardcopy.
ii) Unsharp masking: this is a similar differencing technique,
except that the subtracted image is a smoothed version of
the original. This removes low-frequency structure and is
especially useful where there is a bright background, as
in the case of M87. The fastest approach with IDL is to
use the SMOOTH(IMAGE,K) function. However, the smoothed
image would include the effects of compact structures
(e.g. the jet here, or stars in the case of a star
cluster). A better approach is to use the MEDIAN(IMAGE,K)
function, which is resistant to a minority of bright
pixels within the KxK smoothing box. The disadvantage is
that the MEDIAN routine can be slow if K is large.
Make displays for several values of K. Good trial values
are in the range 9 to 21. Displays are best for a small
positive range of values, e.g. 0 to 2. Make a hardcopy of
a good display.
4) SURFACE PHOTOMETRY
Use the SKY routine to obtain an estimate of the sky background on
the M87 I-band frame. What is the result? Does it agree with
the approximate sky value you can infer by, for example, sampling
blank regions of the frame with CURVAL or other techniques?
Determine in which pixel the galaxy nucleus lies on the M87 I band
frame as follows. Adjust the display until you can easily see
the starlike nucleus. Measure an approximate location
interactively with the cursor. To do this, type
CURSOR,XX,YY,/DEVICE, then place the cursor on the chosen point
on the active window and press the left hand mouse button.
Then, take the [xx,yy] location of the cursor output and use it
as input to the AstUseLib CNTRD centroiding routine. What are
the centroid values for the nucleus? [Note: The behavior of
CURSOR depends on your hardware. See the IDL hyperhelp pages
if you have trouble.]
Do aperture photometry on the M87 I-band frame as follows:
Read the information header for the AstUseLib routine DIST_CIRCLE,
and be sure you understand how it works. You may want to try
using it on a small test array and plotting slices across the
array.
Devise a method, similar to that given as a sample script in the
DIST_CIRCLE header, to obtain the integrated flux of the M87 image
within a circular aperture (centered on the galaxy nucleus).
Measure the total fluxes within circular apertures of 10, 20,
30, and 40 pixel radii.
Make up a simple table (printed to your screen and the journal file) of
the aperture radius, total flux in aperture, and net flux in aperture
after an appropriate correction for the sky background is made.
By what percentage did the sky correction reduce the final flux in
the 40 pixel aperture?
To illustrate the general shape of the galaxy brightness profile
and emphasize any asymmetries, make a "pixel plot" of the
galaxy as follows:
Extract a subarray of 71x71 pixels centered on the nuclear pixel
you identified above. Call this FLX.
Use DIST_CIRCLE to make a matching array containing the distance of
each pixel from the center. Call this RAD.
Now open a plotting window and make a plot of the radius of
each pixel in the subarray vs its flux by typing
PLOT,RAD,FLX,PSYM=5. (PSYM = 5 plots points as open
triangles; PSYM =1 plots plus signs and is similarly
useful.) Most data points should fall in a compact
distribution showing that the source is highly symmetrical.
Have you reached the sky background level at the edge of the
subarray? Is there evidence of an important asymmetry? Make
a hardcopy of the plot. [A linear-log plot using PLOT_IO can
also be useful, but use WHERE to exclude any negative flux
points.]
Test the sensitivity of this technique to asymmetries by
re-extracting the subarray but with the center offset by a
couple of pixels from the true nuclear pixel.
Another way to visualize the source structure is to make a surface
plot with the SURFACE routine. Open a plotting window and give
the command SURFACE,FLX. You can explore the shape of the surface
by inverting the plot (SURFACE,-FLX) or viewing it from another
angle (e.g. SURFACE,FLX,AX=60). Make at least one hardcopy.
5) POINT SOURCE PHOTOMETRY
Read in the image of the globular cluster M13 from the file
"m13-ex8.fits".
Display the image. The center of the cluster is very crowded but
is not saturated in this exposure. Find a set of display
parameters which retains information in the center while still
showing the stars in the outer part of the cluster. Make a hardcopy.
Extract a 100x100 subarray of the image near the cluster center.
Open a plotting window, and make a SURFACE plot of the
subarray. Explore several regions at different radii. How
far from the center do you have to be to avoid blended point-spread
functions?
Extract a 400x400 subarray of the image in its upper left hand
quadrant, and use this for the remainder of exercise (5).
The AstUseLib FIND routine is part of the DAOPHOT photometry package
written by Peter Stetson. This version has been converted to IDL
from the original FORTRAN. FIND locates stellar objects within
a given image. It is efficient and employs only a few parameters,
the most important of which is HMIN, the minimum flux of a candidate
source above the background for a threshold detection.
Apply FIND to the subarray. Use an HMIN value of 120 and a
convolution FWHM of 4 pixels. Leave other parameters at their
default values. In the initial call to FIND, be sure to
specify output variables to store the [x,y] and flux values
produced by the routine.
Display the subarray on your terminal and use the AstUseLib
TVBOX routine to place small boxes around all the stars
chosen by FIND. (11 pixels is a good boxsize.) Make a
hardcopy of the result.
APER (in AstUseLib) is the next routine used in a standard DAOPHOT
reduction. It obtains circular aperture photometry of stars
selected by FIND. It uses a small inner aperture to measure
each star and a slightly larger annulus to measure the local
sky.
Use APER to obtain brightnesses for the sources located in the
FIND run above. Reasonable values for this image are 5
pixels for the "first" star aperture radius (press the return
key when you are asked for "another aperture radius") and 6
and 9 pixels for the sky aperture. Set the number of "photons
per ADU" equal to 1. The output will be expressed in
magnitudes with an arbitrary zero point. Be sure to store
the magnitude values. [Note for non-astronomers: "magnitudes"
are related to fluxes measured in power per unit area by
m = -2.5*alog10(f) + const. ]
Make a histogram of the cluster luminosity function you obtained.
Make a hardcopy of this plot.
Note: the standard procedure with DAOPHOT is not to use a
"first" measuring aperture large enough to include all the light
from a given stellar point spread function. Instead, a composite
PSF derived from isolated stellar images is used to extrapolate the
light measured in a fixed aperture (say 3 pixels radius) to the
total light.
6) USING ATV
Skim the documentation on the ATV widgit display program (see
the ATV home page).
Read the M13 image into ATV. Experiment with the various display and
image sampling features of ATV.
Change the "MouseMode" to "ImExam" and measure the FWHM of
selected stars of various brightnesses and locations on the
image. Is there a significant variation in the FWHM's?
Quote the approximate mean value of the FWHM for the image.
END OF IDL EXERCISES Part III
IDL Tutorial Home Page
Copyright © 2000-2002 Robert W. O'Connell. All rights reserved.
Last modified by RWO, 10/1/08