Abstract:
The present invention relates to a method for correcting a fragmentary or deformed quadrangular image. The method comprises five steps, i.e. detection of an edge point, elimination of an abnormal edge point, straight-line fitting, vertex calculation and image correction. The method for correcting a fragmentary or deformed quadrangular image is applied to a recognition method and a recognition system for papers, such as valuable documents, bills, identity cards, etc., and can rapidly conduct edge detection and tilt correction on images of valuable documents, bills or papers which are fragmentary or deformed.

Description:
CROSS REFERENCE OF RELATED APPLICATION 
       [0001]    This application claims the priority to Chinese Patent Application No. 201310733877.7, titled “METHOD FOR CORRECTING FRAGMENTARY OR DEFORMED QUADRANGULAR IMAGE” and filed with the Chinese State Intellectual Property Office on Dec. 25, 2013, which is incorporated herein by reference in its entirety. 
       FIELD 
       [0002]    The present disclosure relates to an identification technology for an image of valuable documents, bills or papers, and particularly to an edge detection and correction method for a quadrangular image of valuable documents such as banknote in financial field, bills such as car ticket, or papers such as identity card. 
       BACKGROUND 
       [0003]    Since tilt of position and deformation in moving typically occur for identification means for valuable documents, bills and papers during the process of placing them or high-speed movement, an image generated is often a tilted or deformed image. When a collected image is identified, firstly, an edge detection and a tilt correction are often performed on the collected image, and the content of the image after the tilt correction is further identified. Therefore, the edge detection and the tilt correction are important subjects in designing an identification system for valuable documents, bills or papers. 
         [0004]    In the process of edge detection and tilt correction, an image of valuable documents, bills or papers has the following characteristics. 
         [0005]    1. The shape is quadrangle, but four edges may often be fragmentary, and it is the edges with no fragmentary defects of the valuable documents, the bills or the papers that are required to be obtained. 
         [0006]    2. The identification means has high demands on identification time and storage space. For example, a common Deposit and withdrawal machine processes a valuable medium at a very fast speed. Many identification items, for example, valuable document type identification, valuable document prefix number identification, valuable document authenticity identification and valuable document sorting identification or the like, are contained in the processing of each valuable medium; therefore, the time period for the edge detection and the tilt correction has to be short. Moreover, since more valuable media are processed in a hardware platform such as an embedded platform, demanding requirements are also imposed on the storage space. 
         [0007]    3. The generated image of the valuable document is deformed due to factors such as inconsistent friction coefficients in a moving process of the identification apparatus; or the generated image of the papers has trapezoid deformation due to an angle problem in a process of scanning the papers. 
         [0008]    A common edge detection algorithm is the Hough Transform. The Hough Transform is to map the rectangular coordinate system to the polar coordinate system, for example, a straight line is represented as y=kx+b in the rectangular coordinate system, and is represented as r=x cos(θ)+y sin(θ) in the polar coordinate system, and any straight line in the rectangular coordinate system corresponds to a point in the polar coordinate system. When the edge detection is performed using Hough Transform, for the edge points in the image, corresponding points (r, θ) in the polar coordinate transform domain are calculated, the corresponding points in the transform domain are accumulated, and the maximally distributed points are obtained. Further, points on a straight line of an edge to be detected are further obtained, and points that are not on the edge are eliminated. Since one cosine calculation and one sine calculation are required to be performed on each point in the process of mapping, the calculation amount is large, and the calculation time is long since the calculation is floating-point calculation. 
         [0009]    Another common edge detection algorithm is the Canny edge detection. The Canny operator is an edge detection operator based on optimization algorithm, thereby having a good signal-noise ratio and good detection accuracy. Firstly, de-noising is performed on the image by using Gaussian filtering. Then, an amplitude value and a direction of the gradient are calculated by finite difference of first-order partial derivative. Next, a non-maximum suppression is applied on the amplitude value of the gradient. Finally, the edge is detected and joined by a double-threshold algorithm. The calculation amount is large, and the calculation time is long. 
         [0010]    Therefore, there is a need for a method that can perform edge detection and tilt correction on a fragmentary or deformed image of valuable documents, bills or papers quickly. 
       SUMMARY 
       [0011]    In order to solve the problem in the prior art that the calculation time of the edge detection algorithm is long, the present disclosure provides a method for performing quick edge detection and tilt correction on a fragmentary or deformed image of valuable documents, bills or papers. 
         [0012]    The method for correcting a fragmentary or deformed quadrangular image includes: step 1, edge point detection: where edge points are detected quickly using a grayscale value difference between an image region and a background region in a collected image, and an edge point detection is performed on each edge of the collected image in a X direction at equal intervals of ΔW based on a characteristic that the image of a valuable document is in a shape of quadrangle and the edges of the image are straight lines, a limited number of edge points are acquired and edge fitting is performed to obtain a straight line equation; step 2, abnormal edge point elimination: where abnormal points detected due to fragment, wrinkle or the like are eliminated so as to improve the accuracy of straight line fitting; statistics is performed on a slope distribution of the slopes of adjacent edge points based on a characteristic that a fragmentary edge part is smaller than a non-fragmentary edge part in the image of the valuable document, and a slope, the number of which is the largest in the slope distribution, is used as a slope of a straight line to be fitted, and edge points whose slope is not in the range of the largest slope are eliminated; step 3, straight line fitting: where a least-square fitting is performed on a point set of edge points obtained after the abnormal points are eliminated so as to obtain an edge straight line equation; step 4, vertex calculation: where fourth edge straight lines are obtained through the above three steps, and four vertexes of the quadrangle are obtained by solving intersection points of the straight lines; and step 5, image correction: where a correspondence between a point before correction and a corrected point is acquired based on a proportional relation in a bilinear space, and a tilt-corrected image of the image of the valuable document is obtained by grayscale interpolation. 
         [0013]    Specifically, the step 1 of detecting an upper edge point includes: 1.1, searching, from up to down, for the upper edge point on a straight line x=WIDTH/2, where the edge point obtained is PointsSet_Up[index 0 ]=(x_up_index 0 , y_up_index 0 ); 1.2, detecting an edge point on a straight line x=x_up_index 0 −ΔW, where a searching range of y is [y_up_index 0 −Δy, y_up_index 0 +Δy], and the edge point searched is PointsSet_Up[index −1 ]=(x_up_index −1 , y_up_index −1 ); 1.3, repeating the operation in 1.2 with PointsSet_Up[index −1 ] as an origin point, and performing the edge point detection until that no edge point is detected within a set searching range; 1.4, detecting an edge point on a straight line x=x_up_index 0 +ΔW, where a searching range of y is [y_up_index 0 −Δy, y_up_index 0 +Δy], and the edge point searched is PointsSet_Up[index 1 ]=(x_up_index 1 , y_up_index 1 ); 1.5, repeating the operation in 1.4 with PointsSet_Up[index 1 ] as an origin point, and performing the edge point detection until no edge point is detected in a set searching range; and 1.6, obtaining a point set of the detected upper edge points (PointsSet_Up[index −lm ], PointsSet_Up[index −lm+1 ], . . . PointsSet_Up[index −1 ], PointsSet_Up[index 0 ], PointsSet_Up[index 1 ], . . . PointsSet_Up[index rm−1 ], PointsSet_Up[index rm ]. 
         [0014]    Specifically, the step 2 of abnormal edge point elimination includes: 
         [0015]    2.1, slope calculation: where it is assumed that two adjacent upper edge points are PointsSet_Up[index n−1 ] and PointsSet_Up[index n ], and a slope of the two adjacent upper edge points is 
         [0000]              k   =           PointsSet_Up        [     index   n     ]       ·   y     -       PointsSet_Up        [     index     n   -   1       ]       ·   y             PointsSet_Up        [     index   n     ]       ·   x     -       PointsSet_Up        [     index     n   -   1       ]       ·   x           ,         since PointsSet_Up[index n   ].x −PointsSet_Up[index n−1   ].x=ΔW,  
 
         [0016]    therefore 
         [0000]    
       
         
           
             k 
             = 
             
               
                 
                   
                     PointsSet_Up 
                      
                     
                       [ 
                       
                         index 
                         n 
                       
                       ] 
                     
                   
                   · 
                   y 
                 
                 - 
                 
                   
                     PointsSet_Up 
                      
                     
                       [ 
                       
                         index 
                         
                           n 
                           - 
                           1 
                         
                       
                       ] 
                     
                   
                   · 
                   y 
                 
               
               
                 Δ 
                  
                 
                     
                 
                  
                 W 
               
             
           
         
       
     
         [0017]    since ΔW is a constant, k is represented by ks directly when determining the slope, 
         [0000]        ks =PointsSet_Up[index n   ].y −PointsSet_Up[index n−1   ].y,  
 
         [0000]    
       
      
       k˜=ks;  
      
     
         [0018]    2.2, slope distribution statistics: where the slope distribution statistics is performed by taking a quantitative standard being 1 as an example, angles of an upper edge, a lower edge, a left edge and a right edge are generally less than 90 degrees, and it is assumed that tilt angles of the four edges in the system should be less than θ; therefore, the slope ks calculated in 2.1 is an integer, a maximum value of the slope ks is represented as ks max , and a minimum value of the slope ks is represented as ks min , then, 
         [0000]    
       
         
           
             
               
                 k 
                 max 
               
               = 
               
                 
                   
                     ks 
                     max 
                   
                   
                     Δ 
                      
                     
                         
                     
                      
                     W 
                   
                 
                 = 
                 
                   tan 
                    
                   
                     ( 
                     θ 
                     ) 
                   
                 
               
             
             , 
             
               
 
             
              
             
               
                 
                   k 
                   min 
                 
                 = 
                 
                   
                     
                       ks 
                       min 
                     
                     
                       Δ 
                        
                       
                           
                       
                        
                       W 
                     
                   
                   = 
                   
                     
                       tan 
                        
                       
                         ( 
                         
                           - 
                           θ 
                         
                         ) 
                       
                     
                     = 
                     
                       - 
                       
                         tan 
                          
                         
                           ( 
                           θ 
                           ) 
                         
                       
                     
                   
                 
               
               ; 
             
           
         
       
     
         [0019]    therefore, 
         [0000]        ks   max =[tan(θ)*Δ W],  
 
         [0020]    ks min =−[tan(θ)*ΔW], where [ ] represents rounding; 
         [0021]    accumulative statistics is performed on the ks within a range of [−[tan(θ)*ΔW], [tan(θ)*ΔW]], and then ks, the number of which is the largest in the slope distribution, is obtained; and 
         [0022]    2.3, abnormal edge point elimination: 
         [0023]    where based on the ks calculated in 2.2, the number of which is the largest in the slope distribution, points corresponding to ks whose number is not the largest in the slope distribution, are eliminated from the point set of the edge points, and a point set of upper edge points obtained after the abnormal points are eliminated is defined as PointsSet_Up_New. 
         [0024]    Specifically, the step 3 of acquiring the edge straight line equation includes: assuming that an upper edge straight line equation to be solved is y=kx+b, the point set of upper edge points obtained after the abnormal points are eliminated is PointsSet_Up_New, X represents PointsSet_Up_New.x, Y represents PointsSet_Up_New.y, and n is the number of points in the PointsSet_Up_New, then 
         [0000]    
       
         
           
             
               k 
               = 
               
                 
                   
                     n 
                      
                     
                       ∑ 
                       XY 
                     
                   
                   - 
                   
                     ∑ 
                     
                       X 
                        
                       
                         ∑ 
                         Y 
                       
                     
                   
                 
                 
                   
                     n 
                      
                     
                       ∑ 
                       
                         X 
                         2 
                       
                     
                   
                   - 
                   
                     
                       ( 
                       
                         ∑ 
                         X 
                       
                       ) 
                     
                     2 
                   
                 
               
             
             , 
             
               
 
             
              
             
               
                 b 
                 = 
                 
                   
                     
                       ( 
                       
                         ∑ 
                         Y 
                       
                       ) 
                     
                     - 
                     
                       k 
                        
                       
                         ( 
                         
                           ∑ 
                           X 
                         
                         ) 
                       
                     
                   
                   n 
                 
               
               ; 
             
           
         
       
     
         [0025]    where edge straight line equations are obtained for the lower edge, the left edge and the right edge respectively in a similar way. 
         [0026]    Specifically, the step 5 of acquiring the correspondence between the point before being corrected and the corrected point comprises: performing X displacement and Y displacement on a point in an original image in a bilinear transformation space so as to obtain a corresponding point in the corrected image, where it is assumed that four vertexes A, B, C and D are obtained through the calculation in step 4, and the corresponding points after tilt-correction are A′, B′, C′ and D′ respectively, where calculating a correspondence between a point X′(x′, y′) in the tilt-corrected image and a corresponding point X(x, y) in the corresponding original image comprises: 
         [0027]    5.1, calculating the displacement in the y direction: 
         [0028]    where the displacement of a point X′ in the corrected image in the y direction is y′, similarly, each of a point E′ and a point F′ also has a displacement y′ in the y direction, and point X′, point E′ and point F′ correspond to a point X, a point E and a point F in the original image, respectively; 
         [0029]    coordinates of point E: 
         [0030]    where the displacement of point E′ in the y direction, i.e. the displacement of point E′ on straight line A′C′, corresponds to the movement of point E on straight line AC in the image before tilt correction, which is in proportion to the movement of point E′ on straight line A′C′; 
         [0000]    
       
         
           
             
               
                 x 
                 E 
               
               = 
               
                 
                   x 
                   A 
                 
                 + 
                 
                   
                     
                       
                         y 
                         
                           E 
                           ′ 
                         
                       
                       - 
                       
                         y 
                         
                           A 
                           ′ 
                         
                       
                     
                     
                       
                         y 
                         
                           C 
                           ′ 
                         
                       
                       - 
                       
                         y 
                         
                           A 
                           ′ 
                         
                       
                     
                   
                   · 
                   
                     ( 
                     
                       
                         x 
                         C 
                       
                       - 
                       
                         x 
                         A 
                       
                     
                     ) 
                   
                 
               
             
             , 
             
               
 
             
              
             
               
                 y 
                 E 
               
               = 
               
                 
                   y 
                   A 
                 
                 + 
                 
                   
                     
                       
                         y 
                         
                           E 
                           ′ 
                         
                       
                       - 
                       
                         y 
                         
                           A 
                           ′ 
                         
                       
                     
                     
                       
                         y 
                         
                           C 
                           ′ 
                         
                       
                       - 
                       
                         y 
                         
                           A 
                           ′ 
                         
                       
                     
                   
                   · 
                   
                     ( 
                     
                       
                         y 
                         C 
                       
                       - 
                       
                         y 
                         A 
                       
                     
                     ) 
                   
                 
               
             
           
         
       
     
         [0031]    i.e., [formula 1] 
         [0000]    
       
         
           
             
               x 
               E 
             
             = 
             
               
                 x 
                 A 
               
               + 
               
                 
                   
                     y 
                     ′ 
                   
                   Height 
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       C 
                     
                     - 
                     
                       x 
                       A 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               E 
             
             = 
             
               
                 y 
                 A 
               
               + 
               
                 
                   
                     y 
                     ′ 
                   
                   Height 
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       C 
                     
                     - 
                     
                       y 
                       A 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0032]    coordinates of point F: 
         [0033]    the displacement of point F′ in the y direction, i.e. the displacement of point F′ on straight line B′D′, corresponds to the movement of point F on straight line BD in the image before tilt correction, which is in proportion to the movement of point F′ on straight line B′D′, 
         [0000]    
       
         
           
             
               x 
               F 
             
             = 
             
               
                 x 
                 B 
               
               + 
               
                 
                   
                     
                       y 
                       
                         F 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         B 
                         ′ 
                       
                     
                   
                   
                     
                       y 
                       
                         D 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         B 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       D 
                     
                     - 
                     
                       x 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               F 
             
             = 
             
               
                 y 
                 B 
               
               + 
               
                 
                   
                     
                       y 
                       
                         F 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         B 
                         ′ 
                       
                     
                   
                   
                     
                       y 
                       
                         D 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         B 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       D 
                     
                     - 
                     
                       y 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0034]    since the corrected image is in a shape of quadrangle, 
         [0000]      y D′ =y C′ , y B′ =y A′ , y F′ =y E′ ; 
         [0035]    therefore, 
         [0000]    
       
         
           
             
               x 
               F 
             
             = 
             
               
                 x 
                 B 
               
               + 
               
                 
                   
                     
                       y 
                       
                         E 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         A 
                         ′ 
                       
                     
                   
                   
                     
                       y 
                       
                         C 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         A 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       D 
                     
                     - 
                     
                       x 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               F 
             
             = 
             
               
                 y 
                 B 
               
               + 
               
                 
                   
                     
                       y 
                       
                         E 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         A 
                         ′ 
                       
                     
                   
                   
                     
                       y 
                       
                         C 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         A 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       D 
                     
                     - 
                     
                       y 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0036]    i.e., [formula 2]: 
         [0000]    
       
         
           
             
               x 
               F 
             
             = 
             
               
                 x 
                 B 
               
               + 
               
                 
                   
                     y 
                     ′ 
                   
                   Height 
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       D 
                     
                     - 
                     
                       x 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               F 
             
             = 
             
               
                 y 
                 B 
               
               + 
               
                 
                   
                     y 
                     ′ 
                   
                   Height 
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       D 
                     
                     - 
                     
                       y 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0037]    5.2, displacement in the x direction: 
         [0038]    where the displacement of point X′ in the corrected image in the x direction is x′, and the movement of point X′ in the x direction, i.e., the movement of point X′ on straight line E′F′, is in proportion to the movement of point X on straight line EF, 
         [0039]    coordinates of point X are obtained based on the coordinates of point E and the coordinates of point F: 
         [0000]    
       
         
           
             
               x 
               X 
             
             = 
             
               
                 x 
                 E 
               
               + 
               
                 
                   
                     
                       x 
                       
                         X 
                         ′ 
                       
                     
                     - 
                     
                       x 
                       
                         E 
                         ′ 
                       
                     
                   
                   
                     
                       x 
                       
                         B 
                         ′ 
                       
                     
                     - 
                     
                       x 
                       
                         A 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       F 
                     
                     - 
                     
                       x 
                       E 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               X 
             
             = 
             
               
                 y 
                 E 
               
               + 
               
                 
                   
                     
                       x 
                       
                         X 
                         ′ 
                       
                     
                     - 
                     
                       x 
                       
                         E 
                         ′ 
                       
                     
                   
                   
                     
                       x 
                       
                         B 
                         ′ 
                       
                     
                     - 
                     
                       x 
                       
                         A 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       F 
                     
                     - 
                     
                       y 
                       E 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0040]    i.e., [formula 3]: 
         [0000]    
       
         
           
             
               x 
               X 
             
             = 
             
               
                 x 
                 E 
               
               + 
               
                 
                   
                     x 
                     ′ 
                   
                   Width 
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       F 
                     
                     - 
                     
                       x 
                       E 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               X 
             
             = 
             
               
                 y 
                 E 
               
               + 
               
                 
                   
                     x 
                     ′ 
                   
                   Width 
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       F 
                     
                     - 
                     
                       y 
                       E 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0041]    the correspondence between any one point (x′, y′) in the corrected image and the point (x, y) in the corresponding original image is obtained according to [formula 1], [formula 2] and [formula 3]. 
         [0042]    Specifically, when acquiring the correspondence between the point before being corrected and the corrected point in step 5, a corrected image of the whole image of the valuable document is obtained if the value of x′ is traversed from 0 to Width-1 and the value of y′ is traversed from 0 to Height-1, and a corrected image of a partial region of interest in the valuable document is obtained if the value of x′ is taken only from a part of values within a range of [0, Width] and/or the value of y′ is taken only from a part of values within a range of [0, Height]. 
         [0043]    Preferably, the grayscale interpolation algorithm in step 5 comprises Nearest Neighbor Interpolation, bilinear interpolation or high-order interpolation. 
         [0044]    The method for correcting a fragmentary or deformed quadrangular image according to the present disclosure is applied to an identification method and an identification system for valuable documents, bills or papers such as an identity card. In step 1 of the method for correcting the fragmentary or deformed quadrangular image, the edge point detection is performed quickly based on a difference between a background part and a foreground part in the collected image, thereby avoiding a complicated calculation caused by various gradient operators and reducing detection time for the edge points. Moreover, the edge point detection is performed in the image at equal intervals, thereby reducing the detection time for the edge points. In addition, since coordinates of adjacent edge points are close to each other, a next edge point can be detected using information on a previous adjacent edge point in a process of detecting the same edge, thereby narrowing a detection scope for the edge points and reducing the detection time for the edge points. A simplified calculation method is proposed to perform the slope calculation in step 2, a slope calculation with floating-point division calculation is converted into integer subtraction calculation, thereby reducing calculation complexity and reducing calculation time. Therefore, the method for correcting the fragmentary or deformed quadrangular image according to the present disclosure can perform the edge detection and the tilt correction quickly on the fragmentary or deformed image of valuable documents, bills or papers. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0045]      FIG. 1  is a flowchart of a method for correcting a fragmentary or deformed quadrangular image according to an embodiment of the present disclosure; 
           [0046]      FIG. 2  is a schematic diagram of an image of which the edge is fragmentary; 
           [0047]      FIG. 3  is a schematic diagram of a result of edge fitting without eliminating abnormal point; 
           [0048]      FIG. 4  is a schematic diagram of a result of edge fitting after abnormal point elimination; and 
           [0049]      FIG. 5  is a schematic mapping diagram of image tilt correction. 
       
    
    
     EXPLANATION OF PARAMETERS: 
       [0050]    WIDTH: width of the whole image 
         [0051]    HEIGHT: height of the whole image 
         [0052]    Width: width of image after tilt correction 
         [0053]    Height: height of image after tilt correction 
         [0054]    x: variable of image in a horizontal direction 
         [0055]    y: variable of image in a vertical direction 
         [0056]    point set of upper edge points PointsSet_Up 
         [0057]    point set of lower edge points PointsSet_Down 
         [0058]    point set of left edge points PointsSet_Left 
         [0059]    point set of right edge points PointsSet_Right 
         [0060]    upper edge straight line Line_Up 
         [0061]    lower edge straight line Line_Down 
         [0062]    left edge straight line Line_Left 
         [0063]    right edge straight line Line_Right 
         [0064]    ΔW: a step interval in the x direction when upper edge points and lower edge points are detected 
         [0065]    Δy: a floating range in the y direction when upper edge points and lower edge points are detected 
         [0066]    ΔH: a step interval in the y direction when left edge points and right edge points are detected 
         [0067]    Δx: a floating range in the x direction when left edge points and right edge points are detected 
       DETAILED DESCRIPTION 
       [0068]    In order to further describe the method for correcting the fragmentary or deformed quadrangular image according to the present disclosure, a detailed description will be given below in conjunction with a preferred embodiment of the present disclosure. 
         [0069]    With reference to  FIG. 1 , which is a flow diagram of a method for correcting a fragmentary or deformed quadrangular image, the method includes five steps, i.e. edge point detection, abnormal edge point elimination, straight line fitting, vertex calculation and image correction, which will be described below in detail step by step. 
         [0070]    Step 1: Edge Point Detection 
         [0071]    There is a difference between grayscale values of an image region and a background region in an imaging process of valuable documents, bills or papers. With this difference, edge points of each edge of the image region can be determined quickly, which is not in the background, thereby avoiding complicated calculation caused by various gradient operators and decreasing detection time for the edge points. 
         [0072]    In addition, since the valuable documents, the bills or the papers are of a quadrangle-like shape and the edges are straight lines, it is not required to detect all the edge points. Only a limited number of edge points are required to be detected for each edge, and then edge fitting can be performed to acquire a straight-line equation. Therefore, the edge point detection is performed on the image at equal intervals, thereby reducing the detection time for edge points. 
         [0073]    Furthermore, since coordinates of adjacent edge points are closed to each other, a next edge point can be detected using information on a previous adjacent edge point in a process of detecting the same edge, thereby narrowing a detection scope of edge points and reducing the time for detecting edge points. 
         [0074]    Specifically, in an example of detecting an upper edge point: 
         [0075]    (1) an upper edge point is searched for in a straight line x=WIDTH/2 from up to down, and the obtained edge point is PointsSet_Up[index 0 ]=(x_up_index 0 , y_up_index 0 ); 
         [0076]    (2) an edge point is detected in a straight line x=x_up_index 0 −ΔW, a searching range of y is [y_up_index 0 −Δy, y_up_index 0 +Δy], and a searched edge point is PointsSet_Up[index −1 ]=(x_up_index −1 , y_up_index −1 ); 
         [0077]    (3) the operation in (2) is repeated with PointsSet_Up[index −1 ] as an origin point so as to perform edge point detection until no edge point is detected within a set searching range; 
         [0078]    (4) an edge point is detected in a straight line x=x_up_index 0 +ΔW, a searching range of y is [y_up_index 0 −Δy, y_up_index 0 +Δy], and a searched edge point is PointsSet_Up[index 1 ]=(x_up_index 1 , y_up_index 1 ); 
         [0079]    (5) the operation in (4) is repeated with PointsSet_Up[index 1 ] as an origin point so as to perform edge point detection until no edge point is detected within a set searching range; 
         [0080]    (6) a point set of the detected upper edge points is (PointsSet_Up[index −lm ], PointsSet_Up[index −lm+1 ], . . . PointsSet_Up[index −1 ], PointsSet_Up[index 0 ], PointsSet_Up[index 1 ], . . . PointsSet_Up[index rm−1 ], PointsSet_Up[index rm ]. 
         [0081]    Step 2: Abnormal Edge Point Elimination 
         [0082]    The edge points detected in the image include fragmentary edge points due to fragment, wrinkle or the like in the valuable documents, the bills or the papers, as shown in  FIG. 2 . For this reason, not all the detected edge point sets are on one straight line, thus having an influence on fitting accuracy of subsequent edge straight lines. Therefore, before the fitting, the abnormal edge point elimination is performed. 
         [0083]    In the embodiment, based on a characteristic that a fragmentary edge part is smaller than a non-fragmentary edge part in the image of the valuable documents, the bills or the papers, statistics is performed on a slope distribution of slopes of adjacent edge points, and a slope, the number of which is the largest in the slope distribution, is taken as the slope of a straight line to be fitted, and edge points whose slopes are not in the range of the largest slope are eliminated. Herein, in particular, slope calculation and slope distribution statistics are simplified. 
         [0084]    Similarly, by taking the upper edge as an example, calculation is performed according to the following steps: 
         [0085]    (1) Slope Calculation 
         [0086]    In the edge point detection in step 1, the edge point detection is performed in the x direction at equal intervals of ΔW; assuming that two adjacent upper edge points are PointsSet_Up[index n−1 ] and PointsSet_Up[index n ], a slope of the two adjacent upper edge points 
         [0000]              k   =           PointsSet_Up        [     index   n     ]       ·   y     -       PointsSet_Up        [     index     n   -   1       ]       ·   y             PointsSet_Up        [     index   n     ]       ·   x     -       PointsSet_Up        [     index     n   -   1       ]       ·   x           ;         since PointsSet_Up[index n   ].x −PointsSet_Up[index n−1   ].x=ΔW,  
 
         [0000]    
       
         
           
             
               k 
               = 
               
                 
                   
                     
                       PointsSet_Up 
                        
                       
                         [ 
                         
                           index 
                           n 
                         
                         ] 
                       
                     
                     · 
                     y 
                   
                   - 
                   
                     
                       PointsSet_Up 
                        
                       
                         [ 
                         
                           index 
                           
                             n 
                             - 
                             1 
                           
                         
                         ] 
                       
                     
                     · 
                     y 
                   
                 
                 
                   Δ 
                    
                   
                       
                   
                    
                   W 
                 
               
             
             ; 
           
         
       
     
         [0087]    since ΔW is a constant, when estimating the slope, k is represented by ks directly, 
         [0000]        ks =PointsSet_Up[index n   ].y −PointsSet_Up[index n 1   ].y,  
 
         [0000]    
       
      
       k˜=ks  
      
     
         [0088]    In this way, a slope calculation with floating-point division calculation is simplified as integer subtraction calculation. 
         [0089]    (2) Slope Distribution Statistics 
         [0090]    A quantitative statistics is performed on slope distribution. In an actual application, the quantitative statistics for the slope can be designed based on accuracy of solving the slope; that is, the slope distribution statistics can be performed on a slope value with a quantitative standard being 1, or with a quantitative standard being 2. In a case where the quantitative standard is 2, the distributions of two adjacent slopes are combined and a accumulative statistics is performed. 
         [0091]    The slope distribution statistics is explained below by taking the quantitative standard being 1 as an example. 
         [0092]    Typically, angles of an upper edge, a lower edge, a left edge and a right edge are smaller than 90 degrees. Assuming that tilt angles of the four edges in the system should be smaller than θ, the slope ks calculated in the above step (1) is therefore an integer, a maximum value of ks is represented as ks max , and a minimum value of ks is represented as ks min , then: 
         [0000]    
       
         
           
             
               k 
               max 
             
             = 
             
               
                 
                   ks 
                   max 
                 
                 
                   Δ 
                    
                   
                       
                   
                    
                   W 
                 
               
               = 
               
                 tan 
                  
                 
                   ( 
                   θ 
                   ) 
                 
               
             
           
         
       
       
         
           
             
               k 
               min 
             
             = 
             
               
                 
                   ks 
                   min 
                 
                 
                   Δ 
                    
                   
                       
                   
                    
                   W 
                 
               
               = 
               
                 
                   tan 
                    
                   
                     ( 
                     
                       - 
                       θ 
                     
                     ) 
                   
                 
                 = 
                 
                   - 
                   
                     tan 
                      
                     
                       ( 
                       θ 
                       ) 
                     
                   
                 
               
             
           
         
       
     
         [0093]    therefore, 
         [0000]        ks   max =[tan(θ)*Δ W] 
 
         [0094]    ks min =−[tan(θ)*ΔW], where [ ] represents rounding, since ks is an integer; 
         [0095]    accumulative statistics is performed on the ks within a range of [−[tan(θ)*ΔW], [tan(θ)*ΔW]], and then ks, the number of which is the largest in the slope distribution, is obtained; 
         [0096]    (3) Abnormal Edge Point Elimination 
         [0097]    As described above, in a case where an edge of the image of the valuable documents, the bills or the papers is fragmentary or the like, an edge point detected in the fragmentary part is not on the same line as the real edge, and a slope of the edge point detected in the fragmentary part is different from that of the real edge. Moreover, assuming that the fragmentary part is less than a half of the whole edge, ks, the number of which is the largest in the slope distribution can be calculated through step (2), and then points corresponding to ks whose number is not the largest in the slope distribution are eliminated from the point set of the edge points. A point set of upper edge points obtained after the abnormal points are eliminated is defined as PointsSet_Up_New. 
         [0098]    Step 3, straight line fitting: least-square fitting is performed on the point set obtained after the abnormal points are eliminated so as to obtain a straight-line equation. 
         [0099]    Assuming that an upper edge straight-line equation to be solved is y=kx+b, the point set of upper edge points obtained after the abnormal points are eliminated is PointsSet_Up_New, where X represents PointsSet_Up_New.x, Y represents PointsSet_Up_New.y, n is the number of points in the PointsSet_Up_New, then 
         [0000]    
       
         
           
             
               k 
               = 
               
                 
                   
                     n 
                      
                     
                       ∑ 
                       XY 
                     
                   
                   - 
                   
                     ∑ 
                     
                       X 
                        
                       
                         ∑ 
                         Y 
                       
                     
                   
                 
                 
                   
                     n 
                      
                     
                       ∑ 
                       
                         X 
                         2 
                       
                     
                   
                   - 
                   
                     
                       ( 
                       
                         ∑ 
                         X 
                       
                       ) 
                     
                     2 
                   
                 
               
             
             , 
             
               
 
             
              
             
               b 
               = 
               
                 
                   
                     
                       ( 
                       
                         ∑ 
                         Y 
                       
                       ) 
                     
                     - 
                     
                       k 
                        
                       
                         ( 
                         
                           ∑ 
                           X 
                         
                         ) 
                       
                     
                   
                   n 
                 
                 . 
               
             
           
         
       
     
         [0100]    Similarly, for the lower edge, the left edge and the right edge, corresponding edge straight-line equations are obtained respectively through the steps described above. As shown in  FIG. 3  and  FIG. 4 , the effect of edge fitting before abnormal point elimination is different from the effect of edge fitting after abnormal point elimination, and the effect of edge fitting after abnormal point elimination is closer to the edge of an image which is not fragmentary or deformed. 
         [0101]    Step 4, vertex calculation: four vertexes are obtained by solving straight lines of four edges. 
         [0102]    Intersection points, i.e. vertexes of the quadrangle, are obtained by solving a two intersected-line equation. 
         [0103]    An intersection point of the upper edge straight line and the left edge straight line is solved and the upper left vertex A is obtained, an intersection point of the upper edge straight line and the right edge straight line is solved and the upper right vertex B is obtained, an intersection point of the lower edge straight line and the left edge straight line is solved and the lower left vertex C is obtained, and an intersection point of the lower edge straight line and the right edge straight line is solved and the lower right vertex D is obtained, as shown in  FIG. 5 . 
         [0104]    Step 5, correction image: the content of tilt-corrected image is acquired. 
         [0105]    After the image of the valuable documents, the bills or the papers is collected, there might be a requirement for only identifying a part of the content of the valuable documents, the bills or the papers in the application. For example, only an identity card number is required to be identified when an identity card is identified. Also, only a two-dimensional code at the lower right corner of a bill has to be identified when a bill is identified. 
         [0106]    Therefore, the tilt correction described herein can be not only applied to the whole image of the valuable documents, the bills or the papers, but also applied to a partial region of interest in the image of the valuable documents, the bills or the papers. 
         [0107]    A process of the correction includes two steps: 
         [0108]    (1) Calculating a Transformation Relation before the Correction and after the Correction 
         [0109]    X displacement and Y displacement are performed on a point in an original image in a bilinear transformation space to obtain a corresponding point in the corrected image. 
         [0110]    Assuming that four vertexes A, B, C and D are obtained through the calculation in step 4, the corresponding points after tilt correction are A′, B′, C′ and D′ respectively, as shown in  FIG. 5 . 
         [0111]    A correspondence between a point X′(x′, y′) in the tilt-corrected image and a corresponding point X(x, y) in the corresponding original image (an image before tilt correction) is calculated below. 
         [0112]    (1.1) the Displacement in the y Direction is Firstly Calculated: 
         [0113]    the displacement of a point X′ in the corrected image in the y direction is y′, similarly, each of a point E′ and a point F′ also has a displacement y′ in the y direction, and point X′, point E′ and point F′ correspond to a point X, a point E and a point F in the original image, respectively. 
         [0114]    coordinates of point E: 
         [0115]    The displacement of point E′ in the y direction, i.e. the displacement of point E′ on straight line A′C′, corresponds to the movement of point E on straight line AC in the image before tilt correction, which is in proportion to the movement of point E′ on straight line A′C′. 
         [0000]    
       
         
           
             
               
                 x 
                 E 
               
               = 
               
                 
                   x 
                   A 
                 
                 + 
                 
                   
                     
                       
                         y 
                         
                           E 
                           ′ 
                         
                       
                       - 
                       
                         y 
                         
                           A 
                           ′ 
                         
                       
                     
                     
                       
                         y 
                         
                           C 
                           ′ 
                         
                       
                       - 
                       
                         y 
                         
                           A 
                           ′ 
                         
                       
                     
                   
                   · 
                   
                     ( 
                     
                       
                         x 
                         C 
                       
                       - 
                       
                         x 
                         A 
                       
                     
                     ) 
                   
                 
               
             
             , 
             
               
 
             
              
             
               
                 y 
                 E 
               
               = 
               
                 
                   y 
                   A 
                 
                 + 
                 
                   
                     
                       
                         y 
                         
                           E 
                           ′ 
                         
                       
                       - 
                       
                         y 
                         
                           A 
                           ′ 
                         
                       
                     
                     
                       
                         y 
                         
                           C 
                           ′ 
                         
                       
                       - 
                       
                         y 
                         
                           A 
                           ′ 
                         
                       
                     
                   
                   · 
                   
                     ( 
                     
                       
                         y 
                         C 
                       
                       - 
                       
                         y 
                         A 
                       
                     
                     ) 
                   
                 
               
             
           
         
       
     
         [0116]    i.e., [formula 1]: 
         [0000]    
       
         
           
             
               x 
               E 
             
             = 
             
               
                 x 
                 A 
               
               + 
               
                 
                   
                     y 
                     ′ 
                   
                   Height 
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       C 
                     
                     - 
                     
                       x 
                       A 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               E 
             
             = 
             
               
                 y 
                 A 
               
               + 
               
                 
                   
                     y 
                     ′ 
                   
                   Height 
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       C 
                     
                     - 
                     
                       y 
                       A 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0117]    coordinates of point F: 
         [0118]    the displacement of point F′ in the y direction, i.e. the displacement of point F′ on straight line B′D′, corresponds to the movement of point F on straight line BD in the image before tilt correction, which is in proportion to the movement of point F′ on straight line B′D′, 
         [0000]    
       
         
           
             
               x 
               F 
             
             = 
             
               
                 x 
                 B 
               
               + 
               
                 
                   
                     
                       y 
                       
                         F 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         B 
                         ′ 
                       
                     
                   
                   
                     
                       y 
                       
                         D 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         B 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       D 
                     
                     - 
                     
                       x 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               F 
             
             = 
             
               
                 y 
                 B 
               
               + 
               
                 
                   
                     
                       y 
                       
                         F 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         B 
                         ′ 
                       
                     
                   
                   
                     
                       y 
                       
                         D 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         B 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       D 
                     
                     - 
                     
                       y 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0119]    since the corrected image is in a shape of quadrangle, 
         [0000]      y D′ =y C′ , y B′ =y A′ , y F′ =y E′ ; 
         [0120]    therefore, 
         [0000]    
       
         
           
             
               x 
               F 
             
             = 
             
               
                 x 
                 B 
               
               + 
               
                 
                   
                     
                       y 
                       
                         E 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         A 
                         ′ 
                       
                     
                   
                   
                     
                       y 
                       
                         C 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         A 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       D 
                     
                     - 
                     
                       x 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               F 
             
             = 
             
               
                 y 
                 B 
               
               + 
               
                 
                   
                     
                       y 
                       
                         E 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         A 
                         ′ 
                       
                     
                   
                   
                     
                       y 
                       
                         C 
                         ′ 
                       
                     
                     - 
                     
                       y 
                       
                         A 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       D 
                     
                     - 
                     
                       y 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0121]    i.e., [formula 2]: 
         [0000]    
       
         
           
             
               x 
               F 
             
             = 
             
               
                 x 
                 B 
               
               + 
               
                 
                   
                     y 
                     ′ 
                   
                   Height 
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       D 
                     
                     - 
                     
                       x 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               F 
             
             = 
             
               
                 y 
                 B 
               
               + 
               
                 
                   
                     y 
                     ′ 
                   
                   Height 
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       D 
                     
                     - 
                     
                       y 
                       B 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0122]    (1.2) Displacement in the x Direction: 
         [0123]    The displacement of point X′ in the corrected image in the x direction is x′, and the movement of point X′ in the x direction, i.e., the movement of point X′ on straight line E′F′, is in proportion to the movement of point X on straight line EF. 
         [0124]    Coordinates of point X are obtained based on the coordinates of point E and the coordinates of point F: 
         [0000]    
       
         
           
             
               x 
               X 
             
             = 
             
               
                 x 
                 E 
               
               + 
               
                 
                   
                     
                       x 
                       
                         X 
                         ′ 
                       
                     
                     - 
                     
                       x 
                       
                         E 
                         ′ 
                       
                     
                   
                   
                     
                       x 
                       
                         B 
                         ′ 
                       
                     
                     - 
                     
                       x 
                       
                         A 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       F 
                     
                     - 
                     
                       x 
                       E 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               X 
             
             = 
             
               
                 y 
                 E 
               
               + 
               
                 
                   
                     
                       x 
                       
                         X 
                         ′ 
                       
                     
                     - 
                     
                       x 
                       
                         E 
                         ′ 
                       
                     
                   
                   
                     
                       x 
                       
                         B 
                         ′ 
                       
                     
                     - 
                     
                       x 
                       
                         A 
                         ′ 
                       
                     
                   
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       F 
                     
                     - 
                     
                       y 
                       E 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0125]    i.e., [formula 3]: 
         [0000]    
       
         
           
             
               x 
               X 
             
             = 
             
               
                 x 
                 E 
               
               + 
               
                 
                   
                     x 
                     ′ 
                   
                   Width 
                 
                 · 
                 
                   ( 
                   
                     
                       x 
                       F 
                     
                     - 
                     
                       x 
                       E 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               y 
               X 
             
             = 
             
               
                 y 
                 E 
               
               + 
               
                 
                   
                     x 
                     ′ 
                   
                   Width 
                 
                 · 
                 
                   ( 
                   
                     
                       y 
                       F 
                     
                     - 
                     
                       y 
                       E 
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0126]    In this way, the correspondence between any one point (x′, y′) in the corrected image and the point (x, y) in the corresponding original image is obtained according to [formula 1], [formula 2] and [formula 3]. 
         [0127]    A corrected image of the whole image of the valuable documents, the bills or the papers is obtained if the value of x′ is traversed from 0 to Width−1 and the value of y′ is traversed from 0 to Height−1, and a corrected image of a partial region of interest in the valuable documents, the bills or the papers is obtained if the value of x′ is taken only from a part of values within a range of [0, Width] or the value of y′ is taken only from a part of values within a range of [0, Height]. Value ranges of x′ and y′ can be set based on actual requirements in the application. 
         [0128]    (2) Grayscale Interpolation 
         [0129]    After the correspondence between the point before tilt correction and the point after tilt correction is obtained, a grayscale interpolation algorithm is further required for acquiring a final corrected image so that the corrected image has good continuity and consistency. A specific interpolation method includes the Nearest Neighbor Interpolation, the bilinear interpolation, the high-order interpolation or the like. In terms of the time for calculation, the Nearest Neighbor Interpolation has the shortest time, the bilinear interpolation has a longer time, and the high-order interpolation has the longest time. In terms of the smoothness after interpolation, the high-order interpolation is the best, the bilinear interpolation is less good, and the Nearest Neighbor Interpolation is the worst. An interpolation method can be selected based on actual identification requirements in the application. 
         [0130]    The method for correcting the fragmentary or deformed quadrangular image according to the embodiment is applied to the identification technology for a document such as valuable documents, bills or papers and improves the speed and accuracy in identification. 
         [0131]    The above described are only preferred embodiments of the present disclosure, it should be noted that the preferred embodiments described above should not regarded as limiting the present disclosure, and the scope of protection of the present disclosure is in accordance with the scope defined by the appended claims. Many improvements and modifications can also be made by those skilled in the art without departing from the sprit and scope of the present disclosure, and such improvements and modifications will also fall within the scope of protection of the present disclosure.