Abstract:
Ever since the advent of histogram equalization algorithms (“HE”) for image enhancements, there has been numerous variants of HE been proposed to improve or overcome the problems of the traditional HE. One of the drawbacks of the traditional HE is that the amount of enhancement is not adjustable. This invention gives a simple and efficient method to generalize the traditional HE to become a variable histogram equalization (“VHE”) by a single parameter, Q. Q ranges from 0 to 1 such that when Q equals 0, there is no enhancement and when Q reaches 1, the enhancement of VHE becomes the same as that of traditional HE. Therefore, the amount of image enhancement can be controlled by changing the parameter Q to achieve better visually appealing image enhancements.

Description:
FIELD OF INVENTION 
       [0001]    The present invention relates to image processing, and, in particular, to digital processing, including histogram processing. 
       BACKGROUND 
       [0002]    Ever since the advent of histogram equalization (“HE”) algorithm for image enhancements, there has been numerous variants of HE been proposed to improve or overcome the problems of the traditional HE. One of the drawbacks of the traditional HE is that the amount of enhancement is not adjustable. It would be desirable to have an invention that provides a simple and efficient method to generalize the traditional HE to become a variable histogram equalization (“VHE”) by a single parameter Q ranges from 0 to 1 in a way when Q equals 0, there is no enhancement and when Q reaches 1, the enhancement of VHE becomes the same as that of traditional HE. Therefore the amount of image enhancement can be controlled by changing the parameter Q to achieve better visually appealing image enhancements. 
       SUMMARY OF THE INVENTION 
       [0003]    An object of the present invention is to provide a single designated parameter in the adjustment of an enhanced image. 
         [0004]    Another object of the present invention is to provide methods for adjusting color saturation of a digital image. 
         [0005]    Yet another object of the present invention is to provide methods for improving the dynamic range enhancement of variable histogram equalization by adding a gamma compensation stage. 
         [0006]    Still another object of the present invention is to provide methods for automatic searching of the optimal parameters for best visually appealing image/video enhancement. 
         [0007]    Briefly, the present invention discloses a method for calculating an enhanced image of a digital image wherein the digital image having a plurality of pixels each have a plurality of color components, comprising the steps of: generating a histogram for each color components of a digital image; summing the histograms to generate a combined histogram; calculating a modified histogram as a function of a designated parameter; generating a remapping curve as a function of the modified histogram by a cumulative distribution function; and calculating enhanced pixels for an enhanced image. 
         [0008]    An advantage of the present invention is that it provides a single designated parameter in the adjustment of an enhanced image. 
         [0009]    Another advantage of the present invention is that it provides methods for adjusting color saturation of a digital image. 
         [0010]    Yet another advantage of the present invention is that it provides methods for improving the dynamic range enhancement of variable histogram equalization by adding a gamma compensation stage. 
         [0011]    Still another advantage of the present invention is that it provides methods for automatic searching of the optimal parameters for best visually appealing image/video enhancement. 
     
    
     
       DESCRIPTION OF THE DRAWINGS 
         [0012]    The following are further descriptions of the invention with reference to figures and examples of their applications. 
           [0013]      FIG. 1  is a flowchart illustrating steps in calculating for variable histograms; 
           [0014]      FIG. 2  illustrates relationship between Q, Q1 and P based on a given ratio R; 
           [0015]      FIG. 3  is a flowchart illustrating steps in calculating for variable histograms and GCS; 
           [0016]      FIG. 4  is a flowchart illustrating steps in calculating automatic searching algorithm for gamma compensated variable histogram equalization; 
           [0017]      FIG. 5  illustrates an example of a monotonically increasing weight function; 
           [0018]      FIG. 6  illustrates an example of a monotonically decreasing weight function; 
           [0019]      FIG. 7  illustrates an example of a bell shape weight function; and 
           [0020]      FIG. 8  illustrates an example of a rectangular weight function. 
       
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     Part I: Variable Histogram Equalization for Image and Video Light Compensation 
       [0021]    One aspect of this invention is intended to enhance luminous and/or dynamic ranges and/or tonal range and/or contrast ratio and/or color saturation of under-exposed pictures/images and videos which may be captured at ill-lighting conditions or with scenes composed of strong contrast of bright and dark areas/objects, and is especially useful for digital still cameras, camera phones and video surveillances. 
         [0022]    Histogram Equalization (HE) is widely used as a means to enhance contrast of an image or video frames. However HE does not always produce the right amount of enhancement that viewers desired. Most often, HE stretch contrast too much that causes un-natural looking of the altered images. This invention intends to give a more regulated and adjustable enhancement through a single designated parameter, named Q. 
         [0023]    To facilitate the idea of adjusting the amount of the traditional HE enhancement, the traditional HE is generalized to become a variable HE (“VHE”).  FIG. 1  illustrates the general steps of an embodiment of the present invention. First, histograms are calculated by counting frequencies of each pixel&#39;s red, green and blue color intensities in an image or the luma component (of YCbCr) of a video frame. Then, these histograms are summed to produce a combined histogram. A proper normalization is done on this combined histogram to account for varying image or video frame sizes. Let&#39;s denote the said Histogram as function H(i), i=0 . . . 255 of gray levels, where i is the gray scale intensity level for 8-bit pixel depth images. For other number of bits depth image format, the range of i can be adjusted accordingly. For example, for a 12 bit pixel depth, the range of i is from 0 to 2 12 −1. A modified histogram (“MH”) is then calculated as: 
         [0024]    MH(i)=power(H(i), Q), where power function is to raise each H(i) to the power of Q, where Q is a fractional number between 0.0 and a constant C inclusive, i.e., 0.0&lt;=Q&lt;=C, where C is a positive number. In the normal case, C=1.0 
         [0025]    After the MH is calculated, then a cumulative distribution function (“CDF”) is applied to the MH(i), instead of the original histogram H(i), to generate a remapping curve denoted as RC(j). A proper rounding and normalization to the remapping curve RC(j) is done to ensure that it remaps to integers and within the range of 0 to 255 inclusive for an 8-bit pixel depth. In one embodiment, the cumulative distribution function can be as follows: 
         [0000]    
       
         
           
             
               
                 CDF 
                  
                 
                   ( 
                   j 
                   ) 
                 
               
                
               • 
                
               
                 
                   ∑ 
                   
                     i 
                     = 
                     0 
                   
                   j 
                 
                  
                 
                   MH 
                    
                   
                     ( 
                     i 
                     ) 
                   
                 
               
             
             , 
             
               0 
               ≤ 
               j 
               ≤ 
               255. 
             
           
         
       
     
         [0026]    The following equations (1) (or use equation 1P for video) and (2) summarize the operations to obtain the remapping curve RC(j): 
         [0000]        H ( i )=( HR ( i )+ HG ( i )+ HB ( i ))× k,  0≦i≦255, k&gt;0, for images  (1) 
         [0000]      or 
         [0000]        H ( i )= HY ( i )× k,  0≦i≦255, k&gt;0, for videos  (1P) 
         [0027]    where HR(i), HG(i) and HB(i) are histograms for red, green and blue color components (RGB), respectively, of pixels of an image, and HY(i) is the histogram of luminous component (YCbCr) of pixels of a video frame, and k is the normalization constant. 
         [0000]                RC        (   j   )       =     round        (     p   ×       ∑     i   =   0     j            H        (   i   )       Q         )         ,         0≦j≦255, 0≦Q≦C, C&gt;0  (2) 
         [0028]    where p is a normalization factor such that after rounding by the round( ) function, the range of RC(j) is in integers of [0, 255] for 8-bit depth images or videos. 
         [0029]    After the remapping curve RC is successfully obtained, the following procedures describe how to obtain the enhanced version of images and videos: 
         [0030]    For each pixel p in an image, let&#39;s use pr, pg and pb to represent the red, green and blue components of the pixel. The maximum of the three components is denoted by l=max(pr, pg, pb). Then the enhanced pixel p′ whose 3 components p′r, p′g and p′b are obtained by the following equations: 
         [0000]        l′=RC ( l ) 
         [0000]            f   =       l   ′     l             p′r=a   1   ×f×pr  for image RGB color space 
         [0000]    
       
      
       p′g=a 
       2 
       ×f×pg  
      
     
         [0000]    
       
      
       p′b=a 
       3 
       ×f×pb  
      
     
         [0000]    or, by equations: 
         [0000]            f   =       RC        (   py   )       py             p′y=a   1   ×RC ( py ) 
         [0000]        p′u=a   2   ×f×pu  for video YUV color space 
         [0000]    
       
      
       p′v=a 
       3 
       ×f×pv  
      
     
         [0031]    where the proportional coefficients a 1 , a 2 , a 3  are for tuning purpose. In most cases, they are all ones but they can be any numbers and also can be functions of the pixel&#39;s position and its RGB components. 
         [0032]    An optional procedure for adjusting color saturation can be added in the following way: 
         [0000]        l′=RC ( l ) 
         [0000]            f   =       l   ′     l             p′r=a×f×pr +(1− a )× RC ( pr ) 
         [0000]        p′g=a×f×pg +(1− a )× RC ( pg ) 
         [0000]        p′b=a×f×pb +(1− a )× RC ( pb ) 
         [0033]    where the parameter a is a fractional number between 0 and 1. When the parameter a is set to 1, it is for maximum color saturation and 0 for minimum color saturation, respectively. This parameter is used to adjust the enhancement of color saturation of RGB color format images. 
         [0034]    For videos, the procedure for adjusting color saturation is similarly done by the following equations: 
         [0000]            f   =       RC        (   py   )       py             p′y=RC ( py ) 
         [0000]        p′u =( a×f+ 1− a )× pu    
         [0000]        p′v =( a×f+ 1 −a )× pv    
         [0035]    where the parameter a is a fractional number between 0 and 1. When the parameter a is set to 1, it is for maximum color saturation and 0 for minimum color saturation, respectively. 
         [0036]    For videos, for each pixel p in a video frame, let&#39;s use py, pu and pv to represent the luma (Y), chroma Cb and Cr components of the pixel, respectively. Then the enhanced pixel p′ whose 3 components p′y, p′u and p′v are obtained by the following equations: 
         [0000]        p′y=a   1   ×RC ( py ) 
         [0000]    
       
      
       p′u=a 
       2 
       ×pu  
      
     
         [0000]    
       
      
       p′v=a 
       3 
       ×pv  
      
     
         [0037]    where the proportional coefficients a 1 , a 2 , a 3  are for tuning purpose. In some cases, they are all ones but they can be any numbers and also can be functions of the pixel&#39;s position and its YCbCr components. 
         [0038]    For other color space representations other than RGB and YCbCr, similar procedures can be derived from above equations. 
       Part II: Gamma Compensated Variable Histogram Equalization for Image and Video Light Compensation 
       [0039]    To further improve the dynamic range enhancement of VHE, a gamma compensation stage (“GCS”) may be combined to the output of VHE. Here, the issue of how to balance the compensation strengths between VHE and GCS to achieve optimally visually appealing image enhancement is addressed.  FIG. 3  illustrates the general steps of an embodiment of this present invention. 
         [0040]    The gamma operation operates on the remapping curve RC obtained from description of Part I. This is different from the usual sense of gamma operation which operates on pixels of an image. The output of this gamma operation is a modified remapping curve (“MRC”), which may be defined as follows: 
         [0000]        MRC ( i )=floor(power( RC ( i )/255 ,Q 1)*255), i=0 . . . 255, 
         [0041]    where the floor function rounds numbers to its nearest integer toward minus infinity, and Q1 is a fractional number between 0.0 and C, i.e., 0.0&lt;=Q1&lt;=C, where C is a positive number identical in value as defined in Part I, equation (2). 
         [0042]    This Modified Remapping Curve MRC may replace the original remapping curve RC in Part I to be used to produce the enhanced images as described above. 
         [0043]    In many cases, it is desirable to have a single adjusting parameter instead of two independent parameters Q and Q1 for adjusting image enhancement. Therefore, the following describe how to use a single parameter P to adjust both Q and Q1. 
         [0044]    Let&#39;s first find the medium MED of a Histogram H by the following equation: 
         [0000]    
       
         
           
             
               MED 
               = 
               
                 
                   
                     ∑ 
                     
                       i 
                       = 
                       0 
                     
                     255 
                   
                    
                   
                     i 
                     × 
                     
                       H 
                        
                       
                         ( 
                         i 
                         ) 
                       
                     
                   
                 
                 
                   
                     ∑ 
                     
                       i 
                       = 
                       0 
                     
                     255 
                   
                    
                   
                     H 
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                 
               
             
             , 
           
         
       
     
         [0045]    and then we first define a threshold th of a Histogram H: 
         [0000]    
       
         
           
             
               th 
               = 
               
                 
                   
                     ∑ 
                     
                       i 
                       = 
                       0 
                     
                     255 
                   
                    
                   
                     H 
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                 
                 
                   255 
                   * 
                   a 
                 
               
             
             , 
           
         
       
     
         [0046]    where a is a constant that we may set to 1.5 normally, but it can be adjusted according to different types of image contents. 
         [0047]    Then the tonal range (“TR”) of a histogram H is defined as 
         [0000]    
       
         
           
             
               
                 T 
                  
                 
                     
                 
                  
                 R 
               
               = 
               
                 
                   ∑ 
                   
                     i 
                     = 
                     0 
                   
                   255 
                 
                  
                 
                   F 
                    
                   
                     ( 
                     i 
                     ) 
                   
                 
               
             
             , 
             
               
 
             
              
             where 
           
         
       
       
         
           
             
               F 
                
               
                 ( 
                 i 
                 ) 
               
             
             = 
             
               { 
               
                 
                   
                     
                       1 
                       , 
                       
                         
                           H 
                            
                           
                             ( 
                             i 
                             ) 
                           
                         
                         ≥ 
                         th 
                       
                     
                   
                 
                 
                   
                     
                       0 
                       , 
                       
                         
                           H 
                            
                           
                             ( 
                             i 
                             ) 
                           
                         
                         &lt; 
                         th 
                       
                     
                   
                 
               
             
           
         
       
     
         [0048]    Then a ratio R is defined as 
         [0000]    
       
         
           
             
               R 
               = 
               
                 
                   
                     T 
                      
                     
                         
                     
                      
                     R 
                   
                   MED 
                 
                 × 
                 α 
               
             
             , 
           
         
       
     
         [0049]    where α=0.4 in our normal case but it can be changed according to types of image contents. 
         [0050]    After we have computed R, then we can use a single parameter P to obtain both Q and Q1 by the following equations: 
         [0000]        Q=a ×tan( b×P ) 
         [0000]        Q 1=1 −c ×log( R ×tan( d×P )+1)  (3) 
         [0051]    where a, b, c, d are constants. In normal cases, they are 0.4, 0.6, 0.4 and 0.75 respectively. However, they can be adjusted according to types of image contents. 
         [0052]    The parameter P for equation (3) is the main enhancement control that in the range of 0.0 to 2.0. The key point for equation (3) is that when P is increasing, Q should be monotonically increasing too but Q1 should be at the same time monotonically decreasing. The ratio R is to control how fast Q1 is to decrease. The higher the R, the faster the Q1 decreases. See  FIG. 2  for an example where R=0.8. 
       Part III: Automatic Searching Algorithm for Gamma Compensated Variable Histogram Equalization for Image and Video Light Compensation 
       [0053]    The automatic searching algorithm may be used to automatically find the optimal value of Q and Q1 (or P) for best visually appealing image/video enhancement. The basic idea is to iteratively updating Q and Q1 (or P) from initial values until a certain number of specific metrics, defined by weighted summations of the altered histogram (“AH”), against a set of criteria are met. The algorithm is derived from gamma compensated variable histogram equalization (Part II). In addition to the original functional units, it adds three more functional units: (1) a metric calculation unit (“MCU”) to generate a set of metrics based on the altered histogram which in term can be calculated by the MRC; (2) a decision making unit (“DMU”) that determines if the enhancements have been achieved or not based on the generated metrics from MCU and to compare the metrics against a set of empirical rules; and (3) a parameter updating unit (“PUU”) to generate new values for parameters Q and Q1 for VHE and GCS, respectively, if DMU decides it needs to loop further. Please see  FIG. 4  for a flowchart of the processing steps. 
         [0054]    After CGS (as explained in Part II), a MRC is generated, and, based on this MRC an altered histogram is generated. AH can be generated through applying MRC to remap all the pixels in the image or video frame and then calculate the histogram again for this enhanced image or video. However a faster way to calculate AH without counting through all pixels is through the original histogram H(i) by: 
         [0000]        AH ( MRC ( i ))= AH ( MRC ( i ))+ H ( i ) 
         [0055]    for each i=0 to 255, in which each AH(i) was initially zeroed. 
         [0056]    AH serves as the foundation for giving information about how much enhancement is enough or not. This information is extracted through calculation of a set of metrics derived by weighted summations of AH through all luminance levels from 0 to 255. The weight functions (“WF”) can be of varies forms. A few of them are given here as examples. See  FIG. 5  through  FIG. 8   
         [0057]    Varies Metrics (M 1 , M 2 , M 3 , etc. . . . ) can be calculated by 
         [0000]    
       
         
           
             
               M 
               1 
             
             = 
             
               
                 ∑ 
                 
                   i 
                   = 
                   0 
                 
                 255 
               
                
               
                 ( 
                 
                   
                     
                       WF 
                       1 
                     
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                   × 
                   
                     AH 
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                 
                 ) 
               
             
           
         
       
       
         
           
             
               M 
               2 
             
             = 
             
               
                 ∑ 
                 
                   i 
                   = 
                   0 
                 
                 255 
               
                
               
                 ( 
                 
                   
                     
                       WF 
                       2 
                     
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                   × 
                   
                     AH 
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                 
                 ) 
               
             
           
         
       
       
         
           
             
               M 
               3 
             
             = 
             
               
                 ∑ 
                 
                   i 
                   = 
                   0 
                 
                 255 
               
                
               
                 ( 
                 
                   
                     
                       WF 
                       3 
                     
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                   × 
                   
                     AH 
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                 
                 ) 
               
             
           
         
       
     
         [0058]    etc. 
         [0059]    A set of thresholds has been empirically obtained by human inspections through a database of images and video clips with varying contents. These thresholds (Th 1 , Th 2 , Th 3 , etc . . . ) are compared against metrics M 1 , M 2 , M 3 , etc. A Decision Making Unit (“DMU”) is responsible to determine if the amount of enhancement is enough or not. DMU is essentially a set of rules that evaluates the truth table of comparisons of Metrics and Thresholds. The set of rules is empirically obtained through experiments and may depend on the characteristics of imaging sensors. 
         [0060]    An example of decision rules used by the DMU is as follows: 
         [0061]    If ((M 1 &gt;Th 1 ) And (M 2 &lt;Th 2 ) Then
       a. Looping_Done=YES       
 
         [0063]    ElseIf ((M 1 &gt;Th 1 ) And (M 3 &lt;Th 3 ) Then
       a. Looping_Done=YES       
 
         [0065]    ElseIf ((M 2 &gt;Th 2 ) And (M 1 &gt;Th 3 ) Then
       a. Looping_Done=YES       
 
         [0067]    ElseIf
       a. Looping_Done=NO       
 
         [0069]    The DMU gives a final answer of YES or NO depending upon the values of the metrics and the predefined thresholds. If the answer is YES, it means the desired amount of enhancement has been achieved and thus the loop is ended. The current MRC is used to remap each pixel&#39;s luminance level in the image or video frame into modified luminance level. The resulting image or video frame is properly enhanced. If the answer is NO, both parameters Q and Q1 need to be updated and the loop is going back and repeats again starting from VHE. 
         [0070]    The Parameter Updating Unit (“PUU”) is responsible to find new values for Q and Q1. A simple updating rule will be increment the value of Q and decrement the value of Q1 by a preset delta. Please refer to Part II for the formula for computing Q and Q1 from a single parameter P. If the formula is used, then updating single parameter P is sufficient. 
         [0071]    A more complex updating mechanism is used to predict the right increments of Q and decrements of Q1 in order to reduce the number of required iterations for achieving the desired amount enhancement. The updating rules are empirically obtained based on the differences of the paring Metrics and Thresholds. The rule of thumb is that if the differences are large, then increment the value of Q and decrement the value of Q1 by a larger amount of deltas, and vice-versa. 
         [0072]    While the present invention has been described with reference to certain preferred embodiments, it is to be understood that the present invention is not limited to such specific embodiments. Rather, it is the inventor&#39;s contention that the invention be understood and construed in its broadest meaning as reflected by the following claims. Thus, these claims are to be understood as incorporating not only the preferred embodiments described herein but all those other and further alterations and modifications as would be apparent to those of ordinary skilled in the art.