1. A method comprising: obtaining a first image that was captured using a first exposure length, wherein the first image includes a first set of two or more properly-exposed pixels and a second set of two or more improperly-exposed pixels; determining a second exposure length based on pixel values of the second set of two or more improperly-exposed pixels in the first image; obtaining a second image that was captured using the second exposure length, wherein the second image includes a third set of two or more pixels that correspond to the second set of two or more improperly-exposed pixels in the first image; determining a third exposure length based on the first set of two or more properly-exposed pixels in the first image and a first target average pixel value; obtaining a third image that was captured using the third exposure length, wherein the third image includes a fourth set of two or more properly-exposed pixels and a fifth set of two or more improperly-exposed pixels; determining a fourth exposure length based on the fifth set of two or more improperly-exposed pixels in the third image and a second target average pixel value, wherein the second target average pixel value is different from the first target average pixel value; obtaining a fourth image that was captured using the fourth exposure length, wherein the fourth image includes a sixth set of two or more pixels that correspond to the fifth set of two or more improperly-exposed pixels in the third image; and forming, by a computing device, a fifth image by selecting pixels from the fourth set of properly-exposed pixels in the third image and pixels from the sixth set of two or more pixels in the fourth image that correspond to the fifth set of two or more improperly-exposed pixels in the third image.