Lens and CCD correction using singular value decomposition

Imaging devices, such as digital cameras, scanners, displays and projectors, and related processing methods that implement calibration and post-capture image processing that quickly and accurately corrects image quality resulting from lens and CCD imperfections using a minimum amount of computation and memory storage space.

BACKGROUND

All digital cameras suffer from lens and CCD effects that degrade image quality. For example, lens vignetting (the property of all lenses to gather more light in the center of the image) causes darkening of the corners of the image when compared with the image center. Another degradation is color shading, which is a gradual shift in color from one edge of the image to another. Color shading is easiest to see when the scene to be captured is a solid color (e.g. a clear blue sky or a blank wall). Color shading is the result of an interaction between the lens and CCD and is present in all digital cameras to varying degrees. A third type of degradation are lens blemishes which are caused by irregular lens surfaces. These irregularities are most visible when the lens is at full telephoto and smallest aperture (similar to the effect of dust on the lens).

Good quality digital cameras utilize a calibration and post-capture image processing algorithm to reduce or remove unwanted lens and CCD effects. A camera is calibrated by capturing an image of a uniformly illuminated, uniform-color scene (e.g. a white wall). Since the scene is known to be of uniform brightness and color, gains can be determined for each pixel location (r,c) to ensure the final image has uniform brightness and color. These gains may be represented by a matrix G with R rows and C columns. Because lens and CCD distortion changes with zoom and aperture position, a gain image Gazneeds to be stored for each aperture a ε{1 . . . A} and zoom position zε{1 . . . Z}. Unfortunately, there can be 100 or more such gain images for all zoom and aperture settings. The key is to utilize a method that can be computed quickly with minimum on-camera memory use while still accurately correcting lens and CCD effects.

The polynomial approximation may then be written as:
Gaz≈YCazXT(3)
where the n×n matrix Cazof polynomial coefficients are given by
Caz=(YTY)−1YTGazX(XTX)−1(4)

Assuming n2coefficients per gain mask, 2 bytes per coefficient and 3 color planes, it would take a total of 6AZn2bytes to store all the polynomial coefficients. Assuming that the matrices X and Y can be precomputed, Equation 3 takes Cn(n+R) multiplies and C(n+R)(n−1) adds for a total of C(R+n)(2n−1) operations.

Polynomial fitting thus involves fitting a two-dimensional polynomial to the gain image and then storing the coefficients of the polynomial. Since there are usually 10 or so polynomial coefficients, only 10 numbers need to be stored for each zoom and aperture position. Additionally, since polynomials are generated using only multiplications and additions, gain masks can be efficiently computed and applied once the user captures an image.

Unfortunately, polynomials with an efficiently computable number of coefficients form a poor approximation to ideal gain masks. In short, polynomial fitting is a computationally efficient method of lens/CCD correction that involves a small amount of memory storage, but the overall correction ability is limited.

It would be desirable to have a gain correction method that may be implemented in a calibration and post-capture image processing algorithm that achieves a superior level of correction with minimal memory use.

DETAILED DESCRIPTION

The single value decomposition procedures discussed below relate to calibration and correction of images, and are generally described with regard to their use with a digital camera. However, it is to be understood that the method of calibration and correction described herein is also well-suited for use in scanners, displays and projectors, and the like, and is not limited to use in digital cameras.

Referring to the drawing figures,FIGS. 1aand1bare rear and front views, respectively, of an exemplary digital camera10that may employ gain correction methods that may be implemented in a calibration and post-capture image processing algorithm as disclosed herein. As is shown inFIGS. 1aand1b,the exemplary digital camera10comprises a handgrip section20and a body section30. The handgrip section20includes a power button21or switch21having a lock latch22, a record button23, a strap connection24, and a battery compartment26for housing batteries27. The batteries may be inserted into the battery compartment26through an opening adjacent a bottom surface47of the digital camera10.

