# Patent

## Title
Systems and methods for color lens shading correction

## Abstract

System and methods are provided for performing color lens shading correction. A plurality of mesh points are generated. Mesh gain parameters associated with the mesh points are determined. The mesh gain parameters are applied to an input image for color lens shading correction. A color entropy related to color distribution of the corrected input image is obtained. The mesh gain parameters are adjusted to reduce the color entropy.

## Background
CROSS-REFERENCE TO RELATED APPLICATIONS
This disclosure claims priority to and benefit from U.S. Provisional Patent Application No. 61/871,631, filed on Aug. 29, 2013, the entirety of which is incorporated herein by reference.


FIELD
The technology described in this patent document relates generally to data processing and more particularly to image processing.
BACKGROUND
In an image, a particular pixel can be represented in a RGB color space as follows:

R(x,y)=∫I(x,y,z)×CR(λ)dλ

G(x,y)=∫I(x,y,z)×CG(λ)dλ

B(x,y)=∫f(x,y,z)×CB(λ)dλ  (1)

where R, G and B represent pixel values of the pixel, x and y represent horizontal and vertical position values of the pixel, and CR(λ), CG(λ), and CB(λ) represent transmission responses of R, G, B color filters in an image-capturing device (e.g., a camera).

Lens shading effects often occur in an image-capturing device (e.g., a camera). One common lens shading effect involves color non-uniformity in an image. That is, a same color in reality becomes different colors at a center of a captured image and at a corner of the captured image. The color lens shading effect is often caused by, for example, optical cross-talk, defective infrared filter, etc.
Considering the color lens shading (CLS) effects, the pixel values of the pixel can be determined as follows:

R(x,y)=∫I(x,y,z)×CR(λ)×CLS(λ,α(x,y))dλ

G(x,y)=∫I(x,y,z)×CG(λ)×CLS(λ,α(x,y))dλ

B(x,y)=∫I(x,y,z)×CB(λ)×CLS(λ,α(x,y))dλ  (1)

where CLS(λ, α(x, y)) represents a CLS gain function, and a represents an incident angle that is a function of pixel position.

A CLS gain is determined as follows:




  
    
      
        
          
            Gain
            X
          
          ⁡
          
            (
            
              x
              ,
              y
            
            )
          
        
        =
        
          
            ∫
            
              
                
                  I
                  ⁡
                  
                    (
                    
                      x
                      ,
                      y
                      ,
                      λ
                    
                    )
                  
                
                ⨯
                
                  
                    C
                    X
                  
                  ⁡
                  
                    (
                    λ
                    )
                  
                
                ⨯
                
                  CLS
                  ⁡
                  
                    (
                    
                      λ
                      ,
                      
                        α
                        ⁡
                        
                          (
                          
                            x
                            ,
                            y
                          
                          )
                        
                      
                    
                    )
                  
                
              
              ·
              
                d
                λ
              
            
          
          
            ∫
            
              
                
                  I
                  ⁡
                  
                    (
                    
                      x
                      ,
                      y
                      ,
                      λ
                    
                    )
                  
                
                ⨯
                
                  
                    C
                    X
                  
                  ⁡
                  
                    (
                    λ
                    )
                  
                
              
              ·
              
                d
                λ
              
            
          
        
      
    
    
      
        (
        2
        )
      
    
  




where X represents a R channel, a G channel, or a B channel.

