Basic image processing


Below article was taken from the previous version of the website and is already a few years old.
I decided to transfer it to the new site anyhow, as the concept below may not always be the best approach for mono CCD images, however the basics still apply.

This article assumes some basic knowledge of Photoshop GUI, tools and layer functionality.

The article was written with the processing of DSLR color images in mind, but can be used for other camera’s and monochrome images as well as the basics remain more or less the same.

Index:

      • Introduction
      • The histogram
      • Basic image stretching
      • 1) Linear stretching (levels adjustments)
      • 2) Non Linear stretching (curves adjustments)
      • 3) Clipping
      • Steps in Photoshop
      • Color correction
      • Remarks

Always process your images in uncompressed 16 BIT format, either FIT or TIFF !

Introduction

As soon as the stacking process is complete, you usually end up with a rather dark looking image which does not show the kind of detail you would have expected to see in an image stack containing lots of single exposures. However, there is a huge amount of data available in this dark looking image !

Question is, how to bring out all the data and detail contained in the raw image data using Photoshop.
This tutorial briefly describes some of the most basic image processing steps involved.

We start off by explaining some basics of THE most important tool used in image processing; the histogram !

The histogram


The histogram of an image is nothing more than a graphical representation of the distribution of pixels with a specific value in an image.

The vertical axis of the histogram shows the amount of pixels holding a single specific brightness value. (i.e. 1721 pixels have brightness value 89, 1524 pixels have brightness value 90 and so on), these amount of pixels are shown as vertical bars.

The horizontal axis shows all brightness levels in the image from black (0) at the left to white (255) at the right.

A histogram is used to determine whether an image has been correctly exposed and if no clipping (data loss) has taken place in either the dark or light parts of an image.
In Photoshop the histogram is usually always shown as a standard window together with the Navigator and Info tab. If the histogram is not shown, use the “Window” menu and activate “Histogram” to show the window.

A typical histogram of an astronomical image should look somewhat like the histogram below.

The slope at the left side of the histogram shows that there are quite a lot of pixels containing a considerable amount of low brightness levels values in the image. These values represent the details in the dark part of the image, background + nebula etc…

The right part contains a lot less pixels as it is quite flat. These are the amount of pixels with a high brightness level (stars in the image).

Basic image stretching

In order to construct a standard color image we need to have three basic colors available being red, green and blue.

This is achieved in a color CCD/CMOS sensor by applying tiny color filters to each pixel. These pixels are grouped into an array of 4 pixels and are color coded red, green, green and blue (RGGB). This is called a Bayer matrix/filter. As the human eye is most sensitive to green light, 2 green pixels are used in a group of 4. When the exposure is ended, the camera will automatically build up the color image from the info contained in all the separate pixels (this is mentioned for reference only as the technical details are beyond the scope of this article.)

Now lets go back to the histogram.

When looking at the histogram of a color image in Photoshop, it is by default set to show all three channels simultaneously (RGB). In order to process the image correctly we also need to view the data available in each channel separately.

This can be done by changing the channel from “RGB” to the individual Red, Green and Blue channels.

When imaging through a refractor or when filters are being applied, the data in these channels will usually not overlap.
An example of the different color channels not overlapping can be seen in the screen shown at left.

Part of stretching the image correctly is resetting the color balance in such a way that all 3 channels will overlap again.
The correction of the color balance is an almost final step in this process and will be addressed later in this tutorial.

The first step in processing basics is how to stretch the data available.
There are different methods available for doing this.
1) Level adjustments, this is called linear stretching.

With this tool the levels for pixel values can be remapped to a different value increasing the overall brightness of an image.
The drawback of using this method is that it will reset all pixel values in a linear way increasing the brightness level of each pixel in the image with an equal amount.

This will very likely cause the stars in the image to become oversaturated and appear as colorless hard white dots. This is not a very desirable effect and should be avoided if possible.
As level adjustments is not the best way of getting the data out of the image we will not be using in in this step of the processing (more on this later). Let’s have a look at the next method
2) Curves adjustments, this is called non-linear stretching.

As method 1, curves adjustments can also be used to remap the brightness values of pixels in an image, however it differs from the first method as it can be used in a non-linear way. With curves adjustments it is possible to remap pixel values containing the dark detail (low levels)in an image without affecting the pixels with the high brightness levels (stars) !
3) Before we start processing, first something about “clipping” (loss of data).

