Flower Photography in the Cellphone Era #136

3 - Depth of Field    

The wide angle (x0.5) lens of the iPhone lets you get very close to the subject with a minimum focus distance of about 2 cm. This means that you can take detailed photos of a very small flower. However, even with the very small lens you’ll run into depth of field problems when important parts of the subject are at different distances from the lens. You can mitigate the problem by using a tripod, a delayed-action shutter and a long exposure time with the aid of a third party app like Halide. However, if you want to achieve the greatest detail, you need to use focus stacking, which overcomes the optical limitations of your camera by combining multiple images focussed at different distances from the lens. I’ll tell you about my efforts to use focus stacking on the iPhone which have been somewhat successful.

There are focus stacking apps for the iPhone and I’ve experimented with two of them. The first, called AuraHDR, lets you select a bunch of points on the image, after which it takes a shot focussed on each of them. You then export the photos to your Mac where you can use a focus stacking application like Affinity Photo to create an image combining them. Unfortunately, the app lets you use only the main lens and so it’s not useful for a closeup. It seems to be intended more for improving depth of field in landscape photography, as is demonstrated in their tutorial video. An app called CameraPixels seems at first sight just what I need. It has a “focus bracket” mode that lets you choose a range of distances from the lens and a number of shots to take over that range. You can select the wide angle lens and the nearest parts of the subject appear in focus when you click the shutter. However, when you export the resulting images to Affinity Photo and run the focus stacking software, the final image shows the nearest portions are out of focus. The camera must have defaulted to the main lens. I haven’t been able to change this but it should be easy enough for the developer to fix the problem.

So I am left with having to do the whole process myself, which isn’t difficult once you understand it. You’ll need a tripod and make sure that the clamps are firmly tightened. You want to be sure that the camera doesn’t move even slightly when you tap the shutter button and the screen when you manually select the focus points. Be sure to select a delayed shutter action. Take as many shots as you need to cover all of the parts of the image that you want in focus. I don’t ordinarily take more than half a dozen to cover the distances from the lens that I want to include. The inherent depth of field is enough that you shouldn’t need a greater number.

Once you have enough shots, export the image files to your Mac. You can then use an application that does focus stacking, like Affinity Photo or Photoshop, to generate the final image. The software needs  to do more than identify the best focussed portions of each image and to exclude the parts that are not well focussed. It also needs to correct for the different projection and magnification with varying distances from the lens. The first process is ‘alignment’, followed by smart combination of the images. If alignment of contributions from several images is imperfect then the image on the far right will show ‘ghosting’ as illustrated in this blowup of the stamens of a Geissorhiza.

Here is an example of what you can achieve. I photographed a single flower of the Pink Breath of Heaven, Coleonema pulchellum, which is only 8 mm in diametre. The first is a single shot and the second is the result of stacking five images focussed on different parts of the subject. The lower left petal is not well focussed in either photo because it is too close to the camera lens. You can easily see that the second is better focussed over most of the plant. What you won’t see without blowing up the photo is that there is some subtle ghosting, most noticeable in the leaflets at the lower right corner.

I expect that Apple will add focus stacking to the iPhone camera’s bag of tricks within the next generation or two, and when they do I’m sure they’ll do it right.

Posted on May 8, 2024 .