Abstract:
A fast gamma correction method for an image reading apparatus is proposed. The original intervals for normalized output data are combined to merged intervals fewer in number and the original color correction function is replaced by a fitting function in the merged intervals. For an input normalized data, the corresponding merged interval is found and a fitting function associated with the merged interval is invoked to find the corresponding normalized and corrected data.

Description:
FIELD OF THE INVENTION 
   The present invention relates to a fast gamma correction method for an image reading apparatus, especially to a fast gamma correction method for an image reading apparatus with less storage space. 
   BACKGROUND OF THE INVENTION 
   Image reading apparatuses such as scanners, digital still cameras and video cameras have become popular, as the Internet has become prevalent. The image reading apparatuses have different mechanisms and physical properties from image output apparatuses such as displays and printers. Therefore, the image data obtained from an image reading apparatus generally requires correction such as gamma correction to present a picture with fidelity. 
   Provided that X denotes input pixel data and Y denotes output pixel data, the Gamma correction can be expressed in the form Y=XY, or other empirical curve. The function representation is hard to realize by hardware, so a look-up table is often used to enhance processing speed. The size of the gamma correction table depends on the resolution (bit number) of the input pixel data and output pixel data. The gamma correction table requires 4K bytes of storage space for 12-bit input data and 8-bit output data. The gamma correction table requires 64K bytes of storage space for 16-bit input data and 8-bit output data, which is not feasible for an ordinary platform. 
   The applicability of the look-up table is also limited by data accessing speed. Page mode accessing is not useful due to the randomness of pixel data. The data accessing time is 120 ns for external 60 ns DRAM. 
   SUMMARY OF THE INVENTION 
   It is an object of the present invention to provide a gamma correction method for an image reading apparatus with less storage space. 
   It is an object of the present invention to provide a gamma correction method for an image reading apparatus with fast accessing speed. 
   To achieve the above objects, the gamma correction method for image reading apparatus according to the present invention comprises following steps:
         a. provided that the normalized output pixel data Y is quantified by n-bit, the original 2″ intervals is reduced to M merged interval, wherein M^2″, the original correction function is represent by an approximated function with simple function form in each merged interval;   b. reading normalized input pixel data X and allocating the read data to a merged interval;   c. finding the normalized output pixel data Y by approximated function in the merged interval and the normalized input pixel data X.       

   The various objects and advantages of the present invention will be more readily understood from the following detailed description when read in conjunction with the appended drawing, in which: 

   
     BRIEF DESCRIPTION OF DRAWING: 
       FIG. 1  is an example with liner fitting function segments for gamma correction function; 
       FIG. 2  demonstrates interval mergence in the present invention; 
       FIG. 3  shows a block diagram to realize the gamma correction method according to the present invention. 
   

   DETAILED DESCRIPTION OF THE INVENTION 
   The gamma correction function is a generally monotonic function, and therefore, a realistic gamma correction function can be approximated by a simple function such as linear function segments or polynomial functions over specific intervals. The gamma correction function has good approximation by prudently choosing the intervals. 
     FIG. 1  shows a first example of a gamma correction function approximated by a linear function segments, wherein X denotes a normalized input signal to be corrected and Y denotes the normalized output signal after correction. The normalized output signal Y is quantified to 2 bits for illustration. The threshold values of the Y coordinate are 0, 0.25, 0.5, 0.75, and 1. That is, the output between 0 and 0.25 is Y 0  ( code 00 ), the output between 0.25 and 0.5 is Y 1  (code 01), etc. The solid line in this FIGURE represents a realistic gamma correction function and the dashed line segments in this FIGURE represent an approximated gamma correction function. The threshold values of the X coordinate X T0 , X T1 , X T2 , X T3 , X T4  can be obtained by inversely mapping threshold values of the Y coordinate 0, 0.25, 0.5, 0.75, 1 with respect to the realistic gamma correction function. 
   In the example shown in  FIG. 1 , the related interval of the input pixel data X is determined with reference to the threshold values of X coordinate X T0 , X T1 , X T2 , X, X T4  and then an appropriate fitting function is used to obtain corresponding output pixel data Y. In the example shown in  FIG. 1 , two comparison steps are required if binary search is used. If the output pixel data Y is represented by n bits, n comparisons are required, which is time consuming. In the present invention, the 2″ intervals are merged to reduce search time. 
   The symbols used in the specification are list below for clarity:
         m: resolution of input data   n: resolution of output data   {Y 0 , Y 1 . . . Y 2   n   −1 }: symbolic set of output data   {X 0 , X 1 . . . X 2   m   −1 }: symbolic set of input data   {T 0 , T 1 . . . T 2   n }: output threshold set   Y=G(X): realistic color correction function   F (h,k) (.) fitting function in interval (T h , T k )   D(.): distortion measure function   Q(.): quantizer function   Provided T 0 =0, T 2   n =1, which are boundary values of output pixel data and the thresholds T 0 , T 1 . . . T 2   n  divide the range of normalized output data into 2 n intervals. The normalized output data can be obtained with reference to the thresholds Y j =(T j +T j+1 )/2, j=0, 1, 2,.2 n −1 and the quantization of normalized output data is executed by following formula:
 
 Q ( Y ) =Y   i ,
 