Clipping occurs when the pixel values in the image are modified, using one of the methods above, in such a way that part of the information is simply lost (forever !).

The most common error is to reset the blackpoint to a brightness level which is too high. For example if the blackpoint is remapped to brightness value 80, all pixels containing a lower brightness level (up to 79) are effectively removed from the image ! This results in an extremely dark background and is mostly done to compensate for local light pollution.

To the left is a good example of clipping which has occured in the dark detail of an image histogram. Instead of sloping back to zero value, the left part of the histogram is cut off. This results in the loss of data which can never be undone by any further processing !

All information contained in the pixels up to the remapped value is removed and it is not possible to bring this data back by any further processing whatsoever !

Although less common, the same error can of course also be made with remapping the white point. Setting this level to low will result in very bright (burnt out) colorless (white) stars. These stars look like almost stamped on instead of being part of the image.

The image at far right shows a good example histogram with highlight clipping (cut off at the right side).

Whenever you are processing an image, always keep checking the histogram to make sure that your actions will not cause any clipping in either the dark or light parts of the histogram.

Photoshop will always show a dynamic preview of the results on the histogram with each action taken.

Steps in Photoshop


This is how non-linear stretching is done effectively:

Open your calibrated stacked image.
Go to the Image menu and select Adjustments, Curves…
Leave the channel at RGB as the different color channels are not relevant for this processing step.

The curve dialog window shows a 45 degree line from bottom left to top right.
This is how non-linear
This is somewhat similar to a histogram as it is also a representation of the brightness levels based on the current histogram, with black level at lower left and white level at top right. By changing the straight line into a curved line different effects can be achieved in the image. What we are looking for is a shape like the one shown below:

This curve shape will remap the low brightness value pixels (background & object detail) to a higher brightness value without affecting the star images.

Make sure that the top of the line is more or less straight again to minimize the effect on the star images.

Other effects like increasing contrast, darkening the background, increasing mid-tones can be achieved as well by applying different shaped curves to the image.

These stretch curves can be applied several times, but keep an eye on the resulting histogram as with each curve adjustment the histogram will shift in its entirety further towards the right of the horizontal axis. As a rule of thumb, do not stretch the data beyond the middle of the histogram.

Be sure to not overstretch the image as this will introduce large amounts of noise, banding issues and lots of not so nice effects in your image. “Less is more” is the main rule to follow here.

Disregard any color balance issues (too red, blue or green) in this part as this will be covered later on.

Color correction

As soon as this initial stretching is done, it is time to darken the background and reset the color balance.
We now need to reset each of the separate color levels by using the level adjustments function.

Start with opening the level adjustments window (Image, Adjustments, Levels…) and switch the channel from RGB to Red.

Take the left slider (black point) and move it to just before the beginning of the main histogram slope. (see image on the left)

Now do the same for the blue and green channel.

This will darken the background and at the same time correct the color balance as by moving each slider to the start of the histogram for each channel the resulting combined RGB channel will start to show an overlap of the different color levels.
So instead of a histogram which is looking like this: (take notice of the three different peaks for each color channel)

We now have a corrected color balance with a corresponding histogram which looks like this:

When adjusting the levels make sure to NOT clip the data as this is the stage in which this can easily occur (keep checking the histogram !). When darkening the background we will also (automatically) reset the color balance.

Further tweak the individual channels by small amounts to correct the background brightness, but be sure to not clip any data !

You also may want to apply any contrast enhancing curves at this stage, but be sure not to overprocess your image and keep checking your histogram !

After final tweaking is finished, save your processed image under a different name !
This concludes the basic image tutorial.

Remarks

Always keep your source (raw) material as you may want to redo some processing later on with new processing techniques in order to get better and/or different results or combine old images with a set of new ones.

Please have a look at our other tutorials for further processing tips.
Download example curves

Some examples of standard curves for Photoshop are available for download here:
Download set of 16 Photoshop curves

Just unpack the zip file into a folder and use “Load” in the curve adjustment dialog to load the pre-shaped curve.
This is just a small example of what can be done with curves, try experimenting with different shaped curves for all kinds of different effects on your image.