SUMMARY
In accordance with the teachings described herein, system and methods are provided for performing color lens shading correction. A plurality of mesh points are generated. Mesh gain parameters associated with the mesh points are determined. The mesh gain parameters are applied to an input image for color lens shading correction. A color entropy related to color distribution of the corrected input image is obtained. The mesh gain parameters are adjusted to reduce the color entropy.
In one embodiment, a method is provided for performing color lens shading correction. A plurality of original correction curves are generated through calibration. The plurality of original correction curves are applied to an input image to obtain one or more color entropies, a color entropy being associated with color distribution of the input image. A first original correction curve is determined based at least in part on the color entropies. Color lens shading correction is performed based at least in part on the first original correction curve.
In another embodiment, a system for performing color lens shading correction includes one or more data processors and a computer-readable storage medium encoded with instructions for commanding the data processors to execute certain operations. A plurality of mesh points are generated. Mesh gain parameters associated with the mesh points are determined. The mesh gain parameters are applied to an input image for color lens shading correction. A color entropy related to color distribution of the corrected input image is obtained. The mesh gain parameters are adjusted to reduce the color entropy.
In yet another embodiment, a system for performing color lens shading correction includes one or more data processors and a computer-readable storage medium encoded with instructions for commanding the data processors to execute certain operations. For example, A plurality of original correction curves are generated through calibration. The plurality of original correction curves are applied to an input image to obtain one or more color entropies, a color entropy being associated with color distribution of the input image. A first original correction curve is determined based at least in part on the color entropies. Color lens shading correction is performed based at least in part on the first original correction curve.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 depicts an example diagram for a CLS correction system.
FIG. 2 depicts an example flow diagram for CLS correction using correction curves.
FIG. 3 depicts another example flow diagram for CLS correction using correction curves.
FIG. 4 depicts another example flow diagram for CLS correction using correction curves.
FIG. 5 depicts an example diagram showing optimal weighting for two frames.
FIG. 6 depicts an example diagram showing optimal weighting for multiple frames.
FIG. 7 depicts an example flow diagram for performing color lens shading correction.
FIG. 8 depicts another example flow diagram for performing color lens shading correction.



DETAILED DESCRIPTION
Different models have been implemented (e.g., in image sensor pipeline processing) for reducing color lens shading (CLS) effects. For example, a model assumes that a CLS gain of a particular pixel depends on the pixel position and the color channels, but does not depend on incident light on the pixel. This model often does not work well for different scenes or different ambient lights.
Another model assumes that a CLS gain of a pixel depends on the pixel position, the color channels and the spectrum of ambient light, where ambient light can be estimated using an automatic white balance (AWB) unit. However, this model may have certain problems. For example, AWB estimation and CLS correction often depends on each other in an image processing pipeline, and may cause oscillation because of the mutual dependency. In addition, some other approaches for reducing CLS effects, such as calibration of camera modules one by one and addition of a blue glass in front of a camera, may involve high costs and limited effects.
FIG. 1 depicts an example diagram for a CLS correction system. As shown in FIG. 1, a CLS correction module 102 receives an input image 104 and performs CLS correction to obtain a corrected image 106. The CLS correction module 102 performs mesh-based CLS correction or correction-curve-based CLS correction.
The mesh-based CLS correction uses a color entropy related to color distribution of an image. For example, a denser color distribution results in a smaller color entropy. CLS effects often introduce different color shifts at the center of an image and at the corners of the image, and thus tend to increase color entropy. Better CLS correction may be achieved by reducing (e.g., minimizing) the color entropy.
Specifically, pixel values of a particular pixel in the input image 104 correspond to (r, g, b) in a RGB space. A horizontal coordinate and a vertical coordinate in a chromatic space are determined to be x=f1(r/g) and y=f2(b/g), respectively, where f1 and f2 represent two functions. For example, f1 and f2 both correspond to a logarithm function. Then, a pixel cloud may be generated for the input image 104 in the chromatic space.
If most of the pixel cloud locates in a rectangle of xε(xmin, xmax) and yε(ymin, ymax), then the rectangle is divided into M*N grids. A two-dimensional chromatic histogram for the input image 104 is calculated based on the M*N grids. A color presence probability that corresponds to an ith row and a jth column of the M*N grids is calculated as Pi, j. A two-dimensional color entropy is determined as follows:




  
    
      
        
          
            CE
            
              2
              ⁢
              D
            
          
          ⁡
          
            (
            I
            )
          
        
        =
        
          -
          
            
              ∑
              
                
                  i
                  ∈
                  
                    [
                    
                      1
                      ,
                      M
                    
                    ]
                  
                
                
                  j
                  ∈
                  
                    [
                    
                      1
                      ,
                      N
                    
                    ]
                  
                
              
            
            ⁢
            
              
                P
                
                  i
                  ,
                  j
                
              
              ·
              
                log
                ⁡
                
                  (
                  
                    P
                    
                      i
                      ,
                      j
                    
                  
                  )
                
              
            
          
        
      
    
    
      
        (
        3
        )
      
    
  




