An Introduction to Astronomical Image Processing – Part 1
By Chris Longthorn
This is the first of a series of articles designed to introduce the major concepts of astronomical image processing. I’m going to take it from the beginning assuming that you have taken the images you want, calibrated them and stacked them so that you have a finished image ready for processing to obtain a finished article.
Calibrating and stacking can be covered in a separate article at some other time, but for now we need to understand that every image has both a wanted component called Signal and an unwanted component called Noise. The stacking and calibration is used to remove as much of the noise as possible, but you can never remove all of it.
The file that you work on could be in any number of formats and it will depend on what you use to do imaging and what you use to do the calibration and stacking, but you should choose a format that keeps all of the information. I use MaximDL to do the imaging, the calibration and the stacking and this produces a *.fit file, which I then convert to a 16 bit *.tiff (using MaximDL to save both versions). Do not be tempted to work with *.jpg or *.bmp you’ll end up with a noisy mess.
For the processing I use Adobe Photoshop CS3, with some add-ins, but for these articles I’ll not be using the add-ins. Other software can be used with much the same effect, such as Gimp and Paint Shop Pro.
After calibrations and stacking when you open the file in Photoshop you will not see very much.
You will have a very dark image with maybe a few bright stars showing assuming that you have not used the calibration and stacking software to do any stretching. As you work on the image you need to keep a view of the Histogram. In Photoshop this lives on a palette which is accessed using Window/Histogram.
Because I image in three colours I always select Colors (apologise for the US spelling, but that is what it says) from the Channel drop down so that I can see the individual effects I’m having on each colour channel. This histogram belongs to the image above and needs some explanation.
Using the Histogram
I’ve annotated the Histogram palette here so that you can understand what it is showing. Within Photoshop each pixel in the image will have a value for each of the three colours Red/Green/Blue of between 0 and 255 (or 256 levels).
To the left is Black, the value of all three colours here is 0, 0, 0. To the right is White, the value of all three colours here is 255, 255, 255. The grey line along the bottom of the box is some signal (just what we want) and this stretches from 0 to 255 in all three colours and what you are seeing here is the stars. To the left is some more signal, but is mostly black or shades of grey and you’ll see some dark red. In principle the object of the image processing is to stretch this part of the image so that it occupies more of the Histogram Box like this.
The image will likely have artefacts at the edges because of a small shift due to drive errors between each of the filters, so crop the image to remove the edges.
Levels and Curves
The principle tools used to do the stretching are Levels and Curves.
I use the Levels dialog to do the initial stretching. This is accessed using Image/Adjustments/Levels… or Ctrl-L.
On the Levels dialog we have a Channel selector from which we can select to perform on individual colours, R/G/B or work on the “luminance” which is RGB all at the same time. There are 3 sliders with associated numerical input one for adjusting the Shadow levels, one for the Midtone levels and one for the Highlight levels. Moving these sliders or inputting values have these effects
Shadows make the background darker (going right)
Midtones makes the midtones brighter (going left) or darker (going right)
Highlights makes the bright areas brighter (going left)
For our initial stretch we’re going to adjust the midtones only. Move the slider left until you can see the image fairly easily. Less is more, so be gentle, don’t overdo it. The image below shows the effect of a fairly aggressive Midtone level adjustment on the image and the resulting Histogram. You can see that the histogram now occupies more of the available area.
Now we need to establish the Black point and the White point, we have areas of dark sky background where we can establish the Black point and some bright stars where we can set a White point. For this we will need to use the Color Sampler Tool. This is found on the tool palette.
If we use the Color Sampler tool and click it on the image it puts the values of RGB that it reads into the Info palette. So, click first into a dark part of the image for the Black Point and then into a bright area (star) for the White Point.
This shows the result of this,
Point 1 (Black) has RGB values of 9, 2, 3 and Point 2 (white) has RGB values of 242, 249, 251.
The night sky is not completely black, like the daytime sky it still scatters light in the blue end of the spectrum and is therefore a very dark blue and we need to reflect this when setting the black point.
We use the Levels dialog again, but this time we are going to adjust the individual R, G and B values to 25, 30, and 35, to get a very dark blue. As we have to brighten the background here we do this by moving the Output Level Shadows slider to the right to obtain these values in each of the R, G and B channels.
Point 2 is very nearly pure white and in this instance we don’t want to change this.
Now for the first stretch using Curves. The Curves dialog is accessed using Image/Adjustment/Curves… or Ctrl-M.
We can use the Channel selector to select Luminance (RGB) or individual channels like the Levels dialog and the diagonal line represents the stretch curve, bottom left is 0, 0, 0 and top right is 255, 255, 255. We want to be able to stretch the midtones in the image without affecting the Black and White points that we have already set up so we can put these points onto the stretch line by Ctrl-Clicking the mouse pointer on or near to the Color Sampler tool points that we already have on the image, the white point one is the difficult one as it could be in a small star, so exact correspondence is best for this one. Once the point are placed they appear as small squares on the line (highlighted here in yellow).
Now we can click on the line and drag it upwards to boost brightness (or downwards to reduce brightness) and you can use more points to make the curve any shape you want (which can produce some bizarre effects). Anyway here’s a typical stretch in action.
Now we’re clearly seeing the Horsehead Nebula and the red nebulosity associated with it and also that the histogram is now well stretched across. This stretch will have slightly altered the Black and White points, so use levels again to re-adjust these back to their previous levels and then if you want, do additional iterations of Curves and Levels until you get close to how you want your final image to look. So I’ve done a further iteration using individual colour channels to decrease the Red and boost the Green and Blue, which reduces the red cast of the image.
We’re nearly finished with this lesson. There are three things left to do.
Using Filter/Sharpen/Unsharp Mask… open the Unsharp Mask dialog and you can play with the Amount and Radius to sharpen the image to various levels. I’d recommend an Amount of between 50% to 100% and a Radius usually of less than 1, but here I’ve used 2.5 to exaggerate the effect.
You can see that the inset in the dialog clearly shows that the stars are sharper, but that it has also sharpened the noise and made the image grainier. The stretching that we have done of course stretches both the signal and the noise.
So now we have a noisy image and we want to reduce the noise. Actually we don’t want to remove it completely as this will make the image look flat. There are Photoshop Add-Ins that do an excellent job here, but you can make use of Photoshop’s own noise reductions using Filter/Noise…first use Despeckle, this removes a lot of the speckling and then use Dust and Scratches… with a small Radius (1 or 2 maximum) and a Threshold of 0.
The full image above exhibits a gradient; it’s kind of brown towards the bottom. Again there are Photoshop Add-Ins that will remove this, but there are other methods and this will be the subject of the next article.