As is shown inFIG. 1a,a rear surface31of the body section30comprises a liquid crystal display (LCD)32or viewfinder32, a rear microphone33, a joystick pad34, a zoom control dial35, a plurality of buttons36for setting functions of the camera10and a video output port37for downloading images to a computer, for example. As is shown inFIG. 1b,a zoom lens41extends from a front surface42of the digital camera10. A metering element43and front microphone44are disposed on the front surface42of the digital camera10. A pop-up flash unit45is disposed adjacent a top surface46of the digital camera10.

An image sensor11, such as a charge coupled device (CCD) array, for example, is coupled to processing circuitry12(illustrated using dashed lines), both of which may be housed within the body section30, for example. An exemplary embodiment of the processing circuitry12comprises a microcontroller (μC)12or central processing unit (CPU)12. The microcontroller12or CPU12is coupled to a nonvolatile (NV) storage device14, and a high speed (volatile) storage device15, such as synchronous dynamic random access memory (SDRAM)15, for example.

The processing circuitry12(microcontroller12or CPU12) in the digital camera10, embodies firmware13comprising a calibration and gain correction algorithm13that implements a method60using singular-value decomposition. This will be discussed in more detail below and with reference toFIG. 2.

The digital camera10is calibrated to generate a set of gain masks. These gain masks are compressed for on-camera storage with minimal loss of information into a form that is computationally efficient to decompress. In a first stage, the gain masks are individually compressed. Then, in a second stage, similarities between the compressed gain masks are exploited to further compress the data.

The gain masks are individually compressed by computing a compressed approximation of a single gain mask via singular-value decomposition (SVD) into
G=USVT(5)
where UTU=VTV=I, I is an identity matrix and VTrepresents the transpose of matrix V. The matrix S is diagonal with non-negative diagonal elements in decreasing order.

The diagonal elements of S are called the singular values of G. Because the elements of G change slowly with changing row or column (in other words, G is smooth), the singular values of G will decrease quickly. This means that all but the largest n singular values can be set to zero to obtain a good approximation of G.

Let the notation A(i:j, u: v) represent a sub-matrix of matrix A given by rows i thru j and columns u thru v. Define
Ū=U(1: R,1:n)√{square root over (S(1:n,1:n))}  (6)
V=V(1: C,1:n)√{square root over (S(1:n,1:n))}  (7)
so that the approximation can be written as G≈ŪVT.

An algorithm that can find U(1: R,1: n), V(1: C, 1: n)and S(1: n, 1: n) follows, This algorithm may be referred to as a subspace algorithm for partial single value decomposition.

The subspace algorithm is a method for finding the n largest singular values (eigenvalues) and singular vectors (eigenvectors) of a given R×R hermetian matrix A (a real-valued matrix A is hermetian if AT=A). The subspace algorithm iterates until the error is less than some tolerance ε as follows

Step 1: Pick an initial guess for U (e.g. U=A(1: R,1: n)).

Step 2: QR decompose U→QR and then set U=Q, such as by using a decomposition algorithm discussed in Press, H. et al,Numerical Recipes in C,Cambridge University Press, N.Y. 1992.

Step 4: If ||Y_US||>_then set U=Y and loop to Step 2.

Care must be taken not to choose n larger than the rank of A or the subspace method will not converge. The subspace method may be used to find the partial single value decomposition of a non-hermetian matrix A with R rows and C columns. Observe that
AAT=USVT(USVT)T=USVTVSUT=US2UT,
so the subspace algorithm can be used on AATto get U and S2. Matrix V can be solved for using AT=VSUT, ATU=VS, and ATUS—1=V. If R>C then it is faster to use ATA to get V and S2and compute U=AVS−1.

In the second stage, similarities between approximated gain masks are exploited in order to further reduce memory storage requirements. Let Ūazrepresent the matrix for a given aperture a and zoom position z. The following outer-product matrix is generated for each column of Ūaz

