We begin the tutorial on processing astronomical images using FITS files, following the introduction already given. It is a step-by-step created by the Chandra X-ray Observatory within the framework of its openFITS project.

The first part of this tutorial was an introduction.
In this second part we will create a three-color image of Cas A.
1-Download the FITS files:
For that we can get them from:
http://chandra.harvard.edu/photo/openFITS/casa.html
Each file is about 4 MB.
Each file represents something different about the object since the images correspond to different filters for soft, medium, and hard X-rays.
Although the three images appear in black and white, in this process we will manage to create a full-color image.
2-Open GIMP and switch to RGB
a. File ->Open as Layers... and select the three files we just downloaded.
b. Note that the default parameters in the "Load FITS File" dialog box should work well for this example.
c. We should see three layers in the layers box, one titled "Background" and two layers whose names correspond to the file names.
d. To simplify, it would be good to rename those layers now, by double-clicking on the name of each layer. Starting from bottom to top, let's call them "soft," "medium," and "hard" to correspond to the X-ray bands presented (soft for the 0.5-1.5 keV file, hard for the 4.0-6.0 keV one).
e. The opened images are in grayscale and will need to be changed to RGB (red, green, blue) to colorize the layers. We do this in Image->Mode->RGB.

3-Change each layer mode to Screen
a. When we open the files as layers, only the top layer is visible. We need to adjust the layer mode to allow each one to blend with the others.
b. The Screen mode applies a function to each pixel of each layer of the image. The function subtracts 255 from each pixel, multiplies multiple layers of pixels together, divides by 255, and then subtracts 255 from the resulting value. The new image is a linear combination of the pixels from each layer.
c. We can activate Screen mode for each layer by selecting the layer in the dialog box and pressing Mode, which will display a menu where we can select Screen.
d. Let's do this for each layer and we will notice how the image brightens as we do it.
(The layers dialog box should be at the top right. If we don't see it, we can press Ctrl+L).

4-Adjust levels
a. The first view of the image is very dark. Although GIMP automatically rescales the FITS data, the image still needs to adjust the pixel levels.
b-Let's start with the top layer and turn off the layers below. To do this we click the eye icon to the left of the other layers.
c-Open the Levels dialog box by selecting Colors->Levels and let's freely adjust the small triangles below the histogram, where it says Input Levels.
d-Typically we would adjust only the gamma of each layer by adjusting only the middle triangle or slider to the right or left, depending on how much we want to adjust the level.
e-Repeat the process for the two remaining layers until we are satisfied with the result.
f-The trick with adjusting levels at this stage is to bring out the more diffuse details in the object, but minimizing the amount of background "noise" in the image. Let's play a bit with the triangles or sliders and see how subtle changes in the levels affect the image.

5-Apply smoothing algorithm
a. At this point we start to see a nice image developing on the screen, but we will notice a lot of pixelated noise in the darker regions. This is where a good smoothing algorithm can really take the image to another level.
b. Working with each individual layer as we did before, we select the smoothing algorithm found in Filters->GMIC...->Enhancement->Anisotropic Smoothing.
c. There are many options in the window. We can freely play and discover what works. For this case, the default parameters seem to produce a nice smoothed image. It is important to note that the result of this smoothing depends heavily on the levels chosen in the previous step.
Among the options of this filter, whose installation we explained in the first part, there is the possibility to select which layers to use for the filter (active, all, visible) and even whether the result should be applied to the layer itself or to a new one.

6-Add color
a. Another limitation of using GIMP for a three-color image is that GIMP does not use what in Photoshop is known as "Adjustment Layers". Those adjustment layers allow making changes to layers in a non-destructive way, meaning it doesn't change the layer itself, but an additional layer is applied to make the changes. Here, the changes will be applied directly to the original layer and after the file is saved and closed they cannot be undone. One way to avoid this is to duplicate the original layers and do all the work on the duplicates so we can go back if necessary.
b. To apply color to the layers, we will work from the bottom layer, with the lowest energy layer. We select the layer and then go to Colors->Colorize. In this example we will give red, green, and blue colors to the low, medium, and high energy layers, respectively. So, for this layer, we will make it red. We will notice that when moving the Hue slider from left to right, the numbers increase from 0 to 360. That's because Hue is taken directly from the color wheel, a 360-degree representation of the visible light spectrum (red, orange, yellow, green, blue, violet). Red corresponds to 0 degrees on the Hue selector.
c. To have a rich color that does not oversaturate when combined with the other layers, we will use a Saturation value of 100 with a Lightness value of -50.
We do the same with the other layers, coloring them green and blue and respecting the previously recommended values for saturation and lightness.

7-The final touches
a. Now that we added color, the image is taking shape. But we can still do something more.
b. At this point we can be creative and explore the various tools within GIMP to bring more color and brightness to the image.
c. In the example below, another round of level editing of the three layers was performed and then they were merged using Image->Merge Visible Layers.
Then the Colors->Curves option was used.
d. With practice we will gain more confidence and develop intuition about what we can do to create our own images.
The image that begins this post is my final result.
We can compare our result with some of the images generated of Cassiopeia A by Chandra.
After writing this tutorial, I went back and followed each step to create this video:
Video: Creating astronomical images
http://www.youtube.com/watch?v=X-dQ-osfl8U
There will be a third part with a second tutorial, this time to create an image of the Crab Nebula.
Sources and related links
About the images
- Own screenshots using GIMP.


