Abstract:
A compensation method for alleviating color shading in a digital image is adapted to correct a color shading phenomenon in a digital image that causes luminance differences between regions in the digital image. The compensation method includes capturing a uniform color block image; calculating horizontal compensation coefficients of a plurality of horizontal segments of the color block image; performing a linear interpolation process on the horizontal compensation coefficients to generate corresponding horizontal interpolation coefficients, and calculating determination horizontal correction coefficients corresponding to all the horizontal segments, respectively; calculating vertical compensation coefficients of a plurality of vertical segments; multiplying the determination horizontal correction coefficients by the vertical compensation coefficients, respectively, so as to obtain a color shading compensation coefficient of each segment, respectively; and multiplying an average luminance value of each segment by a corresponding color shading compensation coefficient, respectively, thus compensating for color shading in the color block image.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
     This non-provisional application claims priority under 35 U.S.C. §119(a) on Patent Application No(s). 098104733 filed in Taiwan, R.O.C. on Feb. 13, 2008 the entire contents of which are hereby incorporated by reference. 
     BACKGROUND OF THE INVENTION 
     1. Field of Invention 
     The present invention relates to an image processing technology, and more particularly to a compensation method for alleviating color shading in a digital image. 
     2. Related Art 
     When a conventional digital camera is used to capture a digital image, the digital camera resolves the reflected light into light of three primary colors, i.e., red (R), green (G) and blue (B), guides the light of the three primary colors to a photoelectric converter such as a charge-coupled device (CCD) for conversion into an analog signal of the light of the three primary colors. The analog signal of the light of the three primary colors is converted into a digital signal by an analog-to-digital converter and then output. 
     When a digital image of a uniform color block is captured in a uniform luminance environment by using the above digital camera, it is often found that edges of the digital image are darker than the center of the digital image, which is called a color shading phenomenon. This phenomenon is mainly due to the energy attenuation caused by the light refraction. The light is refracted by a lens such that an image is presented on the CCD. The light passing through edges of the lens is refracted at a larger angle than that passing through the center of the lens, so the energy attenuation of the light at the edges is greater than that at the center. As a result, the edges of the digital image are relatively dark, and thus color shading occurs. 
     In order to solve the color shading problem, a method is proposed in the prior art. In this method, an image of a uniform color block is captured in a uniform luminance environment. Then, the image is cut into, for example, M*N segments. An average luminance value of each segment is calculated, and the segment having the largest average luminance value is found from the segments. An average pixel value of the segment is used as a theoretical average luminance value of the entire image without light attenuation, and attenuation rates of other segments can be calculated according to the largest average luminance value and the average luminance values of the other segments. A Compensation coefficient corresponding to each segment can be respectively obtained by dividing the largest average pixel value by an average pixel value of each segment. As such, the energy attenuation caused by color shading can be compensated by multiplying pixels of the captured image by this set of compensation coefficients. 
     The above method can solve the color shading problem; however, as the compensation coefficients of the M*N segments of the image constitute a curvilinear function, and the memory of an image capturing device such as a camera is limited at present, a long time is required for satisfying the requirements of the curvilinear function. 
     In order to save the memory consumed for solving the color shading problem, a new method is further proposed. In this method, firstly, an image of a uniform color block is captured in a uniform luminance environment. Then, the image is cut into M segments in a horizontal direction, a segment having the largest average luminance value is found from the segments, and an average luminance value of the segment having the largest average pixel value is used as a theoretical horizontal average pixel value of the entire image without light attenuation. A plurality of horizontal compensation coefficients that is actually required can be obtained by dividing the largest average luminance value by average luminance values of respective segments. However, in order to reduce the required memory, the compensation coefficient of the segment closest to edges of the uniform color block can be set to a reference coefficient, and the segment having the largest average pixel value is linearly interpolated by using the reference coefficient to obtain a plurality of difference coefficients. The reference coefficient and the difference coefficients constitute a linear function, which can replace the original curve constituted by the horizontal compensation coefficients. Then, the image is cut into N segments in a vertical direction. A segment having the largest average luminance value is found from the segments, and the average luminance value of the segment is used as a theoretical vertical average luminance value of the entire image without light attenuation. A compensation coefficient can be obtained by dividing the largest average pixel value by an average pixel value of each segment. Compensation coefficients of the entire image can be obtained by multiplying the horizontal compensation coefficients by the vertical compensation coefficients. As such, the energy attenuation can be compensated by multiplying pixels of the captured image by this set of compensation coefficients. 
     The above method can effectively save the memory required for color shading compensation; however, as the energy attenuation in the horizontal direction does not change linearly, but the attenuation rate becomes higher towards the edge, overcompensation may occur if the original horizontal compensation curve is replaced by a linear function. 
     Therefore, currently, there is a need to provide a new image process technology so as to solve the problem in the prior art. 
     SUMMARY OF THE INVENTION 
     Accordingly, the present invention is a compensation method for alleviating color shading in a digital image, so as to reduce color shading in a digital image. 
     The present invention is a compensation method for alleviating color shading in a digital image, so as to reduce color shading in a digital image while saving the memory. 
     The present invention is a compensation method for alleviating color shading in a digital image, so as to accurately compensate for color shading in a digital image and avoid overcompensation. 
     In order to achieve the foregoing and other objectives, the compensation method for alleviating color shading in a digital image of the present invention is adapted to correct a color shading phenomenon in a digital image that causes luminance differences between regions in the digital image. The compensation method comprises: providing a uniform color block, and capturing a color block image of the color block; cutting the color block image into a plurality of horizontal segments in a horizontal direction, and calculating horizontal compensation coefficients corresponding to the horizontal segments, respectively; performing an interpolation process to linearly interpolate the horizontal compensation coefficients, so as to generate a plurality of horizontal interpolation coefficients; finding out corresponding horizontal compensation coefficients of the same horizontal segments according to the horizontal interpolation coefficients, and dividing the horizontal interpolation coefficients by the corresponding horizontal compensation coefficients to obtain a plurality of horizontal correction coefficients; multiplying the horizontal correction coefficients by corresponding horizontal interpolation coefficients, respectively, so as to obtain a plurality of determination horizontal correction coefficients, and obtaining determination horizontal correction coefficients corresponding to all the horizontal segments, respectively, by linearly interpolating any two adjacent determination horizontal correction coefficients; cutting the color block image into a plurality of vertical segments in a vertical direction, and calculating vertical compensation coefficients corresponding to the vertical segments, respectively; multiplying the determination horizontal correction coefficients by the vertical compensation coefficients, respectively, so as to obtain a color shading compensation coefficient of each segment of the color block image, respectively; and multiplying an average luminance value of each segment of the color block image by a corresponding color shading compensation coefficient, respectively, thus compensating for color shading in the color block image. 
     According to the compensation method for alleviating color shading in a digital image of the present invention, the color shading in the digital image can be compensated according to the color shading compensation coefficients finally obtained, such that the energy attenuation of the light at the edges of the digital image is reduced. 
     Here, the color block image comprises green pixels, red pixels, and blue pixels. 
     In addition, the step of calculating the horizontal compensation coefficients corresponding to the horizontal segments, respectively, may comprise: calculating a horizontal average luminance value corresponding to each horizontal segment; selecting a largest average luminance value from the horizontal average luminance values corresponding to the horizontal segments, and defining the largest average luminance value as a horizontal reference luminance value; and dividing the horizontal reference luminance value by the horizontal average luminance values, so as to generate the horizontal compensation coefficients. 
     Moreover, the step of calculating the vertical compensation coefficients corresponding to the vertical segments, respectively, may comprise: calculating a vertical average luminance value corresponding to each vertical segment; selecting a largest average luminance value from the vertical average luminance values corresponding to the vertical segments, and defining the largest average luminance value as a vertical reference luminance value; and dividing the vertical reference luminance value by the vertical average luminance values, so as to generate the vertical compensation coefficients. 
     As the color shading phenomenon is characterized by the luminance attenuation from the center to the edges of the color block image, the step of calculating the horizontal interpolation coefficients mainly comprises calculating two symmetrical linear line segments, and the calculation of one of the two line segments is described below. The step of calculating the horizontal interpolation coefficients may comprise: using a horizontal compensation coefficient of a horizontal segment closest to edges of the color block image as a reference coefficient; and performing an interpolation from the reference coefficient serving as a starting value towards the horizontal compensation coefficient of the horizontal segment having the largest horizontal average luminance value every a plurality of horizontal segments, so as to obtain a plurality of difference coefficients. Therefore, horizontal interpolation coefficients of a linear line segment may comprise a reference coefficient and a plurality of difference coefficients. 
     The determination horizontal correction coefficients overlap with a portion of the horizontal compensation coefficients in fact, and the determination horizontal correction coefficients can be connected into a plurality of linear line segments, so the determination horizontal correction coefficients of other horizontal segments can be obtained by linearly interpolating any two adjacent determination horizontal correction coefficients. 
     In the prior art, the color block image is cut into M*N segments, and corresponding compensation coefficients of the segments are calculated, respectively, resulting in that a large amount of memory is consumed. In the compensation method for alleviating color shading in a digital image of the present invention, the plurality of determination horizontal interpolation coefficients are obtained by correcting the horizontal interpolation coefficients, and the determination horizontal interpolation coefficients of other horizontal segments are then obtained by interpolating the obtained determination horizontal interpolation coefficients. As most of the determination horizontal interpolation coefficients are obtained by linear interpolation, the present invention can save a significant amount of memory, as compared with the prior art. 
     Also, in the prior art, overcompensation is caused when the horizontal compensation coefficients are obtained by linear interpolation. In the compensation method for alleviating color shading in a digital image of the present invention, the plurality of determination horizontal interpolation coefficients are obtained by using the desirable horizontal compensation coefficients to correct the horizontal interpolation coefficients, and the linear line segments constituted by the determination horizontal interpolation coefficients fit the desirable horizontal compensation coefficient curve better than the single linear line segment in the prior art. Therefore, as compared with the prior art, the present invention can accurately compensate for color shading in the color block image, and can thus avoid the overcompensation problem in the prior art. 
     As can be seen from the above description, the compensation method for alleviating color shading in a digital image of the present invention can solve the disadvantages of the prior art and can surely contribute to the development of the industry. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       The present invention will become more fully understood from the detailed description given herein below for illustration only, and thus are not limitative of the present invention, and wherein: 
         FIGS. 1A and 1B  are a flow chart according to an embodiment of the present invention; 
         FIG. 2  is a flow chart of the step of calculating horizontal compensation coefficients according to an embodiment of the present invention; 
         FIG. 3  is a flow chart of the step of calculating horizontal interpolation coefficients according to an embodiment of the present invention; 
         FIG. 4  is a flow chart of the step of calculating horizontal correction coefficients according to an embodiment of the present invention; and 
         FIG. 5  is a flow chart of the step of calculating vertical compensation coefficients according to an embodiment of the present invention. 
     
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The compensation method for alleviating color shading in a digital image according to the present invention is applicable to an electrical device having an image capturing function, and may be built in a storage device of the electronic device through software or firmware programs, and then realized by a processor of the electronic device by executing the built-in software or firmware programs in combination with the image capturing function. Here, the electronic device may be, but not limited to, a computer having the image capturing function, a mobile phone having the image capturing function, or a personal digital assistant (PDA) having the image capturing function. 
       FIGS. 1A and 1B  are a flow chart according to an embodiment of the present invention. The method of the present invention comprises the following steps. 
     In Step S 100 , a color block image of a uniform color block is captured by using one of the electronic devices. 
     In Step S 200 , the color block image is cut into m horizontal segments in a horizontal direction, and m horizontal compensation coefficients corresponding to the m horizontal segments are calculated. 
     In Step S 300 , an interpolation process is performed to linearly interpolate the m horizontal compensation coefficients, so as to generate k horizontal interpolation coefficients. 
     In Step S 400 , corresponding horizontal compensation coefficients of the same horizontal segments are found out according to the k horizontal interpolation coefficients, and the horizontal interpolation coefficients are divided by the corresponding horizontal compensation coefficients to obtain a set of horizontal correction coefficients. 
     In Step S 500 , the horizontal correction coefficients are multiplied by corresponding horizontal interpolation coefficients, respectively, so as to obtain determination horizontal correction coefficients, and determination horizontal correction coefficients corresponding to all the horizontal segments are obtained, respectively, by linearly interpolating any two adjacent determination horizontal correction coefficients 
     In Step S 600 , the color block image is cut into n vertical segments in a vertical direction, and n vertical compensation coefficients corresponding to the n vertical segments are calculated. 
     In Step S 700 , the determination horizontal correction coefficients are multiplied by the n vertical compensation coefficients, respectively, so as to obtain a color shading compensation coefficient of each segment of the color block image, respectively. 
     In Step S 800 , an average luminance value of each segment of the color block image is multiplied by a corresponding color shading compensation coefficient, respectively, thus compensating for color shading in the color block image. 
     Here, the horizontal segments are {H 1 , H 2 , . . . , H i , . . . , H m−1 , H m }, and the horizontal compensation coefficients are {FH 1 , FH 2 , . . . , FH i , . . . , FH m−1 , FH m }, where m is the total number of the horizontal segments of the color block image, H i  is the i th  horizontal segment of the color block image, FH i  is the horizontal compensation coefficient of the i th  horizontal segment, and i is a positive integer. 
     In addition, the color block image may comprise green pixels, red pixels, and blue pixels. 
       FIG. 2  is a flow chart of the step of calculating horizontal compensation coefficients according to an embodiment of the present invention. Step S 200  may comprise the following implementation steps. 
     In Step S 210 , a horizontal average luminance value corresponding to each of the m horizontal segments is calculated. 
     In Step S 220 , a largest average luminance value is selected from the m horizontal average luminance values corresponding to the m horizontal segments, and defined as a horizontal reference luminance value. 
     In Step S 230 , the horizontal reference luminance value is divided by the m horizontal average luminance values, respectively, so as to generate the m horizontal compensation coefficients. 
     Here, the horizontal average luminance values corresponding to the horizontal segments may be calculated by using the following equation: 
     
       
         
           
             
               
                 H 
                 i 
               
               _ 
             
             = 
             
               
                 1 
                 p 
               
               ⁢ 
               
                 
                   ∑ 
                   
                     x 
                     = 
                     1 
                   
                   p 
                 
                 ⁢ 
                 
                     
                 
                 ⁢ 
                 
                   H 
                   
                     i 
                     ⁡ 
                     
                       ( 
                       x 
                       ) 
                     
                   
                 
               
             
           
         
       
     
     where
           H i           

     is the horizontal average luminance value of the i th  horizontal segment, p is the total pixel number of the i th  horizontal segment, x is the x th  pixel of the i th  horizontal segment,
         H i(x)          

     is the luminance value of the x th  pixel of the i th  horizontal segment, and i, p, and x are all positive integers. 
     In addition, the horizontal compensation coefficients may be calculated by using the following equation: 
     
       
         
           
             
               FH 
               i 
             
             = 
             
               
                 Max 
                 
                   H 
                   _ 
                 
               
               
                 
                   H 
                   i 
                 
                 _ 
               
             
           
         
       
     
     where
         FH i          

     is the horizontal compensation coefficient of the i th  horizontal segment,
           H i           

     is the horizontal average luminance value of the i th  horizontal segment,
         Max   H           

     is the horizontal reference luminance value, and i is a positive integer. 
     Moreover, the horizontal interpolation coefficients described in Step S 300  are {FI 1 , FI 2 , . . . , FI j , . . . , FI k−1 , FI k }, where FI j  is the j th  horizontal interpolation coefficient, j is a positive integer, and k is the total number of the horizontal interpolation coefficients. As the color shading phenomenon is characterized by the luminance attenuation from the center to the edges of the color block image, the step of calculating the horizontal interpolation coefficients mainly comprises calculating two symmetrical linear line segments, and the calculation of one of the two line segments is described below.  FIG. 3  is a flow chart of the step of calculating horizontal interpolation coefficients according to an embodiment of the present invention. The step of calculating the horizontal interpolation coefficients may comprise the following steps. 
     In Step S 310 , a horizontal compensation coefficient of a horizontal segment closest to the edges of the color block image is used as a reference coefficient. 
     In Step S 320 , an interpolation is performed from the reference coefficient serving as a starting value towards the horizontal compensation coefficient of the horizontal segment having the largest horizontal average luminance value every a plurality of horizontal segments. 
     In Step S 330 , a plurality of difference coefficients is obtained according to the interpolation results. 
     Therefore, horizontal interpolation coefficients of a linear line segment may comprise a reference coefficient and a plurality of difference coefficients. Equations for calculating FI j  are as follows: 
     
       
         
           
             
               
                 FI 
                 1 
               
               = 
               
                 FH 
                 1 
               
             
             , 
             
               
                 FI 
                 2 
               
               = 
               
                 
                   
                     FH 
                     
                       1 
                       + 
                       D 
                     
                   
                   - 
                   
                     FH 
                     1 
                   
                 
                 D 
               
             
             , 
             
               
 
             
             ⁢ 
             
               
                 FI 
                 3 
               
               = 
               
                 
                   
                     FH 
                     
                       1 
                       + 
                       
                         2 
                         ⁢ 
                         D 
                       
                     
                   
                   - 
                   
                     FH 
                     
                       1 
                       + 
                       D 
                     
                   
                 
                 D 
               
             
             , 
             
               
 
             
             ⁢ 
             
               
                 FI 
                 4 
               
               = 
               
                 
                   
                     FH 
                     
                       1 
                       + 
                       
                         3 
                         ⁢ 
                         D 
                       
                     
                   
                   - 
                   
                     FH 
                     
                       1 
                       + 
                       
                         2 
                         ⁢ 
                         D 
                       
                     
                   
                 
                 D 
               
             
             , 
             … 
             ⁢ 
             
                 
             
             , 
             
               
 
             
             ⁢ 
             
               
                 FI 
                 j 
               
               = 
               
                 
                   
                     
                       FH 
                       
                         1 
                         + 
                         
                           
                             ( 
                             
                               j 
                               - 
                               1 
                             
                             ) 
                           
                           ⁢ 
                           D 
                         
                       
                     
                     - 
                     
                       FH 
                       
                         1 
                         + 
                         
                           
                             ( 
                             
                               j 
                               - 
                               2 
                             
                             ) 
                           
                           ⁢ 
                           D 
                         
                       
                     
                   
                   D 
                 
                 ∘ 
               
             
           
         
       
     
     where D is a positive integer. 
       FIG. 4  is a flow chart of the step of calculating horizontal correction coefficients according to an embodiment of the present invention. For ease of illustration, it is assumed that among the m horizontal segments of the color block image, 32 horizontal segments are selected from each side of the image. Although 32 horizontal segments are described herein, the number of the segments may be adjusted as required. Step S 400  may comprise the following implementation steps. 
     In Step S 410 , 32 horizontal segments are selected among the m horizontal segments from each side of the color block image, respectively. 
     In Step S 420 , the horizontal interpolation coefficients corresponding to the selected 64 horizontal segments are corrected by using the horizontal compensation coefficients, so as to generate horizontal correction coefficients corresponding to the 64 horizontal segments. 
     Here, the selected 64 horizontal segments are {H 1 , H 2 , . . . , H 31 , H 32 , H m−31 , H m−30 , . . . , H m−1 , H m }, and the horizontal correction coefficients FC are {FC 1 , FC 2 , . . . , FC 31 , FC m−31 , FC m−30 , . . . , FC m−1 , FC m }, where {H 1 , H 2 , . . . , H 31 , H 32 } represents 32 horizontal segments selected among the m horizontal segments from one side of the color block image, and {H m−31 , H m−30 , . . . , H m−1 , H m } represents 32 horizontal segments selected among the m horizontal segments from the other side of the color block image. Equations for calculating the horizontal correction coefficient FC are as follows: 
     
       
         
           
             
               
                 FC 
                 1 
               
               = 
               
                 
                   FH 
                   1 
                 
                 
                   FI 
                   1 
                 
               
             
             , 
             
               
                 FC 
                 2 
               
               = 
               
                 
                   FH 
                   2 
                 
                 
                   
                     FI 
                     1 
                   
                   + 
                   
                     FI 
                     2 
                   
                 
               
             
             , 
             
               
                 FC 
                 3 
               
               = 
               
                 
                   FH 
                   3 
                 
                 
                   
                     FI 
                     1 
                   
                   + 
                   
                     2 
                     × 
                     
                       FI 
                       2 
                     
                   
                 
               
             
             , 
             … 
             ⁢ 
             
                 
             
             , 
             
               
                 FC 
                 
                   1 
                   + 
                   D 
                 
               
               = 
               
                 
                   FH 
                   
                     1 
                     + 
                     D 
                   
                 
                 
                   
                     FI 
                     1 
                   
                   + 
                   
                     D 
                     × 
                     
                       FI 
                       2 
                     
                   
                 
               
             
             , 
             
               
 
             
             ⁢ 
             
               
                 FC 
                 
                   1 
                   + 
                   D 
                   + 
                   1 
                 
               
               = 
               
                 
                   FH 
                   
                     1 
                     + 
                     D 
                     + 
                     1 
                   
                 
                 
                   
                     FI 
                     1 
                   
                   + 
                   
                     D 
                     × 
                     
                       FI 
                       2 
                     
                   
                   + 
                   
                     FI 
                     3 
                   
                 
               
             
             , 
             
               
                 FC 
                 
                   1 
                   + 
                   D 
                   + 
                   2 
                 
               
               = 
               
                 
                   FH 
                   
                     1 
                     + 
                     D 
                     + 
                     2 
                   
                 
                 
                   
                     FI 
                     1 
                   
                   + 
                   
                     D 
                     × 
                     
                       FI 
                       2 
                     
                   
                   + 
                   
                     2 
                     ⁢ 
                     
                       FI 
                       3 
                     
                   
                 
               
             
             , 
             … 
             ⁢ 
             
                 
             
             , 
             
               
 
             
             ⁢ 
             
               
                 FC 
                 
                   1 
                   + 
                   D 
                   + 
                   D 
                 
               
               = 
               
                 
                   FH 
                   
                     1 
                     + 
                     D 
                     + 
                     D 
                   
                 
                 
                   
                     FI 
                     1 
                   
                   + 
                   
                     D 
                     × 
                     
                       FI 
                       2 
                     
                   
                   + 
                   
                     D 
                     × 
                     
                       FI 
                       3 
                     
                   
                 
               
             
             , 
             
               … 
               ⁢ 
               
                   
               
               ∘ 
             
             , 
           
         
       
     
     where D is a positive integer. 
     Moreover, the vertical segments are {V 1 , V 2 , . . . , V j , . . . , V n−1 , V n }, and the vertical compensation coefficients are {FV 1 , FV 2 , . . . , FV j , . . . , FV n−1 , FV n }, where n is the total number of the vertical segments of the color block image, V j  the j th  vertical segment of the color block image, FV j  is the vertical compensation coefficient of the j th  vertical segment, and j is a positive integer. 
     In addition, the vertical compensation coefficients may be calculated by using the following equation: 
     
       
         
           
             
               FV 
               j 
             
             = 
             
               
                 Max 
                 
                   V 
                   _ 
                 
               
               
                 
                   V 
                   j 
                 
                 _ 
               
             
           
         
       
     
     where
         FV j          

     is the vertical compensation coefficient of the j th  vertical segment,
           V j           

     is the vertical average luminance value of the j th  vertical segment,
         Max   V           

     is the vertical reference luminance value, and j is a positive integer. 
     Moreover, the determination horizontal correction coefficients overlap with a portion of the horizontal compensation coefficients in fact, and the determination horizontal correction coefficients can be connected into a plurality of linear line segments, so the determination horizontal correction coefficients of other horizontal segments can be obtained by linearly interpolating any two adjacent determination horizontal correction coefficients. 
       FIG. 5  is a flow chart of the step of calculating vertical compensation coefficients according to an embodiment of the present invention. Step S 600  may comprise the following implementation steps. 
     In Step S 610 , a vertical average luminance value corresponding to each of the n vertical segments is calculated. 
     In Step S 620 , a largest average luminance value is selected from the n vertical average luminance values corresponding to the n vertical segments, and defined as a vertical reference luminance value. 
     In Step S 630 , the vertical reference luminance value is divided by the n vertical average luminance values, respectively, so as to generate the n vertical compensation coefficients. 
     Here, the vertical average luminance values corresponding to the vertical segments may be calculated by using the following equation: 
     
       
         
           
             
               
                 V 
                 j 
               
               _ 
             
             = 
             
               
                 1 
                 q 
               
               ⁢ 
               
                 
                   ∑ 
                   
                     y 
                     = 
                     1 
                   
                   q 
                 
                 ⁢ 
                 
                     
                 
                 ⁢ 
                 
                   V 
                   
                     j 
                     ⁡ 
                     
                       ( 
                       y 
                       ) 
                     
                   
                 
               
             
           
         
       
     
     where
           V j           

     is the vertical average luminance value of the j th  vertical segment, q is the total pixel number of the j th  vertical segment, y is the y th  pixel of the j th  vertical segment,
         V j(y)          

     is the luminance value of the j th  pixel of the j th  vertical segment, and j, q, and y are all positive integers. 
     In addition, the segments to be compensated for color shading in regions of the color block image described in Step S 700  are {H 1 V 1 , H 2 V 1 , . . . , H i V 1 , . . . , H m−1 V 1 , H m V 1 , H 1 V 2 , H 2 V 2 , . . . , H i V 2 , . . . , H m−1 V 2 , H m V 2 , . . . , H 1 V j , H 2 V j , . . . , H i V j , . . . , H m−1 V j , H m V j , . . . , H 1 V n , H 2 V n , . . . , H i V n , . . . , H m−1 V n , H m V n }, and the color shading compensation coefficients of the regions are {FH 1 V 1 , FH 2 V 1 , . . . , FH i V 1 , . . . , FH m−1 V 1 , FH m V 1 , FH 1 V 2 , FH 2 V 2 , . . . , FH i V 2 , . . . , FH m−1 V 2 , FH m V 2 , . . . , FH 1 V j , FH 2 V j , . . . , FH i V j , . . . , FH m−1 V j , FH m V j , . . . , FH 1 V n , FH 2 V n , . . . , FH i V n , . . . , FH m−1 V n , FH m V n }, where m is the total number of the horizontal segments of the color block image, n is the total number of the vertical segments of the color block image, H i V j  is the i th  horizontal and j th  vertical segment, FH i V j  is the color shading compensation coefficient of the i th  horizontal and j th  vertical segment, and m, n, i, and j are positive integers. 
     Equations for calculating the color shading compensation coefficients of the regions are as follows:
 
 FH   1   V   1   =FI   1   ×FV   1   ×FC   1   ,FH   2   V   1 =( FI   1   +FI   2 )× FV   1   ×FC   2 ,
 
 FH   3   V   1 =( FI   1 +2 ×FI   2 )× FV   1   ×FC   3   , . . . ,FH   1+D   V   1 =( FI   1   +D×FI   2 )× FV   1   ×FC   1+D ,
 
 FH   1+D+1   V   1 =( FI   1   +D×FI   2   +FI   3 )× FV   1   ×FC   1+D+1 , . . . ,
 
 FH   1   V   j   =FI   1   ×FV   j   ×FC   1   ,FH   2   V   j =( FI   1   +FI   2 )× FV   j   ×FC   2 ,
 
 FH   3   V   j =( FI   1 +2 ×FI   2 )× FV   j   ×FC   3   , . . . , FH   1+D   V   j =( FI   1   +D×FI   2 )× FV   j   ×FC   1+D ,
 
 FH   1+D+1   V   j =( FI   1   +D×FI   2   +FI   3 )× FV   j   ×FC   1+D+1 , . . . ,
 
     where D and j are positive integers. 
     As can be seen from the above description, the compensation method for alleviating color shading in a digital image of the present invention can solve the disadvantages of the prior art. As compared with the prior art, the present invention can save a significant amount of memory and accurately compensate for color shading in the color block image, and thus can avoid the overcompensation problem in the prior art.