Pc=∑a,z⁢U_a⁢⁢z⁡(1⁢:⁢R,c)⁢U_a⁢⁢z⁡(1⁢:⁢R,c)T(8)
Singular-value decompose each outer product matrix
PcUcScUcT.  (9)
Define the matrix Ûc=Uc(1: R,1: w) in order to form the approximation Ūaz(1: R,c)≈ÛcTuazcwhere uazcis a w×1 vector given by
uazc=ÛcTŪaz(1:R,c).   (10)
Equations. 8, 9 and 10 are repeated to find the basis {circumflex over (V)}cand weights vazcfor each column ofVaz. Table 1 summarizes the memory requirements for this method and Table 2 summarizes the computational requirements.

FIGS. 2a-2dillustrate comparison between polynomial computation and single value decomposition procedures for R=122, C=163, A=10, and Z=11.FIG. 2ashows an uncorrected image of a uniformly illuminated, uniform color scene. Notice the non-uniform color from top to bottom and lens blemish in the lower right corner.FIG. 2bshows the image when corrected using the polynomial method with order n=3 which uses less memory but roughly the same number of operations as the single value decomposition method. Although vignetting has been reduced, the lens blemish is still clearly visible.

FIG. 2cshows the image when corrected using the polynomial method with order n=7 which uses roughly the same amount of memory, but nearly three times the computation of the single value decomposition method. Although the lens blemish has been reduced, it is still clearly visible.FIG. 2dshows the image when corrected using the single value decomposition method. The lens blemish in the lower right corner has been greatly reduced. Clearly, the single value decomposition method offers an improved trade-off between memory use, computational complexity and image correction ability.

Conventional polynomial fitting leads to a coarse approximation of the ideal gain mask when using the typical number of polynomial coefficients that lead to computational efficiency. In contrast, singular-value decomposition of the ideal gain mask leads to an excellent approximation versus the amount of computation required to regenerate the gain mask.

Given the above, and referring toFIG. 3, it is a flow diagram that illustrates an exemplary gain correction method60such as may be used with a digital camera10, for example. The exemplary gain correction method60may be implemented as follows.

An imaging device10, such as a digital camera10, is provided61that comprises an image sensor11, processing circuitry12and a storage device14. The processing circuitry12is configured62to embody firmware13comprising a calibration and gain correction algorithm13that uses singular-value decomposition to generate approximations of gain masks for use in correcting images generated by the image sensor11caused by certain effects that degrade image quality.

The imaging device10, or digital camera10, is calibrated63to generate a set of gain masks. The set of gain masks is compressed in two stages. Each individual gain mask is compressed64using single value decomposition to produce a singular-value-decomposed gain mask that comprises a compressed approximation of the gain mask. Each compressed approximated gain mask is then processed65to produce an outer product matrix. Each outer product matrix is then compressed66using single value decomposition to produce a singular-value-decomposed outer product matrix. The compressed set of singular-value-decomposed outer product matrices is stored67in the imaging device10, or digital camera10. During operation, an image is generated68by the image sensor11. A selected one of the stored compressed set of singular-value-decomposed outer product matrices that relates to the generated image is decompressed69. The generated image and the selected decompressed singular-value-decomposed outer product matrix are processed70to correct the image for effects that degrade image quality.

The above-described single value decomposition method of lens and CCD correction provides improved correction ability and less computational complexity compared with conventional polynomial correction. A strength of the single value decomposition method comes from use of custom separable functions that best approximate a given gain mask. These separable functions require extra memory storage but provide an improved trade-off between accuracy of the gain mask approximation and overall computation. The single value decomposition method can be used whenever a group of similar images need to be stored in compressed format. The single value decomposition method may be considered as a form of 3D compression that is particularly suited to relatively smooth images. As a result, the above-described method of calibration and correction is well-suited for use in scanners, displays and projectors.

Thus, digital cameras and algorithms that provide for lens and CCD correction using singular value decomposition have been disclosed. It is to be understood that the above-described embodiments are merely illustrative of some of the many specific embodiments that represent applications of the principles described herein. Clearly, numerous and other arrangements can be readily devised by those skilled in the art without departing from the scope of the invention.