Abstract:
A method and apparatus for classification of scanned symbols into equivalence classes as may be used for image data compression. The present invention performs run-length symbol extraction and classifies symbols based on both horizontal and vertical run length information. An equivalence class is represented by an exemplar. Feature-based classification criteria for matching an exemplar is defined by a corresponding exemplar template. The feature-based classification criteria all use quantities, which includes the stroke width of symbols, that can be readily computed from the run endpoints. Reducing the number of equivalence classes is achieved through a process called equivalence class consolidation. Equivalence class consolidation utilizes the symbol classifier to identify matched exemplars indicating equivalence classes which may be merged. For a consolidated equivalence class, the exemplar matching the most symbols is selected as the representative for the class.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of Invention 
     This invention is related to compression of scanned text images. In particular, this invention relates to determining the stroke width of a symbol for use in symbol identification. 
     2. Background 
     A major stumbling block to the common use of digitized images is their size. An 8.5&#34;×11&#34; image at a resolution of 300 dots per inch (dpi) contains roughly 8 million pixels. Although binarization of a scanned image reduces the number of bits per pixel to one, this still requires one megabyte of memory to store. Compression techniques are typically characterized as lossless or lossy. In lossless compression, no data is lost in the compression and subsequent decompression. In lossy compression, a certain amount of data is lost. However, this loss is considered acceptable since the essence of the compressed data is retained after decompression. 
     Common lossless compression techniques for binary images, like CCITT Group 3 or Group 4, can compress a binary image by factors of 10 to 20. The resulting file size is unacceptably large when compared to the synthetic electronic form used to create a comparable image. 
     Most documents contain text. One way to compress the text of a binary image is to perform optical character recognition to create a text stream, compress the text stream using one text compression scheme and store the results. Unfortunately, the mistakes made in selection of character, font, face and position during optical character recognition are often objectionable. 
     Commonly assigned U.S. Pat. Nos. 5,778,095 and 5,818,965, each incorporated herein by reference in their entirety, disclose methods and apparatus for classifying symbols extracted from a scanned document into equivalence classes. An equivalence class is a set of symbols found in an image, where each symbol in the class can be substituted for another symbol in the class without changing the appearance of the image in an objectionable way. An equivalence class is represented by an exemplar. An exemplar of an equivalence class is a symbol that will be substituted for every member of the equivalence class when the image is decompressed or otherwise recreated. 
     The systems and methods disclosed in these applications perform run-length symbol extraction and classify the symbols into equivalence classes based on both horizontal and vertical run length information. Feature-based classification criteria for matching an extracted symbol to an exemplar is defined by a corresponding exemplar template. The exemplar template includes a plurality of horizontal and vertical template groups, each defining criteria for matching one or more symbol runs. The feature-based classification criteria use quantities that can be readily computed from the run endpoints. 
     Specifically, the process of matching template groups with symbol runs is identical for both horizontal/vertical template groups and horizontal/vertical symbol runs. Accordingly, the hereinafter described steps apply to both horizontal and vertical runs. The first step is to determine what the distance is between the symbol&#39;s horizontal/vertical axis and its bottom row/left column (called value X) and the corresponding distance in the exemplar (called value Y). These measurements are used to determine whether or not alignment rows/columns are added to the symbol or exemplar. If X-Y&gt;1, is true, then an alignment row/column is added to the symbol. In other words with respect to the horizontal runs, if the symbol&#39;s axis is at least 1 row closer to its bottom row than the exemplar axis is to its bottom row, start with the symbol&#39;s alignment row to align symbol with exemplar. Conversely, if Y-X&gt;1 is true, then an alignment row/column is added to the exemplar. In other words, if the exemplar&#39;s axis is at least 1 row closer to its bottom row than the symbol&#39;s axis is to its bottom row, start with the alignment row of the exemplar. Note that this corresponds to a duplicated set of the template groups used for matching the bottom row of the symbol to the exemplar. 
     The processing proceeds with templates and symbol runs starting at the bottom row, right column of each exemplar. A template group is obtained. It is then determined if the current run(s) in the symbol run list matches the template group criteria. As described above, more than one run can be required to match the criteria for a template group, and the match criteria is specified by the group type. If the template criteria is not met by a run in the run list, the processing continues to get a next exemplar. If the criteria is met, the runs matching the template group are consumed and the next run in the run list becomes the current run. This is to make sure that all runs match some template of the exemplar. If the symbol is small, round and dense, alignment and noise checks are performed for the row. This check is the accumulation of differences in adjacent row offsets when the current row has a non-zero adjacent row offset. 
     It is then determined if more template groups need to be checked. If not, it is determined if the symbol run list has been exhausted. If not, no match has occurred and the processing continues to get a next exemplar. For small, round and dense symbols, if the run list has been has been exhausted, it is determined if the accumulated offset difference is greater than a predetermined threshold. In the currently preferred embodiment, the predetermined threshold is 3/4 of the height (3/4 of the width when comparing vertical runs). If it is not a small, round and dense symbol or the predetermined threshold is not exceeded, a match has occurred and processing continues to code the symbol. If it is exceeded, the processing continues to get a next exemplar. 
     The feature-based classification criteria also include size, number of black pixels (mass), number of black pixels that are not on the edge (interior), a measure of the slant of the symbol, and measures of roundness and squareness (volume). Using these measures in addition to shape-based measures produces acceptable results. 
     SUMMARY OF THE INVENTION 
     However, shape-based schemes have trouble distinguishing bold face characters from non-bold face characters. In smaller characters, the stroke of a bold character is often only one pixel wider than a normal character. Since the disclosed method must be able to tolerate at least one pixel of noise, a simple shape-based measure cannot always distinguish bold face from non-bold face small characters. 
     In the incorporated applications, the total number of black pixels or the mass of a character is measured to determine whether the character is a bold face character or a non-bold face character. While making all of the strokes in a character one pixel wider changes each horizontal slice of the character by very little, this adds up to a large change in the total number of pixels. Unfortunately, many factors effect the total number of pixels in a symbol, including noise. Thus, setting the tolerances close enough to reliably distinguish small, noisy bold characters from small, noisy non-bold characters results in a fairly large set of character classes. This problem was partially solved by only performing this measurement on small characters. However, this had an unfortunate effect of failing to distinguish large bold and non-bold characters. Thus, a more efficient method for distinguishing bold and non-bold characters is needed. 
     This invention provides a method and apparatus for distinguishing bold and non-bold characters. 
     This invention also provides an improved method for classifying scanned symbols into equivalence classes. 
     The method and apparatus of this invention perform run-length symbol extraction and classify symbols based on both horizontal and vertical run-length information. Instead of only measuring the mass of each character, as disclosed in the incorporated applications, the method and apparatus of this invention measures the stroke width of each character to determine whether the character is bold or non-bold. 
     Stroke width measurement also provides a more efficient method for distinguishing very small punctuation marks. Conventionally, determining the number of interior pixels was necessary to distinguish one small punctuation mark from another small punctuation mark. Since the total number of pixels and the size of different small punctuation marks are the same, determining the number of non-edge pixels was necessary to distinguish symbols having tails, such as commas and apostrophes, from symbols of roughly the same size. Since measuring the stroke width of a character provides a more efficient method of determining the shape of small characters, determining the number of interior pixels of a small symbol to distinguish from another small symbol is no longer necessary. 
     More particularly, this invention is directed to distinguishing bold-face symbols from normal face symbols in scanned text images using the stroke width of the symbols. A preferred method of the invention includes scanning a symbol, generating histograms of the symbol, summing the pixels from the histograms, summing the number of runs used in the pixel sum, and using the two sums to determine the stroke width of the symbol. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     The preferred embodiments of this invention will be described in detail, with reference to the following figures, wherein: 
     FIG. 1 is a block diagram of an apparatus which performs the invention; 
     FIG. 2 illustrates horizontal runs of a symbol; 
     FIGS. 3 and 4 are histograms of the pixel run count of the symbol shown in FIG. 2; and 
     FIG. 5 illustrates a preferred method of this invention. 
    
    
     DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS 
     A computer based system which performs this invention is described with reference to FIG. 1. Referring to FIG. 1, the computer based system includes a plurality of components coupled via a bus 101. The bus 101 illustrated here is simplified in order not to obscure the present invention. The bus 101 may include a plurality of parallel buses (e.g., address, data and status buses) as well as a hierarchy of buses (e.g., a processor bus, a local bus and an I/O bus). The computer system further includes a processor 102 for executing instructions provided via the bus 101 from an internal memory 103. Such instructions are those that are preferably implemented in software for carrying out the processing steps outlined in the flowchart of FIG. 5 and the flowcharts contained in the incorporated applications. The software is preferably written in the C programming language. The functions of the histogram generator 112, the symbol classifier 113, and the consolidator 114 may be performed by software or other means known in the art. The internal memory 103 is typically a combination of RAM and/or ROM. The processor 102 and internal memory ROM 103 may be discrete components or a single integrated device such as an application specific integrated circuit (ASIC) chip. 
     Also coupled to the bus 101 are a keyboard 104 for entering alphanumeric input, an external storage 105 for storing data, a cursor control device 106 for manipulating a cursor, and a display 107 for displaying visual output. The keyboard 104 would typically be a standard QUERY keyboard but may also be a telephone-like keypad. The external storage 105 may be a fixed or removable magnetic or optical disk drive. The cursor control device 106 will typically have a button or switch associated with it to which the performance of certain functions can be programmed. Further coupled to the bus 101 is a scanner 108. The scanner 108 provides a means for creating a bit-mapped representation of a medium (i.e., a scanned document image). 
     Optional elements that could be coupled to the bus 101 include a printer 109, a facsimile element 110 and a network connection 111. The printer 109 could be used to print the bit-mapped representation. The facsimile element 110 may contain an element used to transmit image data that has been compressed using the present invention. Alternatively, the facsimile element 110 could include an element for decompression of a document image compressed using the present invention. The network connection 111 would be used to receive and/or transmit data containing image data. Thus, the image data utilized by the present invention may be obtained from the scanner 108, via a received fax or over a network. 
     The histogram generator 112 generates histograms of extracted symbols. The symbol classifier 113 classifies the extracted symbols into equivalence classes which are represented by unique exemplars. The number of created equivalence classes, will normally be less than the total number of symbols extracted. The created output scheme includes exemplar ID/position pairs followed by a dictionary of the exemplars. 
     The consolidator 114 consolidates the set of equivalence classes by reducing the number of equivalence classes and compresses the image data by reducing the size of the dictionary. The manner in which consolidation occurs is nearly identical to the way in which symbols are compared to exemplars. In general, the more work expended to match symbols, the more matches that will be found. For the sake of efficiency, this extra effort may be more efficiently performed on the relatively small set of equivalence classes rather than performing it on the entire set of raw symbols. 
     When the image is decompressed, each of the exemplar ID/position pairs is processed so that an identified exemplar is placed at a specified location. This continues for all of the pairs. Because exemplars are substituted for the original symbol in the matching process, this type of compression is termed lossy compression. Despite this substitution, the essence of the image will remain. 
     The symbol classifier 113 analyzes runs representing the symbol rather than bitmaps to directly classify the symbol. The symbol classifier 113 still uses symbol features like width and height for classification. For more detailed symbol features, the symbol classifier 113 compares the position of each symbol run endpoint with a corresponding range of legal endpoint locations computed by looking at a corresponding group of three adjacent scan lines in an exemplar. To achieve sufficient accuracy, vertical runs are produced from the horizontal runs and both sets of runs are used in classification. 
     As shown in FIG. 1, the computer-based system is preferably implemented on a programmed general purpose computer. However, the computer-based system can also be implemented on a special purpose computer, a programmed microprocessor or microcontroller and peripheral integrated circuit elements, an ASIC or other integrated circuit, a hard-wired electronic or logic circuit such as a discrete element circuit, a programmable logic device such as a PLD, PLA, FPGA or PAL, or the like. In general, any device which is capable of complementing a finite state machine capable of implementing the methods of this invention, can be used to implement the computer-based system. 
     Feature-based classification criteria use quantities that can be readily computed from the run endpoints. The availability of these endpoints makes the generation of numerical measures of the symbol much easier than it would be with bitmaps. The feature-based classification criteria are: individual symbol width and height; equivalence class width and height; stroke width; slant; and horizontal and vertical volumes. 
     Symbol width and height are specified by a bounding box surrounding the symbol. The symbol width and height are used to select a subset of the equivalence classes to compare against and to decide which symbol feature tests to apply. In the currently preferred embodiment, the equivalence class exemplar must be within the range of plus or minus two pixels of the symbol width and height in order to be eligible for comparison. 
     The most basic tests are adequate for distinguishing large symbols. On smaller symbols, subtle features become important so more tests are needed. Small symbols are generally defined as those having a width or height of 20 or fewer pixels. 
     The determination of the equivalence class width and height range is used in two ways. First, since very small symbols have a smaller range of matching widths and heights, minimum and maximum allowable widths and heights are recorded with each class. Symbols outside these ranges cannot be included in the class. Second, the width and height ranges are used when performing equivalence class consolidation. This determination provides a minimum and maximum allowable width and height for each consolidated class. 
     When determining the stroke width of a character or symbol, the vertical runs and the horizontal runs are analyzed. Since the analysis of the horizontal runs is identical to the analysis of the vertical runs, only the analysis of the horizontal runs is illustrated and described. A horizontal run is a continuous row of pixels of one state. FIG. 2 shows the horizontal runs of an &#34;o&#34; formed in scan lines 201-207. The horizontal runs in the scan lines 201 and 207 each contain 5 pixels, the four horizontal runs in the scan lines 202 and 206 each contain 1 pixel, and the horizontal runs in scan lines 203-205 each contain 2 pixels. The horizontal runs of short length namely the horizontal runs in the scan lines 202-206, represent the vertical strokes of the character. 
     FIG. 3 shows a histogram of the symbol shown in FIG. 2. The histogram is indexed by run length and contains the number of runs of that length. FIG. 4 also shows a histogram of the symbol shown in FIG. 2. This histogram is indexed by the run length and contains the total number of pixels in runs of that length. The number of total pixels of a run length is the run length multiplied by the number of runs in that length. 
     Starting from the shortest run length and proceeding towards the longest run length, for each run length the total number of pixels in runs of that length are added to a first running sum. The first running sum will stop when it becomes a sufficiently large fraction of the total mass of a symbol. The total mass of a symbol is the total number of black pixels needed to represent the symbol. Preferably, the running sum stops when the first running sum becomes at least equal the total mass. However, the running sum can be stopped based on other criteria. 
     A second running sum is calculated by summing the total number of runs used to determine the first running sum. The stroke width of the character equals the first running sum divided by the second running sum. An extracted symbol will be categorized into a particular equivalence class only if the stroke width of the extracted symbol and the exemplar of the equivalence class differs by no more than 0.5 pixels. If the stroke widths were allowed to vary by an entire pixel, any amount of erosion of a bold face symbol or any fattening of a normal symbol would allow them to match. 
     Using the symbol shown in FIG. 2 as an example, the mass equals 26 and the first running sum equals 16. The first running sum is stopped after adding the number of pixels in runs having run lengths of 1 and 2 since 16 is greater than one-half the total mass of 26. For this example, the second running sum equals 10. The second running sum equals the sum of the number of runs having run lengths of 1 and 2. Thus, the stroke width of the symbol shown in FIG. 2 equals 16/10 or 1.60. 
     In a preferred method of the invention the processor 102 directs the scanner 108 to scan a symbol contained in an image document. The processor 102 directs the histogram generator 112 to generate a first histogram of the symbol indexed by run length and contains the number of runs of that length, and a second histogram of the symbol indexed by run length and contains the total number of pixels in runs of that length. The processor 102 determines the total mass, the first running sum, the second running sum, and the stroke width of the symbol. The processor 102 directs the symbol classifier 113 to categorize the symbol into an equivalent class or creates a new equivalent class. 
     A preferred method of the invention is described with reference to FIG. 5. 
     The method starts in step S500. In step S510, a symbol contained in an image document is scanned. In step S520, the first histogram of the symbol indexed by run length and containing the number of runs of that length, and a second histogram of the symbol indexed by run length and containing the total number of pixels in runs of that length are generated. In step S530, the total mass, the first and second running sums, and the stroke width of the symbol are determined. In step S540, the symbol is categorized into an equivalent class or a new equivalent class is created. In step S550, the method ends. 
     While this invention has been described in conjunction with the specific embodiments outlined above, it is evident that many alternatives, modifications and variations will be apparent to those skilled in the art. Accordingly, the preferred embodiments of the invention as set forth above are intended to be illustrative, not limiting. Various changes may be made without departing from the spirit and scope of the invention as defined in the following claims.