1. A non-transitory machine readable medium of a device that captures images, the medium storing a program that when executed by at least one processing unit captures an image of a high dynamic range (HDR) scene, the program comprising sets of instructions for: capturing and storing a plurality of images at a first exposure level; upon receiving a command to capture the HDR scene, capturing a first image at a second exposure level and a second image at a third exposure level; selecting a third image from the captured plurality of images; and compositing the first, second, and third images to produce a composite image that captures the HDR scene.