In addition, a one-dimensional color entropy is determined as follows:





  
    
      
        
          
            CE
            
              1
              ⁢
              D
            
          
          ⁡
          
            (
            I
            )
          
        
        =
        
          
            -
            
              
                ∑
                
                  i
                  ∈
                  
                    [
                    
                      1
                      ,
                      M
                    
                    ]
                  
                
              
              ⁢
              
                
                  P
                  i
                  ′
                
                ·
                
                  log
                  ⁡
                  
                    (
                    
                      P
                      i
                      ′
                    
                    )
                  
                
              
            
          
          -
          
            
              ∑
              
                j
                ∈
                
                  [
                  
                    1
                    ,
                    N
                  
                  ]
                
              
            
            ⁢
            
              
                Q
                j
              
              ·
              
                log
                ⁡
                
                  (
                  
                    Q
                    j
                  
                  )
                
              
            
          
        
      
    
    
      
        (
        4
        )
      
    
  




where Pi′ represents a color presence probability associated with r/g, and Qj represents a color presence probability associated with b/g.

The mesh-based CLS correction begins with generating a plurality of mesh points. One or more mesh gain parameters are determined. The mesh gain parameters are applied to the input image 104 for CLS correction, and a color entropy related to color distribution of the corrected image 106 is obtained. The mesh gain parameters are adjusted to reduce the color entropy for better CLS correction.
Specifically, an N-point mesh (e.g., in a grid pattern, in a circle pattern, etc.) is defined. For each mesh point, a mesh gain parameter for a green channel is fixed to 1.0. Mesh gain parameters for a red channel and a blue channel are kept as variable parameters. Thus, a vector with 2*N mesh gain parameters can be determined as follows:

v=(rgain(1),bgain(1),rgain(2),bgain(2), . . . rgain(N),bgain(N))  (5)

where v represents the vector, rgain represents the mesh gain parameter for the red channel, and bgain represents the mesh gain parameter for the blue channel. The N-point mesh can be denoted as Mesh(v).

An interpolation is performed based on the mesh gain parameters to obtain channel gain parameters for an entire image related to the mesh. Various interpolation methods may be implemented, e.g., bi-linear interpolation, bi-cubic interpolation, B-spline interpolation, or other suitable methods.
The channel gain parameters are applied to the input image 104 to obtain a corrected image 106 as follows:

I′(x,y)=I(x,y)×interpolate(Mesh(v))  (6)

where I′ represents the corrected image 106, I represents the input image 104, and interpolate(Mesh(v)) represents the channel gain parameters. In addition, “×” represents multiplication for each color channel. Furthermore, a color entropy, CE(I′) for the corrected image 106 is obtained. For example, the color entropy for the corrected image 106 corresponds to the vector v.

Various methods may be implemented to reduce the color entropy for better CLS correction. For example, a Newton's method is used for reducing (e.g., minimizing) the color entropy to obtain an optimal color entropy, v_opt. A CLS correction map can be generated through interpolation based on a new mesh obtained using the optimal color entropy, Mesh(v_opt).
The CLS correction module 102 may perform correction-curve-based CLS correction using correction curves obtained through calibration. FIG. 2 depicts an example flow diagram for CLS correction using correction curves. As shown in FIG. 2, multiple correction curves are applied to input image 104 to obtain color entropies, and a correction curve corresponding to the smallest color entropy is selected for better CLS correction.
Specifically, at 302, the input image 104 is received. At 304, a plurality of correction curves (e.g., N correction curves) that are generated through calibration are applied to the input image 104 for CLS correction. Corresponding, at 306, various color entropies (e.g., N entropies) are obtained based on CLS correction using the correction curves. Different color entropies are compared. At 308, a correction curve that corresponds to a smallest color entropy is selected. At 310, the selected correction curve and a presently-used correction curve are blended to generate a new correction curve to replace the presently-used correction curve. At 312, the new correction curve is applied to the input image 104 for final CLS correction. In some embodiments, the selected correction curve can be directly applied to the input image 104 for final CLS correction. For example, the correction curves are generated from white chart images under different light sources.
FIG. 3 depicts another example flow diagram for CLS correction using correction curves. As shown in FIG. 3, a first color entropy is obtained by applying a presently-used correction curve to the input image 104, and a second color entropy is obtained by selecting one of a plurality of correction curves and applying the selected correction curve to the input image 104. A new correction curve is generated based at least in part on the two color entropies for better CLS correction.
Specifically, at 402, the input image 104 is received. At 404, the presently-used correction curve is applied to the input image 104 for CLS correction. At 406, the first color entropy is obtained. At 408, one of the plurality of correction curves is selected, e.g., based on a round-robin algorithm, and is applied to the input image 104 for CLS correction. At 410, the second color entropy is obtained. At 412, the first color entropy is compared with the second color entropy, and the correction curve that corresponds to the smaller color entropy is selected. At 414, the selected correction curve and the presently-used correction curve are blended to generate a new correction curve to replace the presently-used correction curve. At 416, the new correction curve is applied to the input image 104 for final CLS correction. In some embodiments, the selected correction curve can be directly applied to the input image 104 for final CLS correction.
Weighted correction curves may be used for CLS correction. For example, a weighting factor, F, is determined as follows:




  
    
      
        
          
            ∑
            
              i
              =
              1
            
            N
          
          ⁢
          
            F
            ⁡
            
              (
              i
              )
            
          
        
        =
        1
      
    
    
      
        (
        7
        )
      
    
  




