A Multifocus Method for Controlling Depth of Field

Paul Haeberli

Oct 1994

Horiz Bar


When a photograph is taken with a camera, the lens is focused at a particular distance. Objects nearer or farther than this focal distance will appear blurred. By changing the focus of the lens, near objects or distant objects can be made to appear in sharp focus. If you want to create an image where distant objects as well as close objects are in focus, two or more images can be merged together to make an image with increased depth of field. This is done using a simplification of a pyramid-based technique described in [Ogden 85].

The Technique

Here are two images of the same scene, one focused close and the other focused at a distance.

2 original images

We can combine the in-focus parts of both photographs using the following procedure. First each input image is blurred.

Blurred originals

Next, we subtract the blurred image from the original above it, and create an image that shows the magnitude of the difference. This image will be dark where the original image is smooth, and will be bright where the original image has edges. The strength of the edge information maps directly into the brightness of these edge images.

Edge magnitudes

Now we compare the two edge images, and make an image that is black where the left image has more edge information, and is white where the right image has more edge information.

Selection image

Finally, this is used to create an image with the best parts of each original image. Where the image above is black, pixels from the left image are used. Where the image above is white, pixels from the right image are used.

Final image

A simple extension of this technique can be used to combine the in-focus parts of any number of photographs.


[Ogden 85] J.M. Ogden, E.H. Adelson, J.R. Bergen, P.J. Burt, Pyramid-based Computer Graphics, RCA Engineer, Sept/Oct, 1985.