The Crab Nebula : Combining BVR fit/imh files into a color jpg.

January 2nd, 2004 by admin

My last night using the 30 inch telescope at the McDonald observatory proved to not be photometric by around 3AM or so. However, that did not stop me from finding something to point the scope at and take some pictures. I took a B, V, and R filter image of the Crab Nebula, M1 – each 240 second exposures. After I left the observatory, I set out to combine the images into a color jpeg which is shown below.

How did I go from the gray IRAF images in three filters to this relatively pretty color jpeg? I used IRAF of course, but I also used Graphicconverter, and the GIMP. GraphicConverter is the swiss army knife of a Mac graphic programs. It can open and save a huge number of file formats. The GIMP is a the GNU Image Manipulation Facility. It runs in X11, and is similar to Photoshop in its ablities, though it’s not as polished, doesn’t have a Mac-like interface. However, it can handle image layers, and is free. I installed the GIMP via the Fink project.

First, I did some standard ccd image techniques. I bias-subtracted the images, but I did not bother with flat-fielding. I also used imalign to register the images so that the stars (and the Crab) were all aligned in the three images and I could combine them easily.

What I needed to create the color image were grayscale images of each filter in some common file format that I could assign to red, green, and blue colors and the combine together. The trick was to get good looking grayscale GIFs out of IRAF that I could then manipulate in other graphic programs.

So the hardest part of this whole endeavour was getting the IRAF images to come out to a more reasonable file format and to have them look like I could get them to look in ds9 or ximtool. The IRAF display command can display IRAF images and it allows for several options in terms of how to assign the count level to grayscale. IRAF users are probalby familiar with zscale, zrange, z1, z2, etc.

Once display sends the image to ds9 or ximtool I can adjust the brightness and contrast until the image looks like something I like. The trick is getting what appears on my screen in IRAF and ds9 out to a GIF.

The answer lies in the IRAF export command. export can convert IRAF image files to other formats AND preserve both hte z1 and z2 values from the display command and the brightness/contrast from ximtool ds9. (Note: ds9 calls brightness “bias” but the values are the same.)

So I used IRAF to display my R image, and tweaked the z1 and z2 values so that z1 was the background of the sky and z2 was about the peak of the nebula. Then I clicked and dragged around in ds9 until the image showed the level of detail I wanted, and made note of these brightness/contrast values.

Then came time for the export command. I created a file called red with the following content:

  setcmap ( zscale (i1, 800.0, 5000.0), "greyscale", 0.47, 1.1)

This sets z1 and z2 to 800 and 5000, respectively. The 0.47 is the brightness, and 1.1 is the contrast. Once this color map file has been created it came time for the IRAF command, where the first two arguments are the input and output name, ‘gif’ sets the file format, and the outbands parameter reads in the text file above that sets the colormap.

   cl> export Crab_R.imh Crab_red.gif gif outbands=@red

I now had a grayscale gif that looked just like what I had managed to display in ds9. That done I repeated this process with the other images. I now had 3 greyscale gifs representing the B, V, and R filters.

I then attempted to figure out how to assign these three images to different RGB color channels in the GIMP. I failed. I never understood how the channels tab in the GIMP worked. So, I went to GraphicConverter. It has a wonderful “Grayscale to Red Channel” command. It also has the same command for the blue and green channel. I was off and running. I now had 3 monochromatic color images, one red, one blue, and one green – all in the TIFF format now.

Now came time for the GIMP. I simply copied in each monochromatic image as a different layer and made the layer types “additive.” I then exported to the JPEG format and whalla – I got the image you see above.

If there is interest in more details, I can make this more of a tutorial, and can add some screenshots of Graphicconverter, the GIMP, and IRAF, along with the fits files I started with. (Actually, they were IRAF .imh files, but fits are easier to transport.)

Perhaps someone else has a better method altogether. The IRAF export command can, for example, create color sun RAS images, which is described in the export help file. While I was able to do this and set z1 and z2 for each channel, I could not also set the brightness/contrast. If anyone has any feedback or comments email me or use the comments feature below.

Here also is the image with a gamma correction, side by side the original. The gamma correction should make it look brighter. I can’t decide which one I prefer. More complicated is the fact that PCs handle gamma differently than Macs.

Adding a gamma correction of 1.5 in GraphicConverter.

Update Be sure to check out the somewhat simpler DS9 method for this same RGB combination.

.

Please remember this is the archive of Macsingularity. Comments are no longer supported, and this content and site are no longer updated.


3 Responses to “The Crab Nebula : Combining BVR fit/imh files into a color jpg.”

  1. 1

    Fran Says

    I do not understand how to combine R, G, & B channels with Gimp. Its help is no help in telling me how to do this, and I cannot find any button in any dialog box to do it either.

  2. 2

    Marcos Says

    I never figured out the channels thing either. I added color in graphic-converter as I described above than I made three additive layers in the GIMP and combined them with layers, not channels.

  3. 3

    Greg Says

    Marcos, Using GIMP and Graphics Converter is much easier than working with the IRAF and the rgbsun commands. This tutorial has been very helpful. Thanks!



Bad Behavior has blocked 45 access attempts in the last 7 days.