Abstract:
A method and apparatus for white balancing. The method comprising estimating the color temperature of at least a portion of the image, wherein the color temperature estimation algorithm is based on computing histogram correlations of at least a portion of at least one reference image and at least a portion of at least one target image, and correcting the white balance of at least a portion of the image utilizing the estimated color temperature.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application claims benefit of U.S. provisional patent application Ser. No. 61/149,937, filed Feb. 4, 2009, and U.S. provisional patent application Ser. No. 61/084,094, filed Jul. 28, 2009, which are herein incorporated by reference. 
     
    
     BACKGROUND OF THE INVENTION 
       [0002]    1. Field of the Invention 
         [0003]    Embodiments of the present invention generally relate to a method and apparatus for white balance based on image data; more specifically, image statistics and references. 
         [0004]    2. Description of the Related Art 
         [0005]    White balance is the process of removing unrealistic color cast from a digital image caused by the color of the illumination. Human eyes automatically adapt to the color of the illumination, such that white will always appear white. Unfortunately, image capturing devices, such as, camera sensors, can not adapt automatically. Therefore, white balance algorithms are needed for camera sensors, for example, to compensate for the effect of illumination. 
         [0006]    Automatic white balance algorithm (AWB) is an essential part of the imaging system pipeline. Digital still cameras and camera phones, for example, need AWB algorithms to correctly display the color of digital images. It has been a differentiating factor for different camera brands. 
       SUMMARY OF THE INVENTION 
       [0007]    Embodiments of the present invention generally relate to a white balancing method and apparatus for white balancing. The method comprising estimating the color temperature of at least a portion of the image, wherein the color temperature estimation algorithm is based on computing histogram correlations of at least a portion of at least one reference image and at least a portion of at least one target image, and correcting the white balance of at least a portion of the image utilizing the estimated color temperature. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0008]    So that the manner in which the above recited features of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to embodiments, some of which are illustrated in the appended drawings. It is to be noted, however, that the appended drawings illustrate only typical embodiments of this invention and are therefore not to be considered limiting of its scope, for the invention may admit to other equally effective embodiments. 
           [0009]      FIG. 1  is an embodiment of a general flow diagram for color temperature estimation and white balance correction; 
           [0010]      FIG. 2  is an embodiment of a detailed flow diagram for color temperature estimation and white balance correction; 
           [0011]      FIGS. 3(   a ) and ( b ) are embodiments of a diagram depicting design of a reference image for white balance; 
           [0012]      FIG. 4  is an embodiment of a flow diagram depicting the overall flow; 
           [0013]      FIG. 5  is an embodiment of block diagram for white balance calibration; 
           [0014]      FIG. 6  is an embodiment of a flow chart for color temperature estimation and white balance correction; and 
           [0015]      FIG. 7(   a )-( c ) are embodiments of scene brightness control functions. 
       
    
    
     DETAILED DESCRIPTION 
       [0016]      FIG. 1  is an exemplary embodiment of a general flow diagram for color temperature estimation and white balance correction. An image&#39;s data is utilized to perform color temperature estimation and white balance correction. The output includes R gain , G gain  and B gain . 
         [0017]      FIG. 2  is an exemplary embodiment of a flow diagram for color temperature estimation and white balance correction. The first step is to preprocess the image data. The preprocessing of the image data may include, but not necessarily, down sampling the original image by blocking averaging. For example, one may down-sample the original image from 2592×1944 to 128×36. 
         [0018]    The next step transforms the image data from RGB space into a chromaticity space. For example, the space we have used is YCbCr space, and that the chromaticity Cb and Cr are normalized by luminance Y [2]. The normalization by luminance Y may not be necessary. Hence, this algorithm may not be limited by normalization and a variation of this algorithm may be utilized. 
         [0000]        Y= 0.299 R+ 0.587 G+ 0.114 B    
         [0000]        Cb/Y= 256(−0.1726 R− 0.3388 G+ 0.5114 B )/ Y    
         [0000]        Cr/Y= 256(0.5114 R− 0.4283 G− 0.0832 B )/ Y    (1) 
         [0019]    The references for such an algorithm may be the histograms and the gray values of a color checker, taken under a variety of color temperatures. A Gretag Macbeth color checker SG, as shown in  FIG. 3(   a ), or a standard color checker, as shown in  FIG. 3(   b ), may be used. Any images with a collection of well-balanced popular object color may be used as reference image. Calibration of the algorithm means generating the reference histograms and gray values for a target sensor, which may include the steps discussed herein, which may or may not occur in the same ordered. 
         [0020]    In the first step, color checker images are taken with the target sensor in a light box under controlled color temperatures, which may or may not include all of the following: A (2800K), U30 (3000K), CWF (4200K), TL84 (4000K), D50 (5000K), D65 (6500K), D75 (7500K). 
         [0021]    In the second step, 2-D histograms of these references in the Cb/Y−Cr/Y space are computed by quantizing the Cb/Y into N (for example N=35) bins and Cr/Y into M (for example, M=32) bins, and counting the number of blocks or pixels falling into each Cr/Y and Cb/Y bin. 
         [0022]    In the third step, extracting the K gray reference values for each color temperature reference. For a standard Macbeth color checker ( FIG. 3(   b )), there are six gray levels available. We usually use the middle four gray levels. The white patch is not used because of saturation issues. The black patch is not used because of large quantization errors. 
         [0023]    Color temperature estimation is computed with the steps discussed herein, which may not occur in the same order. In the first step, the 2-D histogram of the input image in Cb/Y and Cr/Y space is generated in the same way as computing the histogram of the references. In the second step, the image histogram is transformed into a canonical form to reduce the influence of dominate objective color. One way to do so is to threshold the histogram, followed by normalization. The thresholding operation is shown in (2), and the normalization operation is shown in (3): 
         [0000]    
       
         
           
             
               
                 
                   
                     Hist 
                      
                     
                       ( 
                       
                         i 
                         , 
                         j 
                       
                       ) 
                     
                   
                   = 
                   
                     { 
                     
                       
                         
                           
                             
                               Hist 
                                
                               
                                 ( 
                                 
                                   i 
                                   , 
                                   j 
                                 
                                 ) 
                               
                             
                             , 
                           
                         
                         
                           
                             
                               if 
                                
                               
                                   
                               
                                
                               
                                 Hist 
                                  
                                 
                                   ( 
                                   
                                     i 
                                     , 
                                     j 
                                   
                                   ) 
                                 
                               
                             
                             ≤ 
                             
                               T 
                               hist 
                             
                           
                         
                       
                       
                         
                           
                             
                               T 
                               hist 
                             
                             , 
                           
                         
                         
                           
                             
                               if 
                                
                               
                                   
                               
                                
                               
                                 Hist 
                                  
                                 
                                   ( 
                                   
                                     i 
                                     , 
                                     j 
                                   
                                   ) 
                                 
                               
                             
                             &gt; 
                             
                               T 
                               hist 
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   2 
                   ) 
                 
               
             
           
         
       
     
         [0000]    Normalizing the histogram: 
         [0000]    
       
         
           
             
               
                 
                   
                     Hist 
                      
                     
                       ( 
                       
                         i 
                         , 
                         j 
                       
                       ) 
                     
                   
                   ← 
                   
                     
                       
                         Hist 
                          
                         
                           ( 
                           
                             i 
                             , 
                             j 
                           
                           ) 
                         
                       
                       · 
                       C 
                     
                     
                       
                         ∑ 
                         i 
                       
                        
                       
                         
                           ∑ 
                           j 
                         
                          
                         
                           Hist 
                            
                           
                             ( 
                             
                               i 
                               , 
                               j 
                             
                             ) 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   3 
                   ) 
                 
               
             
           
         
       
     
         [0000]    Where, T hist  is the maximal allowed histogram value. Scalar C guarantees that the sum of the histogram for all input images are equal to C. Normalization is optional. 
         [0024]    In the second step, the correlation score for each reference is computed. The correlation scores for each reference are computed in the following way: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       Corr 
                        
                       
                         ( 
                         i 
                         ) 
                       
                     
                     = 
                     
                       
                         
                           ∑ 
                           m 
                         
                          
                         
                           
                             ∑ 
                             n 
                           
                            
                           
                             Hist_ref 
                              
                             
                               
                                 ( 
                                 
                                   m 
                                   , 
                                   n 
                                   , 
                                   i 
                                 
                                 ) 
                               
                               · 
                               Hist_img 
                             
                              
                             
                               ( 
                               
                                 m 
                                 , 
                                 n 
                               
                               ) 
                             
                           
                         
                       
                       
                         StdDev_ref 
                         · 
                         StdDev_img 
                       
                     
                   
                   , 
                   
                     
 
                   
                    
                   
                     i 
                     = 
                     1 
                   
                   , 
                   2 
                   , 
                   … 
                    
                   
                       
                   
                   , 
                   
                     num_of 
                      
                     _ref 
                   
                 
               
               
                 
                   ( 
                   4 
                   ) 
                 
               
             
           
         
       
     
         [0000]    Where, num_of_ref is the number of color temperature references, 
         [0000]    
       
         
           
             
               
                 
                   
                     StdDev_x 
                     = 
                     
                       
                         
                           
                             1 
                             
                               M 
                               · 
                               N 
                             
                           
                            
                           
                             
                               ∑ 
                               
                                 n 
                                 = 
                                 1 
                               
                               N 
                             
                              
                             
                               
                                 ∑ 
                                 
                                   m 
                                   = 
                                   1 
                                 
                                 M 
                               
                                
                               
                                 Hist_x 
                                  
                                 
                                   
                                     ( 
                                     
                                       m 
                                       , 
                                       n 
                                     
                                     ) 
                                   
                                   2 
                                 
                               
                             
                           
                         
                         , 
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     x 
                     = 
                     
                       ref 
                        
                       
                           
                       
                        
                       or 
                        
                       
                           
                       
                        
                       img 
                     
                   
                 
               
               
                 
                   ( 
                   5 
                   ) 
                 
               
             
           
         
       
     
         [0000]    StdDev_x is the standard deviation (without removing mean) for x, and x denotes either the reference (ref) or the input image (img). The standard deviation can be computed either after removing the mean or without removing the mean. 
         [0025]    In another embodiment, estimating the color temperature of the illumination is determined by counting the number of blocks that fall into the circle with pre-defined radius R for each of the reference. The radius R may be different for each reference. The reference with the greatest count is the top 1 candidate for estimated color temperature. Multiple gray references for each color temperature reference may be used. 
         [0026]    In the third step, scene brightness control is applied. As for scene brightness control, different weights are applied to color temperature references, based on the estimation of the scene brightness under which the picture is taken. The motivation for scene brightness control comes from the observation that color temperature references between 4000K and 5000K are often confused with object colors (such as grass/foliage) for outdoor sunny scenes. However, these color temperatures are less likely to be found in outdoor sunny conditions. By estimating the brightness of the scene, one may reduce the influence of wrong color temperature references. 
         [0027]    The first procedure in scene brightness control is to estimate the brightness of the scene under which the image is taken. This process can be regarded as a reverse process of the Auto-Exposure, i.e., recovering the luminance level of the image before auto-exposure is applied to it. One embodiment of this operation is shown in (6): 
         [0000]    
       
         
           
             
               
                 
                   
                     Scene_Brightness 
                     = 
                     
                       
                         K 
                         · 
                         AverageY 
                       
                       
                         
                           
                             
                               
                                 
                                   Ana 
                                    
                                   
                                       
                                   
                                    
                                   log_gain 
                                 
                                 
                                   Ana 
                                    
                                   
                                       
                                   
                                    
                                   log_gain 
                                    
                                   _divider 
                                 
                               
                               · 
                             
                           
                         
                         
                           
                             
                               
                                 Digital_gain 
                                 
                                   Digital_gain 
                                    
                                   _divider 
                                 
                               
                               · 
                               Exposure_time 
                             
                           
                         
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     Where 
                     , 
                   
                 
               
               
                 
                   ( 
                   6 
                   ) 
                 
               
             
             
               
                 
                   
                     K 
                      
                     
                         
                     
                      
                     is 
                      
                     
                         
                     
                      
                     a 
                      
                     
                         
                     
                      
                     scalar 
                   
                   , 
                   
                     
                       and 
                        
                       
                           
                       
                        
                       AverageY 
                     
                     = 
                     
                       
                         1 
                         
                           P 
                           · 
                           Q 
                         
                       
                        
                       
                         
                           ∑ 
                           
                             i 
                             = 
                             1 
                           
                           P 
                         
                          
                         
                           
                             ∑ 
                             
                               j 
                               = 
                               1 
                             
                             Q 
                           
                            
                           
                             Y 
                              
                             
                               ( 
                               
                                 i 
                                 , 
                                 j 
                               
                               ) 
                             
                           
                         
                       
                     
                   
                   , 
                 
               
               
                 
                   ( 
                   7 
                   ) 
                 
               
             
           
         
       
     
         [0000]    P and Q are the height and width of the input image, respectively; Y is the luminance of the image; Analog_gain, Analog_gain_divider, Digital_gain, Digital_gain_divider, and Exposure_time are the exposure information of the input image. 
         [0028]    The second procedure in scene brightness control is to adjust the weight of the references based on the estimated scene brightness. The core issue in scene brightness control is to determine the weight function, i.e., weight=f(color temperature, slope). The slope of the weight function is also a function of scene brightness, i.e., slope=f(scene brightness). 
         [0029]    In one embodiment, there is a scene brightness control scheme. When scene brightness is greater than a threshold, for example 42.0, we disable color temperature references below a certain color temperature, for example, 4500K, by setting their weights to zero. This is equivalent to having two step functions for both the weight function and the slope function. One draw back of this strategy is that the transition of AWB gains are not smooth, leading to an occasional color shift for images whose scene brightness are close to the threshold. Another draw back is the step weight function could provide insufficient correction for some images, while over-correction for others. 
         [0030]    One embodiment uses linear functions to gradually reduce the weight of the color temperature references between T 2  (for example, 5000K) and T 1  (for example, 4000K) from 1 to 0, as shown in (8). The slope of the function is determined by the estimated scene brightness of the image, as shown in (9). 
         [0000]    
       
         
           
             
               
                 
                   Weight 
                   = 
                   
                     { 
                     
                       
                         
                           
                             1 
                             , 
                           
                         
                         
                           
                             
                               if 
                                
                               
                                   
                               
                                
                               color_temperature 
                             
                             &gt; 
                             
                               T 
                               2 
                             
                           
                         
                       
                       
                         
                           
                             0 
                             , 
                           
                         
                         
                           
                             
                               if 
                                
                               
                                   
                               
                                
                               colortemperature 
                             
                             &lt; 
                             
                               T 
                               1 
                             
                           
                         
                       
                       
                         
                           
                             
                               slope 
                               * 
                               
                                 ( 
                                 
                                   
                                     
                                       
                                         color_temperature 
                                         - 
                                       
                                     
                                   
                                   
                                     
                                       4000 
                                     
                                   
                                 
                                 ) 
                               
                             
                             , 
                           
                         
                         
                           else 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   8 
                   ) 
                 
               
             
             
               
                 
                   
                       
                   
                    
                   
                     Slope 
                     = 
                     
                       { 
                       
                         
                           
                             
                               0 
                               , 
                             
                           
                           
                             
                               
                                 if 
                                  
                                 
                                     
                                 
                                  
                                 Scene_Brightness 
                               
                               &lt; 
                               
                                 S 
                                  
                                 
                                     
                                 
                                  
                                 
                                   B 
                                   1 
                                 
                               
                             
                           
                         
                         
                           
                             
                               
                                 S 
                                 1 
                               
                               , 
                             
                           
                           
                             
                               
                                 if 
                                  
                                 
                                     
                                 
                                  
                                 S 
                                  
                                 
                                     
                                 
                                  
                                 
                                   B 
                                   2 
                                 
                               
                               &gt; 
                               Scene_Brightness 
                               ≥ 
                               
                                 S 
                                  
                                 
                                     
                                 
                                  
                                 
                                   B 
                                   1 
                                 
                               
                             
                           
                         
                         
                           
                             
                               
                                 S 
                                 2 
                               
                               , 
                             
                           
                           
                             
                               
                                 if 
                                  
                                 
                                     
                                 
                                  
                                 S 
                                  
                                 
                                     
                                 
                                  
                                 
                                   B 
                                   3 
                                 
                               
                               &gt; 
                               Scene_Brightness 
                               ≥ 
                               
                                 S 
                                  
                                 
                                     
                                 
                                  
                                 
                                   B 
                                   2 
                                 
                               
                             
                           
                         
                         
                           
                             
                               
                                 S 
                                 3 
                               
                               , 
                             
                           
                           
                             else 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   9 
                   ) 
                 
               
             
           
         
       
     
         [0000]    In our practice, 
         [0000]    
       
         
           
             
               
                 
                   S 
                   1 
                 
                 = 
                 
                   1 
                   
                     5000 
                     - 
                     4000 
                   
                 
               
               , 
               
                 
 
               
                
               
                 
                   S 
                   2 
                 
                 = 
                 
                   1 
                   
                     5000 
                     - 
                     4500 
                   
                 
               
               , 
               
                 
 
               
                
               and 
             
              
             
                 
             
           
         
       
       
         
           
             
                 
             
              
             
               
                 
                   S 
                   3 
                 
                 = 
                 
                   
                     
                       1 
                       
                         5000 
                         - 
                         4750 
                       
                     
                     · 
                     S 
                   
                    
                   
                       
                   
                    
                   
                     B 
                     1 
                   
                 
               
               , 
             
           
         
       
     
         [0000]    SB 2 , and SB 3  depend on the Auto-exposure algorithm and need to be tuned. The weight function and the slope function are illustrated in  FIG. 7(   a ) and  FIG. 7(   b ), respectively. 
         [0031]    To further improve the smoothness of scene brightness control, one could use a continuous function for the slope function, such as  FIG. 7(   c ). 
         [0032]    In the fourth step, correlation score for each reference is adjusted by applying the weight to each score, whereas the weight is determined by the scene brightness control. 
         [0033]    In the fifth step, the adjusted correlation score (Corr) is sorted, for example, in descending order; thus, the top N correlation scores are therefore, Corr(1), Corr(2), . . . and Corr(N). The top N candidates for color temperature estimation are the N color temperatures corresponding to Corr(1), Corr(2), . . . , and Corr(N). For example, N=3. Denote them as T 1 , T 2 , . . . and T N , respectively. 
         [0034]    In the sixth step, the color temperature estimation T final  is determined: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       T 
                       final 
                     
                     = 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         N 
                       
                        
                       
                         
                           α 
                           i 
                         
                         · 
                         
                           T 
                           i 
                         
                       
                     
                   
                   , 
                   
                     
 
                   
                    
                   where 
                 
               
               
                 
                   ( 
                   10 
                   ) 
                 
               
             
             
               
                 
                   
                     
                       α 
                       i 
                     
                     = 
                     
                       
                         Corr 
                          
                         
                           ( 
                           i 
                           ) 
                         
                       
                       
                         
                           ∑ 
                           
                             j 
                             = 
                             1 
                           
                           N 
                         
                          
                         
                           Corr 
                            
                           
                             ( 
                             j 
                             ) 
                           
                         
                       
                     
                   
                   , 
                   
                     
                       _ 
                        
                       i 
                     
                     = 
                     1 
                   
                   , 
                   2 
                   , 
                   … 
                    
                   
                       
                   
                   , 
                   N 
                 
               
               
                 
                   ( 
                   11 
                   ) 
                 
               
             
           
         
       
     
         [0035]    In the seventh step, white balance gain is estimated. The R, G, B gains for white balance correction are estimated, such that the AWB regions identified by the following steps are neutralized to gray. White balance gains are computed with the steps discussed herein, which may not occur in the same order. 
         [0036]    In step 7.1, the RED, GREEN, and BLUE values for each gray patch for the top N color temperature candidates are accumulated, T 1 , T 2 , . . . and T N , 
         [0037]    In step 7.2, the average of the AWB regions from the top N color temperature estimations weighted by their correlation scores is computed. This weighted average procedure improves the stability of color temperature estimation and the AWB performance for images with dominate object color. 
         [0000]    
       
         
           
             
               
                 
                   
                     sumR_all 
                     = 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         N 
                       
                        
                       
                         
                           α 
                           i 
                         
                         · 
                         
                           sumR 
                            
                           
                             ( 
                             
                               i 
                               , 
                               
                                 g 
                                 i 
                               
                             
                             ) 
                           
                         
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     sumG_all 
                     = 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         N 
                       
                        
                       
                         
                           α 
                           i 
                         
                         · 
                         
                           sumG 
                            
                           
                             ( 
                             
                               i 
                               , 
                               
                                 g 
                                 i 
                               
                             
                             ) 
                           
                         
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     sumB_all 
                     = 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         N 
                       
                        
                       
                         
                           α 
                           i 
                         
                         · 
                         
                           sumB 
                            
                           
                             ( 
                             
                               i 
                               , 
                               
                                 g 
                                 i 
                               
                             
                             ) 
                           
                         
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     where 
                     , 
                     
                       
 
                     
                      
                     
                       
                         α 
                         i 
                       
                        
                       
                           
                       
                        
                       is 
                        
                       
                           
                       
                        
                       defined 
                        
                       
                           
                       
                        
                       in 
                        
                       
                           
                       
                        
                       
                         ( 
                         11 
                         ) 
                       
                     
                     , 
                     
                       
                         and 
                          
                         
                             
                         
                          
                         i 
                       
                       = 
                       1 
                     
                     , 
                     2 
                     , 
                     … 
                      
                     
                         
                     
                     , 
                     N 
                   
                 
               
               
                 
                   ( 
                   12 
                   ) 
                 
               
             
           
         
       
     
         [0038]    In step 7.3, the final white balance gain adjustment for Red (R), Green (G), and Blue (B) channels are computed. The gains are designed such that sumR_all, sumG_all, and sumB_all will be equalized after the gain adjustment. There are many different ways to do so. For example, one implementation is to keep sumG_all unchanged, and adjust sumR_all and sumB_all to equal sumG_all. In another implementation, the maximum of sumR_all, sumG_all, and sumB_all is maintained, while the other two are adjusted to match the maximum. This implementation is shown below. It will guarantee that the minimum of R gain , G gain , and B gain  are no less than 1.0. 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       R 
                       gain 
                     
                     = 
                     
                       
                         max 
                          
                         
                           { 
                           
                             sumR_all 
                             , 
                             sumG_all 
                             , 
                             sumB_all 
                           
                           } 
                         
                       
                       sumR_all 
                     
                   
                    
                   
                       
                   
                    
                   
                     
                       B 
                       gain 
                     
                     = 
                     
                       
                         max 
                          
                         
                           { 
                           
                             sumR_all 
                             , 
                             sumG_all 
                             , 
                             sumB_all 
                           
                           } 
                         
                       
                       sumB_all 
                     
                   
                    
                   
                     
 
                   
                    
                   
                     
                       G 
                       gain 
                     
                     = 
                     
                       
                         
                           max 
                            
                           
                             { 
                             
                               sumR_all 
                               , 
                               sumG_all 
                               , 
                               sumB_all 
                             
                             } 
                           
                         
                         sumG_all 
                       
                       . 
                     
                   
                 
               
               
                 
                   ( 
                   13 
                   ) 
                 
               
             
           
         
       
     
         [0039]    For white balance correction, von Kries model may be utilized. The final output image may be obtained by individually scaling the R, G, B channels of the image with R gain , G gain , and B gain , respectively, as the following: 
         [0000]    
       
         
           
             
               
                 
                   
                     [ 
                     
                       
                         
                           
                             R 
                             adapt 
                           
                         
                       
                       
                         
                           
                             G 
                             adapt 
                           
                         
                       
                       
                         
                           
                             B 
                             adapt 
                           
                         
                       
                     
                     ] 
                   
                   = 
                   
                     
                       [ 
                       
                         
                           
                             
                               R 
                               gain 
                             
                           
                           
                             0 
                           
                           
                             0 
                           
                         
                         
                           
                             0 
                           
                           
                             
                               G 
                               gain 
                             
                           
                           
                             0 
                           
                         
                         
                           
                             0 
                           
                           
                             0 
                           
                           
                             
                               B 
                               gain 
                             
                           
                         
                       
                       ] 
                     
                      
                     
                       [ 
                       
                         
                           
                             
                               R 
                               input 
                             
                           
                         
                         
                           
                             
                               G 
                               input 
                             
                           
                         
                         
                           
                             
                               B 
                               input 
                             
                           
                         
                       
                       ] 
                     
                   
                 
               
               
                 
                   ( 
                   14 
                   ) 
                 
               
             
           
         
       
     
         [0040]    If Corr(1)==0, i.e., maximal correlation score is zero, gray world method [1] is used to estimate AWB gains. 
         [0041]    If Corr(1)&lt;Corr_Low_Threshold, color temperature estimation is determined based on the estimated scene brightness. 
         [0042]    If Corr(1)≠0 AND (sumR_all==0 OR sumG_all==0 OR sumB_all==0), i.e., AWB regions are not found, then use the R, G, B value associated with T 1 , T 2 , . . . , and T N  to compute the R, G, B gains, in a similar way as described in fifth step. 
         [0043]    The described method and apparatus for white balancing may include following advantages:
       (1) The concept of estimating color temperature by computing a correlation score. However, building a correlation matrix of all possible surface colors under all the different possible illuminants is a very complex process. Thus, this solution of using histograms of a color checker image taken under several controlled conditions to perform correlation has greatly simplifies the process. This idea is not seen in any prior arts.   (2) Improved performance for images with dominant object colors and images without gray.   (3) Good color temperature estimation robustness. Our solution reduces the number of images that fail to yield meaningful color temperature estimates and white balance gains.   (4) Good stability of color temperature estimation and white balance correction, i.e., with our solution, images taken consecutively with similar content will not have a sudden shift in color   (5) Minimized the work load for AWB tuning for a new sensor   (6) Computationally efficient. Our solution can be implemented in sensor hardware and run in real-time.       
 
         [0050]    Another embodiment comprises the following steps:
       1. Modified the flow of the algorithm to run two color temperature estimation algorithms in parallel.   2. Enhanced the scene brightness control module which is a sub-algorithm of the proposed AWB algorithm   3. Included a scheme to integrate the results from two color temperature estimation algorithms
 
