Abstract:
A method and an apparatus which scans and recognizes a page having columns of text or pictorial images. The scanned page is partitioned into blocks of scanlines and the column gap between the columns are identified by a projection profile process. With this technique the page can be severely tilted while under scan and still be properly recognized.

Description:
TECHNICAL FIELD 
     The present invention relates to a system and a method for recognizing a scanned page having more than one column of text and/or pictorial images and for compensating any tilt or skew in the scanned page. 
     BACKGROUND OF THE INVENTION 
     It is known in the art to optically scan and recognize a page having text or pictorial images. The information from the scanned page is converted into electronic data as an array of pixels representing black or white points of each scanline in the paper. The data is stored and is aggregated to reproduce the scanned images. A problem with this technique is its inability to distinguish two or more columns in a page, i.e., the recognized lines will be interpreted as continuous and without the separation between the columns. If the document contains illustrations or graphics, interpretation will be erroneous if they are treated as text characters. Therefore, it is desirable to have a processing step to divide the scanned images into (1) areas corresponding to illustrations and (2) areas corresponding to text and to further subdivide the latter into columns. Then the recognition process will be applied to each column of text. 
     The process of partitioning images into columns of text is called page segmentation. One known page segmentation technique assumes that columns of text and illustrations form a right rectangle having one pair of sides vertical and the other horizontal. See, for example, U.S. Pat. No. 4,503,556 to Scherl, et al. and an article by H.S. Baird, S.E. Jones and S.J. Fortune &#34;Image Segmentation by Shape-Directed Covers&#34;, published in the Proceedings 10th Int. Conf. on Pattern Recognition pp. 820-825, (June, 1990). The disclosure of each of these references is incorporated herein by reference for the purpose of providing an understanding of basic techniques employed in the general field of the invention. 
     In a commonly known technique in the art, the electronically scanned page is usually a matrix of 1&#39;s representing dark pixels and 0&#39;s representing light pixels. Generally, W is the width, H is the height of the matrix and m[i][j] represents the matrix element in the i th  row and j th  column. A projection profile along the horizontal is defined as ##EQU1## and a projection profile along the vertical is defined as ##EQU2## 
     Previous state of the art methodologies assume that gaps between blocks of texts can be found by searching for places with projections of zero. If the page is upright, then indeed there will be a count of zero within the white spaces between columns along the page P[j]. When the page is tilted, then there will be a certain nonzero count in the white spaces between the columns. 
     Thus, prior art techniques often fail when the page is tilted while being scanned or when the document contains text and illustrations not printed in a rectangular form. 
     For example, consider a hypothetical situation where the text area of a page is 6 inches in width and 7 inches in height. When scanned at 300 pixels per inch, a matrix results with W equal to 1800 pixels and H equal to 2100 pixels. Suppose also that each of the two text columns is 2.85 inches wide (855 pixels) and the gap in between them is 0.3 inches (90 pixels). for values of j between approximately 860 and 940. However, if the page is scanned with a tilt of 6 degrees, then the white spaces will shift from the range of 860 to 940 at the top row to the range from 1080 to 1160 towards the bottom row. 
     Since the sine of 6 degrees equals about 0.105, each vertical projection with a &#34;j&#34; value greater than 940 will have a, zero count for a length of approximately 0.3 inches divided by 0.105 or about 860 pixels. If the remaining 1240 pixels are mostly black, a count value as high as 1000 may not be unexpected. 
     In the example above, the vertical projection profile will be nonzero for &#34;j&#34; values between 860 and 940 if the tilt angle is greater than 2.5 degrees (tangent of 0.3 inches/7.0 inches). 
     Thus, it is desirable to improve the processing of scanning systems with techniques which are more tilt independent. 
     SUMMARY OF THE INVENTION 
     It is therefore an object of the invention to provide a system and a method for scanning and recognizing a document page and properly segmenting the columns even when the page is skewed or tilted while being scanned. 
     In accordance with the technique of the present invention, a document page is scanned. A search may be made for white spaces which are wide enough to be distinguished from other spacing, such as the white spacing between characters or words. However, such a method will produce erroneous results when very wide white spaces occur between two descendants or ascendants of characters, either within a column or across columns. In the former case they produce false starts, in the latter they distort the width of the column gap. 
     To overcome this problem, the page is partitioned into blocks of scanlines. The column gaps in each block are identified by a projection profile process. Blocks having matching column gaps are merged. The skew angle of each block is estimated by measuring the slope of the line dividing the center of the column gaps in the merged blocks. The scanned images are reconstructed by repositioning the merged blocks by matching column widths and column gap widths. Then the reconstructed image is rotated by the estimated skew angle to compensate for the tilt. 
     In contrast to previous techniques, the present invention performs projection profile on sections much smaller than a full page. Advantages derivable from this technique include a much more skew tolerant recognition process. For example, if the projections are computed only over a short height (less than 0.5 inches) of the text, the white spacings in a column gap of 0.3 inches can be detected even when the tilt is at an angle of about 31 degrees (tangent of 0.3/0.5). This is a dramatic improvement as compared to the 2.5 degrees of tilt found to be the maximum acceptable for a vertical projection over a height of 7 inches as explained in the background of the invention. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 illustrates a block diagram of the system according to the present invention. 
     FIG. 2 illustrates the program flow steps for identifying column gaps and forming column blocks. 
     FIG. 3 illustrates the program flow steps for the treatment of wide white spacings resulting from other than column gaps. 
     FIG. 4 illustrates the program flow steps for merging column blocks. 
     FIG. 5 illustrates a sample scanned page. 
     FIG. 6 illustrates the result of the recognition process according to the present invention. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     FIG. 1 is a block diagram representation of a system according to a preferred embodiment of the present invention. A scanner 100 is used to obtain a binary representation of the images on a page. The binary information is stored in memory 101 and is preprocessed into run length format prior to processing by processor 102. The stored programs which embody the processing technique of the present invention can be loaded into memory 101. Alternatively, the programs can be permanently stored in a ROM 103. According to one preferred embodiment, a Ricoh 100 scanner with a resolution of 300 points per inch, which produces a binary image of 2512×3400 and a SUN 4 workstation are used. The UNIX operating system and the C programming language are used. 
     Illustrative commented software (source code) for carrying out the processes herein described forms a part of this specification and is attached hereto as Appendix A. 
     FIG. 2 illustrates the steps for identifying white spaces in the column gaps and the forming of the column blocks with common areas of column gaps. In step 201, the page is scanned and preprocessing of the data is performed. 
     In step 202, the scanned page is partitioned into blocks of scanlines for projection profile processing. In the preferred embodiment according to the present invention, the number of scan lines per block varies from 48 (0.16 inches) to 256 (0.85 inches) with 128 (0.43 inches) being the value that gives the optimum result. 
     In step 203, vertical projections are formed and the column gaps are identified by the wide white spaces in them. For example, 40 continuous pixels of white spaces may be used as the criteria for a &#34;wide&#34; white space. Areas of wide white spaces are assumed to be column gaps. 
     A smearing process may be embedded in the vertical projection. Any short black run of consecutive 1&#39;s in a scan line is absorbed by its neighboring white runs, if both of its two neighboring white runs are not too short. 
     A black run is defined as short if it has a length less than a parameter (e.g. NOISE --  B) selected equal to 5 in this embodiment. Similarly a white run is defined as not too short if it has a length shorter than a parameter (e.g. NOISE --  W) selected equal to 10 in this embodiment. This processing eliminates the sporadic black noise spots occurring in the column gaps without wiping off black dot textures in illustration regions, which are often composed of short run black-white dot patterns. 
     When a column gap is encountered in a block, that block is set aside as part of a column block. 
     In steps 204 and 205, the column gap found in the next scanline block will be compared to the column gap of the column block previously identified. If appropriate, the new scanline block will be merged with the column block. If not, a new column block is formed (step 206). The conditions for merging are as follows: 
     Assuming each column gap is a rectangle specified by X left , X right , Y top , and Y bottom  in which P→X left  means the left endpoint of a column gap pointed by P. Any new found column gap pointed by P in the scanline block being processed will be merged into an existing column block Q if all of the following three conditions are satisfied: 
     1. The two gaps are very close in the vertical direction: 
     
         |P→Y.sub.top -Q→Y.sub.bottom |=ε.sub.1 
    
     a pre-specified tolerance ε 1 . 
     2. One of the horizontal projections of the two column gaps is completely inside the other: 
     
         P→X.sub.left &gt;Q→X.sub.left -ε.sub.2 and P→X.sub.right &lt;Q→X.sub.right -ε.sub.2 
    
     or 
     
         P→X.sub.left &lt;Q→X.sub.left -ε.sub.2 and P→X.sub.right &gt;Q→X.sub.right -ε.sub.2 
    
     where ε 2  is a second pre-defined tolerance. 
     3. The widths of the two column gaps are approximately the same: ##EQU3## where ε 2  is a third pre-defined tolerance. 
     In the preferred embodiment, ε 1  is two pixels, ε 2  is 2 and ε 3  is 0.98. 
     The left and right margins of the page will also have wide white spacings and will therefore be considered as column gaps. They are processed the same way as for other column gaps but will be identified as margins in subsequent processing. 
     FIG. 3 shows the flow steps for handling wide white spacings resulting from other than column gaps, for example, the line ending a paragraph with a small amount of text and a wide white spacing. This process is shown in steps 301 to 308 and involves the re-examination of the blocks that are small either in the vertical or horizontal direction, and in addition satisfy conditions 1 and 2 of the merger test described in step 204. Larger tolerances ε 1  and ε 2  are used in this process. In the preferred embodiment, ε 1  is 20 and ε 2  is 5. 
     In step 301, two column blocks which are neighbor to each other in the vertical direction are examined. Tests for horizontal merger are performed in step 302. If the ratio computed between the smaller width over the larger width is less than 0.2, then the smaller block is a merger candidate. In step 303, if the candidate satisfies conditions 1 and 2 of the merger test in step 204, the blocks are merged. The same tests are performed for the remaining blocks in step 304. 
     In step 305, the neighboring column blocks are examined and a vertical merger test is performed in step 306. If the ratio between the block having a smaller height over the block having a taller height is less than 0.4, then the shorter block is a merger candidate. In step 307, conditions 1 and 2 of step 204 are tested on the identified candidate and the respective blocks are merged if the conditions are satisfied. The same tests are performed for the remaining blocks in step 308. 
     FIG. 5 shows a scanned page and FIG. 6 the recognized result of the scan and the processing according to the technique described above. This result appears satisfactory. However, when the scanned page is tilted, the recognized result will also be tilted. Thus, additional processing is needed. Since one does not know in advance whether there will be a skew in the page under scan, the skew estimation process should be incorporated in all scans. 
     According to the skew estimation technique of the present invention, straight lines represented by y=ax+b are placed into the column gaps in the column block using a linear algorithm. (See, for example, the text by T. Pavlidis Structural Pattern Recognition, Chapter 7, Springer Verlag (1977)). As shown in steps 401 to 410 of FIG. 4, blocks are merged if their lines are approximately collinear and their widths are approximately the same. When no further merging is possible the slope of the line provides an estimate of the skew angle. 
     A column block is represented by Y top , Y bottom , width, and a straight line through the middle of the block, y=ax+b. A non-labeled column block is a column block to be merged to a column block set. A non-labeled column block is represented as previously indicated for column gaps. 
     P is a pointer of a column block set, and Q is a pointer of a non-labeled column block. Q will be merged into P if the following three conditions are satisfied: 
     1. P and Q are very close in the vertical direction: 
     
         |P→Y.sub.top -Q→Y.sub.bottom |&lt;ε.sub.1 or |P→Y.sub.bottom -Q→Y.sub.top |&lt;ε.sub.1 
    
     for a pre-specified tolerance ε 1 . 
     2. The center point of column block Q is not far away from the central Y axis of P: 
     
         {((Q→Y.sub.top +Q→Y.sub.bottom)/2)-b}/a-((Q→X.sub.left +Q→X.sub.right)/2)&lt;ε.sub.4 
    
     where ε 4  is a pre-defined tolerance, &#34;a&#34; is the slope of the line and &#34;b&#34; is the y axis adjustment value. 
     3. The widths of P and Q are approximately the same: ##EQU4## where ε 3  is a pre-defined tolerance. 
     In the preferred embodiment, ε 1  is set to 40, ε 3  is set to 0.9 and ε 4  is set to 40. 
     In contrast to other prior approaches, the skew estimation according to the present invention does not require a large computing overhead. This is because only the partitioned blocks are processed as opposed to all the texts and images in a whole page. A much smaller memory is required because of the smaller processing requirement. 
     Because of noise, the estimated angles are not all the same and a weighted average is computed by using the length of the blocks to weigh the angles of the corresponding angles. If the average estimated skew angle is less than a predefined value, then the input page is considered to be roughly upright, and no correction is applied. Otherwise, the left and right lines of each column blocks are rotated according to the average skew angle. If desirable, column blocks could also be outlined according to their individual skew angles. 
     For the same reasons that a second pass is made during the initial column block formation process, a second pass is made to further merge blocks if two compared blocks have similar skew angles, touch each other in the vertical direction, have similar width, and the last interval of one overlaps significantly the first interval of the other. 
     Although an exemplary embodiment of the invention in its various aspects has been described above and shown in the accompanying drawings, flow charts and software listing, the invention is not limited to the particular aspects of the example but should be interpreted in accordance with the claims which follow. 10