where N represents a number of original correction curves. A weighted correction curve is generated based on the weighting factor and the original correction curves.

The weighted correction curve is then applied to the input image 104 for CLS correction. Corresponding, a color entropy is obtained based on CLS correction using the weighted correction curve. The weighting factor is adjusted to reduce (e.g., minimize) the color entropy, e.g., through a Newton method. An optimal weighting factor may be obtained for optimal CLS correction.
FIG. 4 depicts another example flow diagram for CLS correction using correction curves. As shown in FIG. 4, a first color entropy is obtained by applying a presently-used weighted correction curve to the input image 104, and a second color entropy is obtained by applying a first correction curve to the input image 104, where the first correction curve is determined by blending the presently-used correction curve and another correction curve selected from the original correction curves (e.g., through a round-robin algorithm). A correction curve is determined based on the comparison of the two color entropies for better CLS correction.
Specifically, at 502, the input image 104 is received. At 504, the presently-used weighted correction curve is applied to the input image 104 for CLS correction. At 506, the first color entropy is obtained. One of the original correction curves is selected, e.g., based on a round-robin algorithm, and is blended with the presently-used correction curve to generate the first correction curve. At 508, the first correction curve is applied to the input image 104 for CLS correction. At 510, the second color entropy is obtained. At 512, the first color entropy is compared with the second color entropy, and the correction curve that corresponds to the smaller color entropy is selected to replace the presently-used correction curve. At 514, the selected correction curve is applied to the input image 104 for final CLS correction.
Different correction curves may be obtained for different modules (e.g., different types of corner modules) in a camera. One or more corner modules may be selected based on r-g variations and/or b-g variations. For example, different corner-to-center r-g variations can be determined as follows:

Top-left corner variation: VTL=(r/g)TL/(r/g)c 

Top-right corner variation: VTR=(r/g)TR/(r/g)c 

Bottom-left corner variation: VBL=(r/g)BL/(r/g)c 

Bottom-right corner variation: VBR=(r/g)BR/(r/g)c 

where TL, TR, BL, BR, C stand for top-left, top-right, bottom-left, bottom-right, center, respectively.

A function S(A, B, C, D) is determined as follows:




  
    
      
        
          
            S
            ⁡
            
              (
              
                A
                ,
                B
                ,
                C
                ,
                D
              
              )
            
          
          =
          
            
              
                V
                
                  T
                  ⁢
                  
                    
                  
                  ⁢
                  L
                
                A
              
              ·
              
                V
                
                  T
                  ⁢
                  
                    
                  
                  ⁢
                  R
                
                B
              
              ·
              
                V
                
                  B
                  ⁢
                  
                    
                  
                  ⁢
                  L
                
                C
              
              ·
              
                V
                
                  B
                  ⁢
                  
                    
                  
                  ⁢
                  R
                
                D
              
            
            
              
                V
                
                  T
                  ⁢
                  
                    
                  
                  ⁢
                  L
                
                
                  1
                  -
                  A
                
              
              ·
              
                V
                
                  T
                  ⁢
                  
                    
                  
                  ⁢
                  R
                
                
                  1
                  -
                  B
                
              
              ·
              
                V
                
                  B
                  ⁢
                  
                    
                  
                  ⁢
                  L
                
                
                  1
                  -
                  C
                
              
              ·
              
                V
                
                  B
                  ⁢
                  
                    
                  
                  ⁢
                  R
                
                
                  1
                  -
                  D
                
              
            
          
        
        ,
        
          A
          ∈
          
            {
            
              0
              ,
              1
            
            }
          
        
        ,
        
          B
          ∈
          
            {
            
              0
              ,
              1
            
            }
          
        
        ,
        
          C
          ∈
          
            {
            
              0
              ,
              1
            
            }
          
        
        ,
        
          D
          ∈
          
            {
            
              0
              ,
              1
            
            }
          
        
      
    
    
      
        (
        7
        )
      
    
  




