A method of correcting vignetting in an image. The image includes a
plurality of pixels, each pixel having an intensity. The image is
flattened by adjusting the intensity of each pixel based on a vignette
function representative of vignetting characteristics of the image, the
vignette function having a plurality of free parameters, each free
parameter having a value. A vignette metric is determined based on the
flattened image. The values of one or more of the free parameters are
adjusted based on the vignette metric, and the flattening is performed
based on the adjusted values of the free parameters.