univ crest PAUL KERRY

Astronomy Technical Support and Computer Manager

contact me unix ultracam links cricket teaching research physics



MERGING TRI-COLOUR IMAGES



This was written after trials into processing Ultracam images, but should work equally as well on other files where images need to be overlaid to generate tri-colour images.

Ultracam preamble

Image alignment description (along with initial file creation)

colcomp

imalign



Ultracam preamble

Ultracam data is initially written from the instrument into two files - one is XML that contains general information such as telescope used, ccd information, camera mode, etc. The other is DAT which contains the raw image data as well as more XML information such as exposure time, whether binning was used, etc.

In order to generate files that we can use, the data file and corresponding xml file have to be converted using one of two methods which will produce six images in total - each of the three cameras split the total frame (1024x1024) in half vertically producing 512 (w) x 1024 (h) images:-

Tom's software should be used to flat field and bias subtract the data files. There is no discernible dark current on the Ultracam chips but this should be taken into account for other devices.

At this stage, we will have six FITS format files with the following format...

FITS image data, 32-bit, floating point, single precision.



Image alignment description

There are several imaging programs available for Windows and Unix which can blend the six FITS images but it can prove difficult to produce top quality images.

On Ultracam, it is a complex process to align the three cameras to produce pixel perfect images due to chromatic shifts in the three different colour bands. The usual bands on Ultracam are i', g' and u' (red, green and blue bands respectively) and these are focused in the laboratory before the instrument is shipped for the observing run.

The bands can be changed at the telescope by the use of interchangeable glass filters that are placed in front of each camera, so unforeseen focusing problems may be brought into effect.

It is this pixel shifting that governs which package is to be used for merging the three images.

MaximDL running under Windows seems to do a reasonable job of creating tri-colour images from the three files. It does not seem to be able to align the three images to a significant degree for Ultracam images as the merged image is expected to be cropped to make the final image. Ultracam data cannot be cropped as the two halves of the chip need to be merged together to produce a full frame image from the two combined halves, however it is a good program for generic tri-colour files.

Gimp running under Unix is able to do a much better job at pixel alignment but at the time of writing, loads the 32-bit FITS images as 8-bit (MaximDL is able to handle 32-bit IEEE FITS files). This degrades the final image quality even though they are aligned correctly.

Using a combination of the Starlink colcomp program (within KAPPA) and IRAF imalign (within immatch) under Unix, it is possible to produce top quality images and also align the pixels. It is this method that I describe below.



Image alignment initial files

The following assumes that there are six FITS files....

lhs_image_i.fits LHS red band
lhs_image_g.fits LHS green band
lhs_image_u.fits LHS blue band
rhs_image_i.fits RHS red band
rhs_image_g.fits RHS green band
rhs_image_u.fits RHS blue band

Using Starlink's fits2ndf (within CONVERT) create corresponding sdf files using default parameters for colcomp to use...

fits2ndf lhs_image_i.fits lhs_image_i

do the same for the other five fits files.



colcomp procedure

The colcomp procedure is a straighforward way to combine tri-colour images and produces good results if the pixels are aligned.

If the pixels are not aligned, then go onto the imalign section and come back here after alignment.

colcomp produces sdf files by default but it is possible to produce PPM files instead of the default sdf files so for our example files we use...

colcomp lhs_image_i lhs_image_g lhs_image_u out=\! ppm=lhs.ppm

colcomp rhs_image_i rhs_image_g rhs_image_u out=\! ppm=rhs.ppm

where colours are in red, green and blue order.

Press return to use the default percentiles settings (5,95) to start off with.

Use an image viewer (ie gimp, xv, display (in ImageMagick, not KAPPA!), etc) and select which is the most important half (ie for the crab nebula, the rhs image contained the pulsar that we wanted to see).

Re-run colcomp and adjust the percentile levels to get the best result (for the crab nebula, the percentiles were 1,99.8) for the half you are interested in.

For Ultracam images, the lhs.ppm and the rhs.ppm should be created to have the same scaling values to equalise the output levels. If this is not done, then there will be a noticable line where the two halves of the chip meet.

From the best half colcomp run, use the scaling information that is produced from the colcomp output and then re-run colcomp with...

colcomp lhs_image_i lhs_image_g lhs_image_u out=\! ppm=lhs.ppm blow=0.032 58534 bhigh=0.08812995 glow=211.9599 ghigh=577.5596 rlow=247.2443 rhigh=860.8469

Use gimp and combine the lhs.ppm and rhs.ppm into a new file - ie copy from the layers window and align using the zoom tool, make the image tidy with the crop tool and you are done.



imalign procedure

Using ds9, open the three FITS images to be aligned as individual frames. Change the colours so that bright objects can be seen in each of the frames. At this stage, blink can be used to see how far out of alignment the pixels are.

With imalign, a reference frame has to be selected which will be used to align the other two images. For Ultracam images, the g' (green) band has been selected as the reference frame as it has good S/N ratio for the majority of images.

Using iraf from a xgterm (and not a xterm), load imexam.

cl> imexam

Look for stars that are on all of the frames and get the co-ordinates from the reference frame by pressing a. It is beneficial at this stage to zoom in as much as possible to get the most accurate pixel measurement. Try and get at least 10 points if that is possible.

Open a text editor and paste the co-ordinates from the imexam output (they are given as x,y and should be separated by a whitespace in the text editor). Save the text file as for example, green_ref

Quit out of imexam by pressing q in the ds9 window and then load immatch and imalign

cl> immatch im> imalign Input images : lhs_image_i Reference image : lhs_image_g Reference coordinates file : green_ref Output images : lhs_image_i_aligned

This will produce the red frame aligned to to green. Re-run the script and align the blue frame to the green.

At this stage, you can check alignment by loading the two aligned frames into ds9 and running blink. If alignment was not successful, then you should read the help page on imalign within iraf as there are more parameters that can be used.

Create new sdf files of the aligned images using fits2ndf and go back to the colcomp section above.

Valid XHTML 1.1! Valid CSS 1.0!