HDR Photos: How to Merge

HDR stands for high dynamic range. Cameras with HDR capability take multiple photos of the same scene, each at different exposure settings. By merging these photos into a single photo one can create a single photo having the dynamic range of the set. The idea is simple: The brightest areas are taken from the darkest photo, the darkest areas are taken from the brightest photo.

Cameras with HDR capability sometimes merge the photos automatically. Others do not. Even if your camera doesn't have HDR capability, you can do it manually by holding the frame steady (like on a tripod) while you take 3 pictures. One with neutral exposure, one 2 stops darker, one 2 stops lighter. Then you can merge them yourself. I recently learned how to do this manually - that is, without using plugins designed for this purpose. Even if you have plugins or software that does this automatically, I found it educational to do it manually to better understand how it actually works. I used Gimp 2.8, though the features I use to do this exist in other software so you can apply this to other software if you know where to find the features.

This tutorial assumes you have 3 pictures to merge. If you have a different number, it's pretty easy to catch the idea and apply it.

Start by loading the pictures to a computer running Gimp 2.8. I will call the three pictures:

  • base: the middle exposure
  • dark: the dark exposure
  • light: the light exposure
  • Instructions summary:

  • Load the base picture
  • Add the dark image as a layer
  • Create a layer mask for the dark image
  • Add the light image as a layer
  • Create a layer mask for the light image
  • Combine all 3 layers to create the merged image
  • Load the Base Picture

    Simple: open the image using Gimp. This entire process is easier to understand if you also open the Gimp Layers window by pressing "Ctrl-L".

    Add the dark image as a layer

    Open dark as a new image in Gimp, then "Select All", and copy to the clipboard. Switch to base and add a layer. When you add the layer, name it "dark" and use the "transparency" type. Added layers by default go to the top of the stack, which is what you want. Now paste the clipboard, then click Anchor. This will paste the dark you copied, into the new layer. You now have 2 layers: one with base, the other with dark on top of base.

    Create a layer mask for the dark image

    Return to the Gimp window (not the layer) having the dark image. Desaturate it by selecting "Colors|Desaturate". On the Desaturate dialog, I usually select the Average of Lightness and Luminosity. The desaturated picture is black and white. The white areas are opaque, and this layer is on top, so the white area of the image is what you'll see in the merged image. The dark areas are transparent, so here you'll see through it to the lower layers (the other images). You can use "Colors|Curves" to make the image more white, or more black, to adjust how much of it will be used in the merged image. Now select all and copy the desaturated image to the clipboard.

    Return to the base image layers window. Right-click on the dark layer and select "Add Layer Mask". The settings on the dialog don't matter - so click the Add button. Now "Select All", paste, then select "Layer|Anchor". Now the dark layer is complete: it has the image data and mask to ensure only the lighest parts are used.

    Add the light image as a layer

    Open light as a new image in Gimp, then "Select All", and copy to the clipboard. Switch to base and add a layer. When you add the layer, name it "light" and use the "transparency" type. Now paste the clipboard, then click Anchor. This will paste the light you copied, into the new layer. You now have 3 layers: base on the bottom, covered by a partially masked dark, covered by light. You will see only light for now - because it doesn't yet have a mask.

    Create a layer mask for the light image

    Return to the Gimp window (not the layer) having the light image. Desaturate it by selecting "Colors|Desaturate". The dark areas are the ones you want to see in the merged image. Yet the light areas are the ones that will be used in the layer mask. So you need to invert the desaturated image. But, don't do that yet! First you may want to adjust the color curve to set how much of this picture will be used in the final merge. Do that before inverting it, because once you invert it, the picture will look weird and it will be much harder to judge this. When you've completed any color curve corrections, select "Colors|Invert". Now select all and copy the desaturated image to the clipboard.

    Return to the base image layers window. Right-click on the light layer and select "Add Layer Mask". The settings on the dialog don't matter - so click the Add button. Now "Select All", paste, then select "Layer|Anchor". Now the light layer is complete: it has the image data and mask to ensure only the darkest parts are used.

    Combine all 3 layers to create the merged image

    At this point you will see a single image that is the merge of the 3 originals. In the Layers window, you can click the eyeball icons to toggle each layer on and off, to see what effect it has on the image. You will see that the light image enhances the dark areas and the dark image enhances the light areas. You can now save the image. You can flatten/merge all the layers into a single JPG, and you can save the multi-layered image in case you want to adjust the masks later.

    NOTE: if the images don't line up, the camera must have moved in between shots. You can slide them around when you paste them together to correct for this.