One or more corner modules that can minimize S(0,0,0,0), S(0,0,0,1), S(0,0,1,0), . . . , S(1,1,1,) may be selected. As an example, different corner-to-center b-g variations can be determined as follows:

Top-left corner variation: VTL=(b/g)TL/(b/g)c 

Top-right corner variation: VTR=(b/g)TR/(b/g)c 

Bottom-left corner variation: VBL=(b/g)BL/(b/g)c 

Bottom-right corner variation: VBR=(b/g)BR/(b/g)c 

The function S(A, B, C, D) can be determined based on the corner-to-center b-g variations, and one or more corner modules that can minimize S(0,0,0,0), S(0,0,0,1), S(0,0,1,0), . . . , S(1,1,1,) may be selected. Correction curves may be obtained for these selected corner modules.
In some embodiments, optimal weighting as described above may be performed across different illuminants (e.g., light sources), and then optimal weighting may be performed for different module variations. In certain embodiments, optimal weighting for different illuminants (e.g., light sources), and optimal weighting for different module variations may be interleaved and converged in a long loop cycle. FIG. 5 depicts an example diagram showing optimal weighting for two frames. FIG. 6 depicts an example diagram showing optimal weighting for multiple frames.
FIG. 7 depicts an example flow diagram for performing color lens shading correction. At 802, a plurality of mesh points are generated. At 804, mesh gain parameters associated with the mesh points are determined. At 806, the mesh gain parameters are applied to an input image for color lens shading correction. At 808, a color entropy related to color distribution of the corrected input image is obtained. At 810, the mesh gain parameters are adjusted to reduce the color entropy.
FIG. 8 depicts another example flow diagram for performing color lens shading correction. At 902, a plurality of original correction curves are generated through calibration. At 904, the plurality of original correction curves are applied to an input image to obtain one or more color entropies, a color entropy being associated with color distribution of the input image. At 906, a first original correction curve is determined based at least in part on the color entropies. At 908, color lens shading correction is performed based at least in part on the first original correction curve. In some embodiments, the color entropies are used to evaluate color lens shading of the input image.
This written description uses examples to disclose the invention, include the best mode, and also to enable a person skilled in the art to make and use the invention. The patentable scope of the invention may include other examples that occur to those skilled in the art. Other implementations may also be used, however, such as firmware or appropriately designed hardware configured to carry out the methods and systems described herein. For example, the systems and methods described herein may be implemented in an independent processing engine, as a co-processor, or as a hardware accelerator. In yet another example, the systems and methods described herein may be provided on many different types of computer-readable media including computer storage mechanisms (e.g., CD-ROM, diskette, RAM, flash memory, computer's hard drive, etc.) that contain instructions (e.g., software) for use in execution by one or more processors to perform the methods' operations and implement the systems described herein.

## Claims

1. A method for performing color lens shading correction, the method comprising:
generating a plurality of mesh points;
determining mesh gain parameters associated with the mesh points;
applying the mesh gain parameters to an input image for color lens shading correction;
obtaining a color entropy related to color distribution of the corrected input image; and
adjusting the mesh gain parameters to reduce the color entropy.

2. The method of claim 1, wherein each mesh point is associated with at least three of the mesh gain parameters, which comprise a first gain for a green channel of the associated mesh point, a second gain for a red channel of the associated mesh point, and a third gain for a blue channel of the associated mesh point.

3. The method of claim 2, wherein the first gain for the green channel is determined to be 1.

4. The method of claim 1, wherein the mesh points are generated in a grid pattern or a circle pattern.

5. The method of claim 1, wherein applying the mesh gain parameters to the input image for color lens shading correction includes:
interpolating the mesh gain parameters to obtain channel gain parameters of an entire image related to the mesh points; and
applying the channel gain parameters to the input image.

6. The method of claim 5, wherein the mesh gain parameters are interpolated through bi-linear interpolation, bi-cubic interpolation, or B-spline interpolation.

7. The method of claim 1, wherein the mesh gain parameters are adjusted to reduce the color entropy according to a Newton's method.

8. A method for performing color lens shading correction, the method comprising:
generating a plurality of original correction curves;
applying the plurality of original correction curves to an input image to obtain one or more color entropies, a color entropy being associated with color distribution of the input image;
determining a first original correction curve based at least in part on the one or more color entropies; and
performing color lens shading correction based at least in part on the first original correction curve.

9. The method of claim 8, wherein determining the first original correction curve based at least in part on the one or more color entropies includes:
comparing the color entropies to determine a smallest color entropy; and
selecting the first original correction curve that corresponds to the smallest color entropy.

10. The method of claim 8, wherein performing color lens shading correction based at least in part on the first original correction curve includes:
generating a second original correction curve by blending the first original correction curve and a presently-used original correction curve; and
applying the second original correction curve to the input image for color lens shading correction.

11. The method of claim 8, wherein applying the plurality of original correction curves to an input image to obtain one or more color entropies and determining a first original correction curve based at least in part on the one or more color entropies includes:
applying a presently-used original correction curve to the input image to obtain a first color entropy;
determining a second original correction curve among the plurality of original correction curves;
applying the second original correction curve to the input image to obtain a second color entropy; and
in response to the first color entropy being larger than the second color entropy, selecting the second original correction curve.

12. The method of claim 11, wherein performing color lens shading correction based at least in part on the first original correction curve includes:
generating a third original correction curve by blending the presently-used original correction curve and the second original correction curve; and
applying the third original correction curve to the input image for color lens shading correction.

13. The method of claim 11, wherein the second original correction curve is determined among the plurality of original correction curves according to a round-robin algorithm.

14. The method of claim 8, wherein applying the plurality of original correction curves to the input image to obtain one or more color entropies includes:
determining a weighting factor;
generating a first weighted correction curve based at least in part on the weighting factor and the plurality of original correction curves; and
applying the first weighted correction curve to the input image to obtain a first color entropy.

15. The method of claim 14, wherein:
determining the weighting factor includes: adjusting the weighting factor to reduce the first color entropy; and
the first original correction curve corresponds to the first weighted correction curve.

16. The method of claim 8, wherein applying the plurality of original correction curves to the input image to obtain one or more color entropies includes:
determining a weighting factor;
applying a presently-used weighted correction curve to the input image to obtain a first color entropy, the presently-used weighted correction curve being generated based at least in part on the weighting factor and a presently-used original correction curve;
determining a second original correction curve among the plurality of original correction curves;
generating a third correction curve by blending the second original correction curve and the presently-used original correction curve;
applying the third correction curve to the input image to obtain a second color entropy; and
in response to the first color entropy being larger than the second color entropy, applying the third correction curve to the input image for color lens shading correction.

17. The method of claim 8, wherein the plurality of original correction curves are generated through calibration using white chart images under different light sources.

18. The method of claim 8, wherein the one or more color entropies are used to evaluate color lens shading of the input image.

19. A system for performing color lens shading correction, the system comprising:
one or more data processors; and
a non-transitory computer-readable storage medium encoded with instructions for commanding the data processors to execute operations including:
generating a plurality of mesh points;
determining mesh gain parameters associated with the mesh points;
applying the mesh gain parameters to an input image for color lens shading correction;
obtaining a color entropy related to color distribution of the corrected input image; and
adjusting the mesh gain parameters to reduce the color entropy.

20. A system for performing color lens shading correction, the system comprising:
one or more data processors; and
a non-transitory computer-readable storage medium encoded with instructions for commanding the data processors to execute operations including:
generating a plurality of correction curves through calibration;
applying the plurality of correction curves to an input image to obtain one or more color entropies, a color entropy being associated with color distribution of the input image;
selecting a first correction curve based at least in part on the color entropies; and
performing color lens shading correction based at least in part on the first correction curve.