Background Extraction

Astrophotographs taken from light polluted skies will show light pollution as an overall background to the image – which may well change across the frame particularly at low elevations.  The process of background extraction aims to remove this light, termed ‘Sky Glow’, from the image.  

In the background extraction tools, two of which are described below, a number of point samples are placed across the image and a two dimensional model is made of the sky background.  It is vital that samples are not placed over nebula regions as their light will be regarded as background and removed!

A Simple method using an image processing program

A simple, but quite effective, method can be implemented in Adobe Photoshop, Affinity Photo or the free program Glimpse.  To see the pollution better in the stacked image, it might well need to be first brightened but this must be done linearly using, for example, the ‘Brightness/Contrast’ tool.  The image is duplicated.  Any nebula regions must be cloned over from neighbouring regions of the image to give an image only showing stars.  A ‘Median’ or ‘Dust and Scratches’ filter is then applied to the upper layer with a radius of, say, 50 pixels.  By magic, the stars disappear giving just an image of the sky background.  The two layers are then flattened using the ‘Difference’ blending mode leaving an image with the sky background removed.  Simples.  I have found that this method can sometimes give better results close to the edges of an image than the background extraction tools, so it can be worth using.  If nebulosity covers much of the image, such as an image of NGC 7000, the North America Nebula there is obviously a problem.  In this case, the object was at a high elevation so one could reasonably assume that the sky background was uniform across the frame.  So, in the duplicate image, a Gaussian Blur  was applied with a radius of ~5 pixels (to average out the sky background a little) and a sample was taken of the dark region in the ‘Gulf of Mexico’.  The whole duplicate frame was then painted with this colour before ‘differencing the two layers.  A similar process could be used when imaging the Andromeda Galaxy at high elevation.

An example – M81 and M82

The stacked image is shown below.

To see where the two galaxies are, the image is linearly brightened using the ‘Brightness/Contrast’ tool.

The brightened image is duplicated and the galaxies in the upper layer cloned out from close-by regions of the frame.

The ‘Dust and Scratches’ or Median filter is applied with a radius of, say, 50 pixels.  The stars disappear leaving just an image of the sky background.

The two layers are flattened using the ‘Difference’ blending mode to remove the sky background.

Background Extraction in Siril

I am using the free program Siril (for Windows, MacOS and Linux) to process my stacked images so its Background Extraction Tool is the one that I normally use.  It is very simple in use and the placed grid across the frame attempts to avoid nebula regions.  Any sample points left over or too close to nebula regions can be removed by right clicking on them.  I have explained its use in the digest article: https://www.ianmorison.com/a-guide-to-stacking-background-extraction-and-stretching/

When the Background Extraction tool is opened, Siril puts a grid of sample points across the frame. It attempts to avoid Nebula and has avoided M81 but not M82.

The sample points close to M82 are removed by right clicking on them. The area around M81 was cleared as well.

On clicking on ‘Compute Background’ and, when blue, ‘Apply’, the background is removed.

GraXpert Background extraction

This free program works in a very similar way to that in Siril but gives more options to refine the process.  With versions for Windows, MacOS and Linux, it can be downloaded from: https://www.graxpert.com/

When opened the stacked image is loaded – again that of M81 and M82. Like Siril, a grid is placed over the frame

The result is a little odd – a very large area around M81 is avoided, but not as one might expect around M82 so sample points were added (left click) or removed (right click) to give the grid shown below.

GraXpert has three possible interpolation methods – RBF is the standard one and will be used by default.  On clicking ‘Calculate Background, the sky background is removed. GraXpert can then show the result, the original image or an image of the sky background which it has removed. The result can now be exported as a 32 bit  Fits file to import into Siril for further processing or a Tiff file if so desired.

There are three YouTube videos which go into great detail:

An interesting comparison of the three methods having stretched the resulting images

I said that the ‘Photoshop’ method may work better at the edges of the frame.  I did a comparison of  the three methods using the stacked image of the galaxies M81 and M82.  I then stretched the results as near identically as I could.  The Photoshop method had produced far better results towards the edges of the frame.   It does, however, make the background totally black – which some astrophotographers do not like at all.  It is easy, however, to add back some uniform brightness:  one duplicates the image and paints the upper layer a mid grey, then flattens the two layers using the ‘Screen’ blending mode adjusting the opacity (quite low) to suit.

GraXpert Result

Siril Result

‘Photoshop’ result

‘Photoshop’ result with added uniform sky background