Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/fbonomi/public_html/index.php:1) in /home/fbonomi/public_html/includes/ on line 1029

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/fbonomi/public_html/index.php:1) in /home/fbonomi/public_html/includes/ on line 1029

Warning: Cannot modify header information - headers already sent by (output started at /home/fbonomi/public_html/index.php:1) in /home/fbonomi/public_html/includes/ on line 630

Warning: Cannot modify header information - headers already sent by (output started at /home/fbonomi/public_html/index.php:1) in /home/fbonomi/public_html/includes/ on line 631

Warning: Cannot modify header information - headers already sent by (output started at /home/fbonomi/public_html/index.php:1) in /home/fbonomi/public_html/includes/ on line 632

Warning: Cannot modify header information - headers already sent by (output started at /home/fbonomi/public_html/index.php:1) in /home/fbonomi/public_html/includes/ on line 633
Night-time HDR stacking | Francesco Bonomi
warning: Cannot modify header information - headers already sent by (output started at /home/fbonomi/public_html/index.php:1) in /home/fbonomi/public_html/includes/ on line 141.

Night-time HDR stacking

This is a short tutorial on how to make night-time photos like this one:

and this one:

This image was obtained with a simple point-and-shoot camera like the Powershot A570 IS, empowered by the CHDK software and with a combination of  image stacking and HDR Tonemapping.

With the aid of a tripod and of a simple intervalometer script, I shot 40 photos with a 10" exposure each. The shots were taken at ISO 100 to reduce noise. Another shot was taken with identical parameters but covering the lens with a cloth, to have a dark frame also used to reduce noise.

I did not shoot in RAW (CHDK would have allowed this) but used the standard Jpeg setting (at the maximum quality available in the camera)

Each frame looks like this:

As you can see, everything is very under-exposed. One could try to correct the image using "Levels", but two prolems would arise:

If you try to give enough light to the sea, you get a lot of noise and a strongly overexposed area on the right:

If you keep the image darker, the sea stays almost black:

This is not bad, but not the result I wanted. I wanted stronger colors and to see the reflection of the tower in the sea.

I then used a program called ImageStacker to "stack" all the images together (there are other programs that do this, but ImageStacker is one is the one I prefer)

Basically, stacking is an operation of adding a lots of images together, pixel by pixel. This can be used to obtain two different results:
1) adding all the pixels, you get an image similar to the one you would obtain with an extremely long exposure.
2) averaging all the pixels, you get an image with an identical exposure but where (hopefully) most of the noise gets averaged out.

This is the image obtained with the "average" method:

This image is as dark as the original was, but at least we can do levels without suffering because of all that noise:

This is instead the image obtained using the "add" method:

The last two images look very similar, but there is an important difference in the dark areas: each pixel of an image only has values between 0 and 255. In the very dark areas, let\\\'s suppose we have a pixel with a value of about 3. In some of the photos, the pixel will have a value of 3, and in some other photos this pixel will have a value of 4.

Let\\\'s suppose we have 10 photos, and that the same pixel has this values in each photo:

4 4 3 4 3 4 3 3 3 3

we could think that this values represent a luminosity that is slightly more than 3 but less than 4.

If we average these photos, the result will be:

(4+4+3+4+3+4+3+3+3+3)/10 = 34/10 = 3 (because of rounding)

and we lose this additional information

If we just sum the images we will have the following result:

(4+4+3+4+3+4+3+3+3+3) = 34

and we could hope that this 34 has kept some information about that dark pixel.

The problem is that if a pixel was very bright (about 150, for example) then we would have some values like these:

150 152 151 150 151 150 151 150 152 150

The average would be:

(150+152+151+150+151+150+151+150+152+150) = 1507/10 = 151

The sum would instead be:

(150+152+151+150+151+150+151+150+152+150) = 1507 = 255

because 255 is the maximum value!

To put it short, average is good for bright areas, while adding id good for dark areas.

The idea is then to use both two images to make an HDR: the average for the bright areas and the sum for dark areas.

Actually, ImageStacker also allows to generate images that are a mix between average and add. I did a mix with a divisor of 4, meaning that with my 40 images I had:


(p1+p2+ ... +p39+p40)/40


(p1+p2+ ... +p39+p40)


(p1+p2+ ... +p39+p40)/4

This is the "mix4" image:

As you can expect, the mix4 image is an itnermediate between the average and the plain sum.

Using the "average" and the "mix4" image an HDR was generated (I used Photomatix) and after tonemapping, the final image shown above was obtained:

Sure, the "aesthetical" results can be discussed (and are far from optimal, in my opinion), and the look is completely un-natural for a night shot, but  I think that the technique is interesting and is very useful in very high-contrast situations (like often night shots are) where you want to keep information across strongly lighted and dark areas.

Another example:

In this case, the strong moon reflection made the things particularly difficoult as the contrast between light and dark was very strong. Also I had to keep the exposure very short to avoid over-exposing the reflection.

So, I shot 256 frames with exposure of 2 seconds, ISO 100:

On these images, trying to do levels gives very bad results, with a lot of noise:

The averaged image as always is rather dark:

And doing "Levels" on this image gives very strong artifacts (as in the example above, luminosity changes from 3 to 4 in discrete, visible steps)

The summed image is extremely over-exposed:

So, instead of the simple sum I used the sum/4 (p1+p2 ... +p255+p256)/4

After tonemapping, the final result was obtained, with surprisingly good colours, given the difficoult conditions.

Some backstage material: my a570 on a tripod, running CHDK and capturing the shots from a good vantage point:

The location of both pictures is the Tower of Barisardo, in Sardinia, Italy.