A detailed method is described in  FIG. 6  and  FIG. 7 .
       
 
         [0054]      FIG. 4  is an embodiment of a flow diagram depicting the overall flow. In  FIG. 4 , the sensor calibration produces reference data. Color temperature estimation utilizes the reference data and an input image to perform the estimation. A white balance correlation is performed based on the color temperature estimation, thus producing an R_gain, G_gain and B_gain. 
         [0055]      FIG. 5  is an embodiment of block diagram for white balance calibration. In  FIG. 5 , the first step is to retrieve color checker reference shots in light box and outdoor conditions. Then, the R, G, B, Cb/Y and Cr/Y for the gray patch of the reference shot are determined and the histogram for the reference shots are generated. Lastly, the reference data files for AWB algorithm is generated. 
         [0056]    In this proposed AWB algorithm, color temperature estimation consists of two sub-algorithms. These two algorithms are running in parallel. Their results are merged at the end of this process. Algorithm 1 is Histogram Correlation. Algorithm 2 is Gray Reference Scoring, which is developed based on the scoring algorithm. 
         [0057]    An embodiment of a modified Gray Reference Scoring algorithm, instead of using one gray reference point for each color temperature, we measured multiple gray references for each color temperature. For example, the standard Macbeth color checker, as shown in  FIG. 3(   b ), contains six neutral patches with different shades of gray, numbered 1 to 6 from left to right. We obtain four gray references from the color checker—patches 2, 3, 4, and 5—for each color temperature. We recommend not using patch 1 to avoid saturation issue, and not using patch 6 to avoid relatively large quantization errors. 
         [0058]    The advantages of using multiple gray references over one gray reference for each color temperature:
   (a) We find that different level of intensity of the light shifts the gray references on the chromaticity plane. This effect can also be represented by different shades of gray references taken under the same illumination.
       As a result of this effect, using one shade of gray for each color temperature is not sufficient to represent the different shades of gray and the different levels of intensity of the illuminant. Multiple gray references for each color temperature solve this problem.   
       (b) Furthermore, by using multiple gray references, we can reduce the radius of the circle for each reference while covering as much gray regions as possible. By reducing the radius, we reduced the amount of faulty color in the gray region, and hence increased the accuracy of white balance correction.   
 
         [0062]    The Histogram Correlation algorithm and the Gray Reference Scoring algorithm generate a score for each color temperature reference. The final color temperature estimation, i.e., Color_Temp_Estim — 1 and Color_Temp_Estim — 2 in  FIG. 6 , from each algorithm is determined in the same way, shown in (15) and (16). 
         [0063]    Let Sorted_T 1 , i=1,2, . . . ,N be the color temperature of the references sorted in descending order of the correlation scores or gray reference scores, where N is the number of references. The final color temperature estimation T final  is: 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       T 
                       final 
                     
                     = 
                     
                       
                         ∑ 
                         
                           i 
                           = 
                           1 
                         
                         P 
                       
                        
                       
                         
                           α 
                           i 
                         
                         · 
                         
                           Sorted_T 
                           i 
                         
                       
                     
                   
                    
                   
                     
 
                   
                    
                   
                     where 
                     , 
                   
                 
               
               
                 
                   ( 
                   15 
                   ) 
                 
               
             
             
               
                 
                   
                     
                       α 
                       i 
                     
                     = 
                     
                       
                         Sorted_Score 
                          
                         
                           ( 
                           
                             i 
                             , 
                             
                               g 
                               i 
                             
                           
                           ) 
                         
                       
                       
                         
                           ∑ 
                           
                             j 
                             = 
                             1 
                           
                           P 
                         
                          
                         
                           Sorted_Score 
                            
                           
                             ( 
                             
                               j 
                               , 
                               
                                 g 
                                 j 
                               
                             
                             ) 
                           
                         
                       
                     
                   
                   , 
                   
                     i 
                     = 
                     1 
                   
                   , 
                   2 
                   , 
                   … 
                    
                   
                       
                   
                   , 
                   P 
                 
               
               
                 
                   ( 
                   16 
                   ) 
                 
               
             
           
         
       
     
         [0000]    In our practice, P=3. 
         [0064]    The advantage of using a soft decision on color temperature estimation instead of a hard decision, i.e., P=1, is the improved stability. Stability is one of the most challenging problems facing white balance algorithms. When pictures of similar scenes are taken, the color of the images may shift because of a non-smooth change of the white balance gains. This is caused by the change of the location of the maximal score due to the change of the image content. The soft decision, however, will produce much more stable white balance gains, hence reducing the color shift to a great extend. 
         [0065]    In case there are multiple peaks in the scores, hard decision could result in a much more dramatic shift of the color of the output images. A soft decision makes the transition of white balance gains much smoother. 
         [0066]    From the two color temperature estimation algorithms, we obtain two set of AWB results, φ{T,Gains} 1  from the Histogram Correlation algorithm and φ{T,Gains} 2  from the Gray Reference Scoring algorithm. We have tried two methods to integrate the two sets of results. Method 2 produces more stability white balance results. 
       Method 1: 
       [0067]    
       
         
           
             
               
                 
                   
                     φ 
                      
                     
                       
                         { 
                         
                           T 
                           , 
                           Gains 
                         
                         } 
                       
                       final 
                     
                   
                   = 
                   
                     { 
                     
                       
                         
                           
                             
                               φ 
                                
                               
                                 
                                   { 
                                   
                                     T 
                                     , 
                                     Gains 
                                   
                                   } 
                                 
                                 2 
                               
                             
                             , 
                           
                         
                         
                           
                             
                               if 
                                
                               
                                   
                               
                                
                               max_score 
                                
                               _ 
                                
                               2 
                             
                             &gt; 
                             Th 
                           
                         
                       
                       
                         
                           
                             
                               φ 
                                
                               
                                 
                                   { 
                                   
                                     T 
                                     , 
                                     Gains 
                                   
                                   } 
                                 
                                 1 
                               
                             
                             , 
                           
                         
                         
                           else 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   17 
                   ) 
                 
               
             
           
         
       
       
         
           
             where max_score — 2 is the maximal score from the Gray Reference Scoring algorithm, and Th is a pre-defined threshold. 
           
         
       
     
       Method 2: 
       [0069]    
       
         
           
             
               
                 
                   
                     
                       
                         φ 
                          
                         
                           
                             { 
                             
                               T 
                               , 
                               Gains 
                             
                             } 
                           
                           final 
                         
                       
                       = 
                       
                         
                           
                             α 
                             · 
                             φ 
                           
                            
                           
                             
                               { 
                               
                                 T 
                                 , 
                                 Gains 
                               
                               } 
                             
                             2 
                           
                         
                         + 
                         
                           
                             β 
                             · 
                             φ 
                           
                            
                           
                             
                               { 
                               
                                 T 
                                 , 
                                 Gains 
                               
                               } 
                             
                             1 
                           
                         
                       
                     
                     , 
                     
                       
 
                     
                      
                     where 
                   
                    
                   
                     
 
                   
                    
                   
                     
                       α 
                       = 
                       
                         
                           max_score 
                            
                           _ 
                            
                           2 
                         
                         
                           total_num 
                            
                           _blocks 
                         
                       
                     
                     , 
                     
                       
 
                     
                      
                     
                       β 
                       = 
                       
                         
                           max_score 
                            
                           _ 
                            
                           1 
                         
                         1 
                       
                     
                     , 
                   
                 
               
               
                 
                   ( 
                   18 
                   ) 
                 
               
             
           
         
       
       
         
           
             max_score — 1 is the maximal score from the Histogram Correlation algorithm, and total_num_blocks is the total number of blocks or pixels in the input image. 
           
         
       
     
         [0071]    While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.