Visual Stimuli

Compositing photos with a layer mask

auto exposure1.3 stops underexposed1.3 stops overexposedcomposite image (overexposed + underexposed)

Sometimes a scene has such a broad brightness range that it is impossible to capture all the details in both the shadows and the highlights in a single photograph, or on cloudy days where the sky shows up as solid white. There are several ways to compensate for this, but the one I have found works best is to combine to separate exposures with a layer mask. Properly done, this brings out the details in both the bright and dark areas.

This tutorial was done using The Gimp, a Free graphics program available for Linux (and UNIX), Mac OS X, and Windows. A similar process can be used in Photoshop, but I don't have that program.

What You Need

You need two photos of the same thing, taken with a digital camera, using a tripod. One photo should be overexposed by 1 to 1.5 stops, and the other photo should be underexposed by the same amount. (You can do this with a film camera, or without a tripod, but aligning two pictures taken that way is tedious and not covered here.) Exactly how you take these photos will vary between cameras, but many good ones can be set to do automatic exposure bracketing. As a side effect, you also get a picture that is exposed as well as the camera can do on its own. This technique won't work well if there is any movement in the photo so if leaves are blowing in the wind, or if you have cars or people moving in the background, or even a person as the subject (unless they can sit very, very still) you are likely to be disappointed.

At the top of this page is a series of four photos, the first is auto-exposed (consider it the camera's best shot), the second is underexposed by 1.3 stops, the third is overexposed by 1.3 stops, and the fourth is the resulting, composite photo. If you can't wait to try this out, you can save the two middle images and follow along (they are bigger than they look).

The Procedure

Open the overexposed image in the gimp.

Notice how the snake's head is well exposed, but the rock in front of it is almost white.

Open the "Layers" dialog box (Ctrl-L)
Create a new empty layer by clicking on the new layer icon (it looks like a piece of paper with a green plus sign.

Open the underexposed image.

Notice how the rock in front of the snake has lots of detail, but you can't see its head

Copy and paste the underexposed image onto the over the overexposed image. (Ctrl-A to select all, then Ctrl-C to copy it to the clipboard. Next, click on the overexposed image and Ctrl-V to paste.)
Anchor the Pasted Layer to the empty layer you created by clicking on the icon that looks like a boat anchor in the layers dialog box.
Close the original underexposed image, you won't be needing it anymore.
You now have a single image with two layers, the background is the overexposed image and the layer above it is the underexposed image. It is probably called "Empty Layer", change it now by right-clicking on the layer and selecting "Edit Layer Attributes", change the name to "underexposed.
Create a layer mask. right click on the "underexposed" layer and select "Add Layer Mask" In the dialog that pops up, choose "Black (Full Transparency)". In the layers dialog, in between the thumbnail of the underexposed image and the word "underexposed" you will now see a small black box with a white border.
paste a copy of the overexposed image into the layer mask of the underexposed image. This is a multi-step process.
  • In the Layers dialog, click on the "Background" layer.
  • In the Image window, select and copy the entire image (Ctrl-A to select all, then Ctrl-C to copy it to the clipboard.)
  • In the Layers dialog, click on the "underexposed" layer. (Make sure the black box still has a white rim around it, if not, click on the black box and the white "active" border will move to it.
  • In the Image window, paste the clipboard image onto the layer mask (Ctrl-V) then go back to the Layers dialog and click on the anchor icon. The black box will be replaced with a black and white thumbnail of the overexposed image. (see figure 3)
You should now see a much improved picture, there are a few more steps to make it perfect.
Gaussian Blur the layer mask. Right click on the image, select "Filters", then "Blur", then "Gaussian Blur (IIR)". A dialog will pop up allowing you to set the Blur Radius. Finding the best value may take some trial and error. the smaller the image, the smaller the radius you want. For a small image like this, try 5 or 10 pixels, when I do it on a full resolution, six megapixel (3000x2000) image, I use a radius of 20 pixels.
You may want to adjust the color curves of the mask. Right click on the image, and select "Layer", then "Colors", then "Curves". I dragged the black point at the lower left, over a little to the right. This lets a bit more of the overexposed image show through.
Optional step. In the Layers dialog you can move the Opacity slider and it will affect how much of the background shows through. I didn't do it for this example, but you can play around with it.
Flatten the image. This will merge the layers into a single image. In the Layers dialog, right click on the "underexposed" layer, then select "Flatten Image".
Save the image. Right click on the image, select "File", then "Save As". in the dialog, put in the filename. I used "copper_layermask.jpg".

Your done! enjoy your newly-enhanced image.

Notice how you can see both the detail in the forground rock and the snake itself.

Variations

There are variations on this procedure that may produce a better result, you should try some out and see. Often, instead of 1.3 stops under and overexposed, using 1.7 stops is better. I sometimes also use the auto-exposed version and a 2.0 stop underexposed version. After flattening the image, you can do more tweaks, I suggest trying the Colors->Levels and moving the white point to the left. Also, increasing the saturation can help since this process tends to reduce it a bit.

Related Techniques

I forgot where I first saw this, but I certainly didn't come up with it on my own. There are other ways to accomplish a similar effect. If you only have a single photo and it fairly well exposed, you may be able to bring out more detail using a contrast map. If a photo has good detail but one half is too dark or too light, consider using a digital ND Filter. Another technique that uses two exposures is a blended exposure but I find this much to painstaking and time consuming to do.

[Visual Stimuli.] Go Back to Visual Stimuli

Copyright 2005,2006 G. Edward Johnson. All rights reserved.