1. Apparatus comprising: a digital imaging device that comprises an image sensor, processing circuitry, and a storage device; and firmware stored in the digital imaging device that runs on the processing circuitry and that comprises a calibration and gain correction algorithm that uses singular-value decomposition to generate compressed approximated gain masks that are stored in the storage device and that are used to process images generated by the image sensor to correct them for certain effects that degrade image quality.