where 1 satisfies the condition:
 
 D ( Y−Y   i )=min{ D ( Y−Y   j )| Y   J   , j =0˜2 n −1}
       

   The input thresholds can also be obtained by the output thresholds:
 
 {G   −1 ( T   0 ),  G   −1 ( T   1 ) . . .  G   −1 ( T   2   n )}
 
   If the 2 n  intervals are not merged, the related interval of the input data is found and then the output signal is obtained by the function relationship Y=G(X). For example, for the input data G 1 (T j )&lt;X&lt;G−1(T j+1 ), the output signal corresponding to X is Y j . 
   The present invention is characterized in that the 2 n  intervals of the output data are merged into a plurality of merged intervals, and the color correction function in each merged interval can be approximated by a suitable fitting function. For example, if the intervals between T h  to T k  are combined to a merged interval and the color correction function in the merged interval is approximated by a fitting function F (h:k )(.), which is a simple function such as a linear function or exponential function. 
     FIG. 2  demonstrates interval mergence in the present invention, wherein the fitting function F( h,k ) is an approximately linear function represented by a dashed line and the realistic color correction function is represented by solid line. In this example, m=3 and n=2, and there are four intervals for the output data. When one tries to combine interval (T 2 , T 3 ) and (T 3 ,T 4 ), and approximates the color correction function in the merged interval by a fitting function F (2;4 )(.), the quantized input data X4 has a contradiction because Q(F (2,4)  (X4))=Y 2  and Q(G (X 4 ))=Y 3 . Therefore, the intervals (T 2 , T 3 ) and (T 3 ,T 4 ) cannot be combined. On the contrary, the combination of intervals (T 0 , T 1 ) and (T 1 ,T 2 ) is safe. Therefore, the intervals (T 0 , T 1 ) and (T 1 ,T 2 ) can be combined into a merged (T 0 , T 2 ), and the color correction function in the merged interval is approximated by a fitting function F (0,2 )(.). 
   Hereinafter is the merging algorithm for intervals
         step 0: set k=0;   step 1: set h=k;   step 2: set k=k+1;   step 3: if k=2 n , stop;   step 4: if s is within (h,k), and all X T , T=0..2 m −1, in (G −1 (T s ), G −1 (T s+1 )), are equal to all X T , T=0 . . . 2 m −1 in (F −1   (h,k) (T s ), F −1   (h,k) (T s+1 )), back to step  2 ;   step 5: merging (T h , T h+1 )˜(T k−i , T k ) into (T h , T k ), and recoding F (h,k) (.);   step 6: back to step 1.       

   As can be seen from above algorithm, the criterion to validate the merged interval is to check the consistency between the input data obtained by inverse mapping all output data in the merged interval by the realistic color correction function and the input data obtained by inverse mapping all output data in the merged interval by the fitting function. If the validation is positive, the mergence is allowable and the next interval to the merged interval is tested for further mergence. 
     FIG. 3  shows a block diagram to realize the gamma correction method according to the present invention, wherein X denotes the normalized data to be corrected and Y denotes the normalized data after correction. The block diagram comprises a searching unit  102 , a storage unit  104  and a curve fitting and output mapping unit  106 . The searching unit  102  is used to find the related interval for the normalized input data X. The storage unit  104  is used to store the merged interval (X j , X j+1 ), j=0. . . M−1. The curve fitting and output mapping unit  106  is used to generate a fitting function corresponding to a related interval and then maps the input data to a corresponding corrected output data. For an input normalized data X to be corrected, the searching unit  102  compares the input normalized data X with thresholds in the storage unit  104  and finds a related interval for the input normalized data X. The curve fitting and output mapping unit  106  generates a fitting function corresponding to the related interval and then maps the input data to a corresponding corrected output data. Although the present invention has been described with reference to the preferred embodiment thereof, it will be understood that the invention is not limited to the details thereof. Various substitutions and modifications have suggested in the foregoing description, and other will occur to those of ordinary skill in the art. Therefore, all such substitutions and modifications are intended to be embraced within the scope of the invention as defined in the appended claims.