Tag Archives: gimp

Creating star trails with automatic sky glow removal

Creating star trail images is one of the easier astrophotography tasks there is, since it doesn’t require any messing about with tracking devices. You just set a camera to point skywards, with programmable remote control set to snap a few 100 images over a hour or more. There are then software programs which can merge the individual images together to create the final star trail. On Linux, I use a startrails plugin for GIMP to perform the merging of individual frames which is simple to use and works pretty well.

The basic star trail image with no sky glow adjustments applied

The basic star trail image with no sky glow adjustments applied

This is all very straighforward if you’re capturing images under ideal conditions, but life doesn’t always work out that way. The first thing people do is to add in dark frames, which are images captured with the lens cap on. These frames will record any hot pixels or general sensor noise that may be present. The startrail application will merge all the dark frames and then subtract the result from the light frames, removing the hot pixels from the final image.

When taking images in London though, there is a major problem with sky glow from the ever present light pollution. There are number of techniques for removing sky glow, with varying pluses and minuses. A simple way is play with the curves/levels to reduce the intensity of the background glow and/or use colour balance corrections to try and make it less noticeable. The problem with this is that the corrections will apply to the background sky, the stars themselves and any foreground objects uniformly. All too often the sky glow is not uniform, but in fact a gradient from top to bottom of the frame, meaning the results of curve adjustment show up the gradient

The basic star trail image with curve adjustments to reduce intensity of the sky glow. Due to the gradient, it is only possible to remove part of the sky glow

The basic star trail image with curve adjustments to reduce intensity of the sky glow. Due to the gradient, it is only possible to remove part of the sky glow

The overall goal is to produce a background that is completely black. This could be achieved if we are able to extract the background component from the main image and then subtract it, leaving just the stars behind. The layers feature in any photo editor can be used as mechanism for accomplishing this task.

If we make an assumption that sky glow is approximately the same in each frame, we can follow a simple series of steps to extract a reasonable approximation of the sky glow background. Start by opening one of the individual frames. Then select the menu option Filters -> Blur -> Gaussian Blur. The radius setting should be set to a large value such as 150px. The resulting image should now be a very smooth colour gradient just representing the sky glow background.

A single image frame blurred to leave just the sky glow background

A single image frame blurred to leave just the sky glow background

Copy this blurred image, and switch to the star trail image previously produced by the plugin. Create a new layer, paste the blurred image into it and anchor the floating selection. Finally change the layer mode to “Subtract”.

The final star trail image with the gaussian blurred sky glow subtracted

The final star trail image with the gaussian blurred sky glow subtracted

The final result above doesn’t have a completely black background because the sky glow we extracted is merely an approximation, but it should have a less significant colour cast, and lower overall intensity. A small adjustment of curves can further reduce the remaining glow:

The final star trail image with the gaussian blurred sky glow subtracted

The final star trail image with the gaussian blurred sky glow subtracted

While this is much improved, there are still some limitations with this technique. If the sky conditions were changing during the course of the image capture session, any single frame will not be so close to the average glow of the final image, so will either be over or under correcting the sky glow. Weather often plays a part, sending clouds through the scene during capture. Ideally one would simply wait for a clear day before capturing images, but not everyone has such a luxury of time. When some images contain clouds, the final image (as seen above) will have a quite uneven, patchy sky glow which is not easily removed with a simple subtraction layer.

Ideally one would subtract the sky glow from each individual frame before merging them to produce the trail. With 100’s of frames this is quite a tedious process, but since the GIMP startrails plugin is open source GPLv3+ licensed python code, we have the freedom to modify it. To that end I have created a fork which has the ability to perform automatic sky glow removal by applying the gaussian blur technique to each individual frame. This more than doubles the amount of time required to produce a star trail image, but the results are very satisfying indeed.

The star trail when sky glow has been subtracted from each individual frame before merging

The star trail when sky glow has been subtracted from each individual frame before merging

The only downside is that when there are foreground images present, they tend to get a halo around their edges. On the plus side, subtracting the sky glow from each individual frame has totally removed the clouds from the image. The background is a pretty dark gray, but not completely black. This can be tweaked with a little use of curves to produce the final image

The star trail when sky glow has been subtracted from each individual frame before merging, with curve adjustments at the edge

The star trail when sky glow has been subtracted from each individual frame before merging, with curve adjustments at the edge

One final tip is to run a guassian blur with a radius of 1.2px on the final image before saving. This will smooth out any jagged edges on the trails caused by the tiny gaps between successive frames.

A DuoTone process using GIMP

All the photographic management & processing tasks I do use open source applications, in particular Digikam and GIMP. For processing, I’ll often convert to monochrome and then add subtle toning to the image. If I’m lazy I’ll do a quick monotone using the “Colors -> Colourize” menu option, but for things that I care more about I’ll go to the trouble of applying a duotone. There are a number of different ways to achieve the same end result, and for this blog posting I’ll illustrate a technique using layers in GIMP. The screenshots here are taken on Fedora 18, with GIMP 2.8.4

Initial colour image

The image we’re starting with is a simple shot of the Roman Baths in Bath which I’ve scaled down to approx 900×600 pixels, which is the standard resolution I used for things which will be uploaded to the web only.

bath-step1-orig

There is of course only one layer to start off with, which has been given the name “Background”.

layers-step1-orig

Step 1: Conversion to B&W

Before applying any tone, the colour needs to be removed from the image. There are a huge variety of techniques for doing this, which could satisfy many blog postings in their own right. In this case I’ve made use of the relatively unknown “c2g” operation (Tools -> GEGL Option -> c2g). This produces a fairly contrasty and grainy monochrome image

bath-step2-c2g

Step 2: Copy layers

Now it starts to get interesting. Create two copies of the “Background” layer, giving them the convenient names “Highlights” and “Shadows”

layers-step3-layers

Step 3: Add layer masks

Right click on the thumbnail in each of the new layers and select “Add layer Mask”. In the dialog that pops up, select “Grayscale copy of layer”. Then select the thumbnail of the mask in the “Shadows” layer and invoke the “Colours -> Invert” menu option. The layers view should now look like this

layers-step4-masks

Step 4: Fill layer canvas

Set the foreground and background tool colours to those that will be used for the toning. With this image, I am using #90551d for the brown tone and #184e83 for the blue tone. Now select the image thumbnail of the “Highlights” layer and fill with the foreground colour (blue) by pressing “Ctrl+,” (or using the bucket fill tool). Repeat for the “Shadows” layer but fill it with the background colour (brown) by pressing “Ctrl+.”. The layers view should now look like this:

layers-step5-filled

This should have had quite a dramatic effect on the actual image

bath-step5-filled

Step 5: Set layer mode

After the previous step, we’re just seeing the addtion of two colour masks, which isn’t the desired effect. The colours need to applied selectively to the highlights and shadows respectively. To achieve this goal, the blending mode of the “Highlights” and “Shadows” layers needs to be changed from “Normal” to “Color”. The layers view will now look like this:

layers-step6-mode

Looking at the actual image, we’re heading in the right kind of direction, but the toning is still quite strong

bath-step6-mode

Step 6: Set layer opacity

The final task is to moderate the toning effect, which is achieved by changing the opacity of the “Highlights” and “Shadows” layers. For this image, the “Highlights” opacity is set to 16%, while the “Shadows” are slightly higher at 24% opacity.

layers-step7-final

Final image

This duotone processing is now complete. The final image has a fairy subtle toning. If a stronger tone is desired, the opacity settings in the previous step can be tweaked as desired. Personally for duotones, I prefer to keep the effect quite light, leaving stronger effects for monotoning.

bath-step7-final