Data processing

Abstract: An existing character (42), in a text defined in image form by data such as a two-dimensional array, is copied to add a new character to the text. The existing character is found by performing character recognition on a two-dimensional data array defining an image that includes part of the text, such as a page. The array can be obtained from a scanner. A word (30) that is recognized as including characters of the type needed is tested to determine whether it can be divided into the correct number of characters. The word is divided by finding connected components in the part of the array in which the word was found during recognition. The connected components are grouped into sets, each set being likely to be a character. If the word can be correctly divided, character-size arrays for its characters are obtained and saved. One of the arrays for the character type of the new character is selected and used to produce an array for the word in which it is included. The new word's array is then used to produce an array for a line in which the new word replaces an old word. The characters of the new word are spaced according to the spacing of the characters of the old word. The new character is positioned transverse to the line based on the transverse positioning of the existing character. The interword spaces of the line are adjusted. The line's array is then used to produce data defining a modified version of the text in image form. The old word can be an incorrectly spelled word, detected by spell-checking the character recognition results. Alternative spelling corrections can be presented to the user for selection of a correction to be used.

Description: The present invention relates to techniques for operating on an image that includes text. More specifically, the invention relates to inserting, deleting, or otherwise changing characters in an image defined by a two-dimensional data array. For example, the characters of a word could be changed to correct its spelling. Wong, K.Y., Casey, R.G., and Wahl, F.M., "Document Analysis System," IBM Journal of Research and Development, Vol. 26, No. 6, November 1982, pp. 647-656, describe a system, shown in Fig. 1, that assists a user in encoding printed documents for computer processing. An image manipulation editor (IEDIT) described at pages 648-649 reads and stores images on disk and provides image-editing functions, such as copy, move, erase, etc. As described at pages 649-656, a digitized printed document is segmented and classified into regions of text and images. Blocks containing text can be analyzed with a pattern-matching program that groups similar symbols from the document and creates a prototype pattern to represent each group. During pattern matching, the position and matching prototype index for each text pattern is recorded; the position may be the coordinates of the lower left corner of the array representing the pattern. The prototype patterns are identified interactively or by automatic recognition logic. Inclusion of a dictionary-checking technique is planned to help correct errors incurred during recognition. Casey, R.G., and Wong, K.Y., "Text Recognition Using Adaptive Software," Globecom '85 , Vol. 1, IEEE, 1985, pp. 353-357, describe techniques for entering optically scanned printed text into a computer by first extracting one or more examples or "prototypes" of each symbol on the page The prototypes are post-analyzed to detect and separate merged characters, and then, in an interactive stage, are presented to an operator who keys in identity codes. In the interactive stage, the operator modifies the resulting text if necessary Page 354 describes how characters are segmented. User interaction, described beginning at page 355, includes display of unresolved prototypes for the operator to key the identities; a contextual display of prototype displays for the operator to change the ID of any prototype; and highlighting words not present in a dictionary and offering a list of alternative spellings to detect identification errors and correct false matches. Suenaga, Y., and Nagura, M., "A Facsimile Based Manuscript Layout and Editing System by Auxiliary Mark Recognition," 5th International Conference on Pattern Recognition Proceedings , December 1-4, 1980, Vol. 2, pp. 856-858, describe an editor whose only input device is a FAX transmitter and whose only output device is a FAX receiver. Fig. 1 shows components of the system, including OCR, and Fig. 2 shows the processing flow, which includes a text editing subsystem and a graphics editing subsystem The text editing subsystem rearranges the binary picture of the text, as illustrated in Figs 4(a) and 4(b). Marginal distribution (profile) and horizontal connectivity are used to divide the text picture into Segmented Blocks (SBs), corresponding to the rectangular regions which cover the individual characters in Japanese texts, individual words in alphanumeric texts, or graphics to be processed as binary patterns. A segmented block list (SBL) is constructed and used to extract and classify marks based on topological and metric features. A mark parameters list for texts (MPL-T) is constructed. A picture allocation list (PAL), consisting of the SB numbers and their linkage addresses, is generated according to the MPL-T and SBL. Character strings or patterns are virtually deleted, moved, copied, and combined in PAL. The binary picture of the original text is rearranged according to the PAL to construct the fair copy. Brickman, N.F., and Rosenbaum, W.S., "Word Autocorrelation Redundancy Match (WARM) Technology," IBM Journal of Research and Development, Vol. 26, No. 6, November 1982, pp. 681-686, describe facsimile technology that compresses an image of a textual document by complex symbol matching on both the word level and then the character level, as shown and described in relation to Fig. 1. The processing order shown in Fig. 1 is reordered slightly if the font is not known a priori , in which case the character level is done first to obtain the document's font. Holt, M.J.J., and Costas, S.X., "Compression of Document Image Data by Symbol Matching," in Cappellini, V., and Marconi, R., Eds., Advances in Image Processing and Pattern Recognition, Elsevier Science Publishers, 1986, pp. 184-190, describe techniques for compressing typewritten and printed documents using a pattern-matching algorithm. GB-A-2 162 350 discloses an image processing system comprising: a means to read and input image information, means to input character information, recognizing unit for recognizing the character information inputted by the read and input means, and an image processor for performing the editing of characters on the basis of the recognizing unit output. The present invention as defined in the claims provides techniques for changing characters in text appearing in an image. The image may, for example, be defined by a two-dimensional data array; such an array could be received from an image input device such as a scanner or camera, from a stored file, or from any other source. An array defining a character can be obtained from the same text and the character array can then be used in making a change. One aspect of the invention is based on the observation of a fundamental problem in changing characters in text in an image. When the result of a change is that the text includes a new character that is not in the text prior to the change, the changed version of the image will be unsatisfactory unless the new character matches other occurrences of the same character type in the text. For example, if the new character is of a different typeface or a different point size from other occurrences of the same character type in the text, it will detract from the appearance of the text. This aspect is further based on the discovery that this problem can often be solved by finding an existing character that already appears in the text and that is of the same character type as the new character. Data, such as a two-dimensional array, defining this existing character in substantially the same way as it is defined by the data defining the image in which it appears can be obtained automatically. The image in which the existing character appears may be the same as the image being modified or may be another image that includes another part of the same text, such as another page. A modified version of the image being modified can then be produced in which the new character is defined in substantially the same way as the existing character was previously defined. This solution can be implemented by performing character recognition on a two-dimensional array defining an image that includes part of the text. The recognition results can include spatial data, indicating the positions of correctly spelled words within the array, and identity data, indicating the character types of characters they contain. Using spatial data indicating the position of a correctly spelled word that includes the existing character, an intermediate two-dimensional array that includes the word can then be obtained. The two-dimensional array that defines the character can then be obtained automatically from this intermediate array. Other closely related aspects of the invention are based on the observation that an existing character may be unsatisfactory even if it occurs in a correctly spelled word. For example, one or more of the word's characters may be poorly formed. Or a text may include more than one typeface or point size, so that some of the correctly spelled words will be inappropriate because they have the wrong typeface or point size. These problems can be alleviated in a number of ways. One aspect of the invention alleviates the problem of poorly formed characters by testing a word before using its characters. The word's array can be analyzed to find the connected components within it, and the connected components can be grouped into sets each of which is likely to be a character according to appropriate criteria. If the number of component sets is not equal to the number of characters in the word, then it is likely that one or more of the characters is poorly formed, either by the breaking of a character into parts or by the joining of two characters. Therefore, the word is not used unless it has as many component sets as characters. Another aspect of the invention alleviates the problems of poorly formed characters and multiple typefaces or point sizes by selecting a character that is likely to be appropriate from a set of characters of the same character type that have been recognized. As they are obtained, the two-dimensional arrays for the characters of each character type can be compared For characters that are almost identical, the first one found can be retained. For characters that are substantially different, both can be retained, and one can be selected for a particular new character. The selection could be made by a user. Also, contextual data could be saved for each character that is found, indicating its position, its typeface, its point size, or the like. Then, the contextual data could be used to select the two-dimensional array for a particular insertion. Other aspects of the invention are based on the observation that some operations on text require more than simply adding a new character. For example, to perform spelling correction on text in image form, it is often necessary to replace or reorder a number of characters in a word, an operation that may include both deletions and insertions. But each deletion and insertion, if performed separately, requires repositioning of other characters, making the overall operation complex and subject to positioning errors. In addition, spelling correction or any other operation adding a new character to an existing word or deleting a character from an existing word may require additional corrections because other characters of the word are poorly formed. One aspect of the invention is based on the discovery of a technique that can perform complex operations such as spelling correction and adding or deleting a character in an existing word in a text in image form. Rather than performing such operations on each character separately, the entire word can be deleted and replaced with a new word whose two-dimensional array is produced from data defining the text in image form. Spatial data indicating the spacing of the characters in the replaced word can be used in positioning the characters within the new word's array in a direction along the line. Spatial data indicating the position of each character's array relative to a baseline can be used in positioning the characters in a direction transverse to the line. A related aspect is based on the observation that it is often necessary to reposition other words in a line in which a word is being replaced. This repositioning can be done by obtaining a two-dimensional array for the line in which interword spaces are adjusted so that the words, including the replacement word, are appropriately spaced. Word replacement can then be done by producing a modified version of the image in which the line is defined as in its array. In one aspect of the invention, there is provided a method of changing characters in text in an image; the method comprising: holding first text image data in memory; the first text image data defining a first version of a text in image form, the first version of the text including a first character that is an instance of a first character type; and operating processing means connected for accessing the memory to produce second text image data using the first text image data, the second text image data defining a second version of the text in image form with a second character that is an instance of the first character type, characterised in that the processing means, in producing the second text image data: operates on the first text image data to find the first character in the first version of the text and to obtain first character data defining the first character in substantially the same way as it is defined by the first text image data; and uses the first text image data and the first character data to produce the second text image data with the second character defined by the second text image data in substantially the same way as the first character is defined by the first character data. In another aspect of the invention, there is provided a data-processing system comprising: processing means; and memory connected for being accessed by the processing means; the memory storing a first data structure that includes first text image data defining a first version of a text in image form, the text including a first character that is an instance of a first character type; the processing means operating to produce second text image data using the first text image data, the second text image data defining a second version of the text in image form with a second character that is an instance of the first character type, characterised in that the processing means, in producing the second text image data: operates on the first text image data to find the first character in the first version of the text and to obtain first character data defining the first character in substantially the same way as it is defined by the first text image data; and uses the first text image data and the first character data to produce the second text image data with the second character defined by the second text image data in substantially the same way as the first character is defined by the first character data. The present invention will be described by way of example with reference to the accompanying drawings, in which: Fig. 1 is a flow chart showing stages in a spelling correcting operation by replacing a word with a new word formed of new characters according to the invention; Fig. 2 is a flow chart showing general steps in providing a new character according to the invention; Fig. 3 is a flow chart showing in more detail how data defining a character can be obtained in Fig. 2; Fig. 4 is a flow chart showing in more detail how data defining a modified text with a new character can be produced in Fig. 2; Fig. 5 is a block diagram showing components of a system for spelling correction by replacing a word with a new word formed of new characters according to the invention; Fig. 6 is a block diagram showing components of a system according to Fig. 5 in which the processor includes three subprocessors; Fig. 7A shows a view of an image that includes text; Fig. 7B shows a view of a modified version of the text of Fig. 7A in which misspelled words have been replaced by correctly spelled words according to the invention; Fig. 8 is a flow chart showing steps in producing a word list data structure for use in spelling correction according to the invention; Fig. 9 is a flow chart showing steps in spelling correction according to the invention; Fig. 10 is is flow chart showing steps in typesetting a word in Fig. 9, and Fig. 11 is a flow chart showing steps in replacing a word in Fig. 9; A. Conceptual Framework The following conceptual framework is helpful in understanding the broad scope of the invention, and the terms defined below have the meanings indicated throughout this application, including the claims. "Character" means a discrete element that appears in a writing system. Characters in the English language can thus include not only alphabetic and numerical elements, but also punctuation marks, diacritical marks, mathematical and logical symbols, and other elements used in writing English. More generally, characters can include, in addition to alphanumeric elements, phonetic, ideographic, or pictographic elements. A "character type" is a category of which a character may be an instance, such as the letter "a" or the number "3". A "word" is a set of one or more characters that is treated as a semantic unit in a language. A "text" is an arrangement of one or more lines of characters; the characters of a text may form words. An "image" is a pattern of light. An image may include characters, words, and text as well as other features such as graphics. A text may be included in a set of one or more images, such as in images of the pages of a document. A "data structure" is any combination of interrelated items of data. An item of data is "included" in a data structure when it can be accessed using the locations or data of other items in the data structure; the included item of data may be another data structure. Conversely, an item of data can be "removed" from a data structure by rendering it inaccessible, such as by deleting it. An "array of data" or "data array" or "array" is a data structure that includes items of data that can be mapped into an array. A "two-dimensional array" is a data array whose items of data can be mapped into an array having two dimensions. Data or a data structure can be "obtained" or "produced" by any operations that result in the data or data structure. Data or a data structure can be "obtained from" or "produced from" other data or another data structure by operations that obtain or produce the data or data structure using the other data or using data in the other data structure For example, an array can be obtained from another array by operations such as producing a smaller array that is the same as a part of the other array, producing a larger array that includes a part that is the same as the other array, copying the other array, or modifying data in the other array or in a copy of it. Data "defines" an array when it includes data sufficient to obtain or produce the array. For example, data defining an array may include the defined array itself, a compressed or encoded form of the defined array, a pointer to the defined array, a pointer to a part of another array from which the defined array can be obtained, or pointers to a set of smaller arrays from which the defined array can be obtained. Data "defines" an image when the data includes sufficient information to produce the image. For example, a two-dimensional array can define all or any part of an image, with each item of data in the array providing a value indicating the color of a respective location of the image. If a two-dimensional array or other data defines an image that includes a character, the array or other data also defines the character. A "character-size array" is a two-dimensional array that defines only one character or character-size element. Data defines a text "in image form" when the data defines a set of one or more images that together include the text. For example, the text may appear on a series of pages of a document, and may be defined in image form by data defining an image of each page of the document. Each location in an image may be called a "pixel." In an array defining an image in which each item of data provides a value, each value indicating the color of a location may be called a "pixel value". Each pixel value is a bit in the "binary form" of the image, a grey-scale value in a "grey-scale form" of the image, or a set of color space coordinates in a "color coordinate form" of the image, the binary form, grey-scale form, and color coordinate form each being a two-dimensional array defining the image A "version" of a first image is a second image produced using data defining the first image. The second image may be identical to the first image, or it may be modified by loss of resolution, by changing the data defining the first image, or by other processes that result in a modified version. A "view" of an image is a version of the image that is displayed to a user; a view can omit some details of the image or can be otherwise modified. A "connected component" or "blob" is a set of pixel values within a data array defining an image, all of which are connected to each other through an appropriate rule such as that they are neighbors of each other or are both neighbors of other members of the set. A connected component of a binary form of an image can include a connected set of pixel values that have the same binary value, such as black. A "connected component set" or "component set" is a set of connected components that are treated as a unit. A character can therefore be a component set; for example, the letter "i" includes two connected components that are treated as a single character in English text--the connected components "form" the character. A "bounding box" for a character or other component set is a rectangle just large enough to include all the pixel values in the component set, and can be specified by coordinates. The data used to produce a modified version of an image that includes text can include information about a character in the text. "Identity information" about a character is information indicating its character type, case, typeface, point size, or the like. To "recognize" a character means to obtain identity information about the character from a two-dimensional array defining an image that includes the character. "Spatial information" about a character is information indicating its spatial characteristics, such as its size, shape, position, orientation, alignment with other characters, or the like. Although spatial information and identity information are not completely independent, spatial information about a character can be obtained from a two-dimensional array defining an image without recognizing the character. A "data processing system" is a system that processes data. A "data processor" or "processor" is any component or system that can process data, and may include one or more central processing units or other processing components. An "image input device" is a device that can receive an image and provide a signal defining a version of the image. A "scanner" is an image input device that receives an image by a scanning operation, such as by scanning a document. A "user input device" is a device such as a keyboard or a mouse that can provide signals based on actions of a user. The data from the user input device may be a "request" for an operation, in which case the system may perform the requested operation in response. An "image output device" is a device that can provide an image as output. A "display" is an image output device that provides information in visual form, such as on the screen of a cathode ray tube. A processor "accesses" a data structure by any operation that retrieves or modifies data included in the data structure, such as by reading or writing data at a location in memory that is included in the data structure. A processor can be "connected for accessing" a data structure by any combination of connections with local or remote memory or input/output devices that permits the processor to access the data structure. A processor performs an operation or a function "automatically" when it performs the operation or function independent of concurrent human control. B. General Features Figs. 1-5 illustrate general features of the invention. Fig. 1 illustrates stages in a spelling correction operation that includes replacing a word with a new word formed of new characters. Fig. 2 shows general steps in providing a new character. Fig. 3 shows more detailed steps in obtaining data defining a new character. Fig. 4 shows more detailed steps in including a new character in data defining a modified version of a text in image form. Fig. 5 shows components of a system that can perform spelling correction by replacing a word with a new word formed of new characters. Box 10 in Fig. 1 shows an image region that includes a line of text with the words "it's one wird world." This image region can be scanned to obtain a two-dimensional array of data in which each item of data is a binary value or other digital value indicating a respective location in the image region. Character recognition techniques can obtain information from the two-dimensional array including identity information indicating the identities of characters in the image region and spatial information such as the positions of characters, of words, and of lines of text in the image region. Furthermore, spell-checking techniques can determine that word 12, spelled "wird," is a misspelled word. Upon determining that word 12 is incorrect, a number of alternative suggested correct spellings can be presented to a user on an image output device such as a display, as shown in box 20. The user can then provide a signal, with a user input device such as a mouse, indicating that one of the alternatives should replace the incorrect word. In box 20, the user selects word 22, spelled "weird," by positioning pointer 24 on it and providing an appropriate signal such as a mouse button click. At this point, the system begins several automatic steps, each of which obtains data defining one or more of the characters of word 22 from the two-dimensional array defining the image region. The step in box 30 finds data defining character 32, a "w," data defining character 34, an "r," and data defining character 36, a "d." This step can also obtain spatial data for each character indicating its size and position in relation to baseline 38. Similarly, the step in box 40 finds data defining character 42, an "e," and can obtain spatial data indicating its size and position in relation to baseline 44, and the step in box 50 finds data defining character 52, an "i," and can obtain spatial data indicating its size and position in relation to baseline 54. The system then uses the data found in boxes 30, 40, and 50 to obtain data defining the word selected in box 20, as shown in box 60 Data defining word 62 includes data defining the characters "w," "e," "i," "r," and "d" in substantially the same way as characters 32, 42, 52, 34, and 36, respectively, are defined. Data defining the characters could be included in a two-dimensional array for the word such that the characters are appropriately positioned, both in relation to each other along the direction of the line and in relation to baseline 64 in a direction transverse to the line. Finally, in the step shown in box 70, the system uses the data defining word 62 and the original two-dimensional array to obtain data defining a modified version of the text in which word 12 has been replaced by word 72. The data defining the modified version of the text includes data defining word 72 in substantially the same way as it is defined by the data defining word 62. As part of this step, the system makes the necessary adjustments in interword spaces 74, 76, and 78 so that word 72 is appropriately spaced from adjacent words. The interword spaces may also be adjusted to maintain justification of the line of text. The steps in Fig. 2 show more generally how a new character is provided according to the invention. The general step in box 90 automatically obtains data defining a character in the data defining a first version of a text in image form. This step can be performed by finding data defining the character in a two-dimensional array defining an image region that includes the text, as in boxes 30, 40, and 50 in Fig. 1, and by automatically obtaining a two-dimensionally array that defines the character or data defining such an array. The general step in box 92 produces data defining a second version of the text in image form, modified to include a new character. The step in box 92 uses the data defining the character so that the new character is defined in substantially the same way as the data found in box 90 defines the character that was previously present in the text, as in box 70 in Fig. 1. Fig. 3 illustrates in more detail how the general step in box 90 could be performed automatically. The step in box 100 operates on data defining a text in image form to obtain identity data indicating the character types of characters in each word in the text, and word spatial data indicating the position of each word. The step in box 102 then begins an iterative loop that handles words in the text; this loop can continue until it obtains one or more needed characters or until all the words have been handled. The words could be handled in an order that promotes efficiency, such as by starting with the words that have the largest number of the needed characters or by starting with the shortest words that include at least one of the needed characters. The step in box 104 uses the word spatial data indicating the position of the next word, and the data defining the text, to obtain a two-dimensional array that defines the word. The step in box 106 then analyzes the word's two-dimensional array to find the connected components within it. The connected components are grouped into sets according to an appropriate rule and the component sets are counted in box 108. The test in box 110 determines whether the count of component sets from box 108 is the same as the number of characters indicated by the identity data obtained in box 100. If not, at least one of the characters is likely to be poorly formed, so the characters are not used. If the count is the same as the number of characters, the step in box 112 finds data defining each character in the word by obtaining a respective two-dimensional array that includes each component set from the word's two-dimensional array; this step also obtains character spatial data indicating the position of each character's respective two-dimensional array in relation to the word's baseline. The step in box 114 uses the identity data for the word to determine the character type of each character's two-dimensional array and updates the stored arrays for those character types; for example, the new array could be added to the stored arrays if it is different from all of them, or its spatial data could be used to indicate an additional occurrence of a previously encountered array that is substantially the same as the new array. When all the words in the text have been handled in this manner, the step in box 120 returns the stored arrays for the character types. This step makes the arrays available for use in subsequent operations. Fig. 4 illustrates in greater detail how the general step in box 92 in Fig. 2 could be performed by replacing a word in the text with a new word formed from new characters. The step in box 140 begins with the new word's character types. The step in box 142 begins an iterative loop that handles each of the types until a two-dimensional array defining the word has been produced. For each type, the test in box 144 determines whether any character arrays are available for that type, such as stored arrays from the step in box 120 in Fig. 3. If no character arrays are available, the step in box 146 provides an error signal indicating that an array for the word could not be produced. But if character arrays are available, the step in box 148 selects an array that defines a character of that type that is suitable for the new word. When an array for each of the types has been selected in this manner, the step in box 150 produces a two-dimensional array for the new word using the selected character arrays. The step in box 150 can be performed by including in the new word's array data defining each character in substantially the same way as it is defined by the selected character array. The data defining each character can be positioned within the new word's array so that the character is appropriately positioned in relation to the other characters of the word and in relation to a baseline. When the new word's two-dimensional array is completed, the step in box 152 produces a new array defining an image that includes all or part of the modified version of the text. This step can include omitting data defining a word being replaced, including data defining the new word in substantially the same way as it is defined by its two-dimensional array, and positioning the data defining the new word and data defining other words in the same line to adjust the line's interword spaces. The step in box 154 then returns this new two-dimensional array as part of the data defining the modified version of the image. Fig. 5 shows components of system 200 that can perform spelling correction by replacing a word with a new word formed of new characters as described above. System 200 includes processor 202, which could have any appropriate architecture. Processor 202 is connected for receiving signals from image input device 204, which could be a scanner, and user input device 206, which could be a keyboard with a mouse. Processor 202 is also connected for providing signals to image output device 208, which can include a display. Processor 202 is also connected for accessing program memory 210 and data memory 230 Program memory 210 holds a number of routines executed by processor 202 in performing spelling correction with character insertion. Data memory 230 holds a number of data structures that are produced or used during execution of the routines in program memory 210. In executing image input routine 212, processor 202 produces first version data 232 from signals received from image input device 204; first version data 232 includes data defining a first version of a text in image form Processor 202 can execute character recognition routine 214 to obtain recognition results data structure 234, which can include identity data indicating the character types of characters in the text and spatial data indicating spatial information about the characters or words such as position, shape, and size. Processor 202 can execute spelling correction routine 216 using spelling correction data structures 236 to find misspelled words in recognition results data structure 234 and to present alternative correct words to the user for selection; spelling correction data structures 236 can include a word list or other data structure for checking spelling, rules or other data for generating a set of alternative correct words, and an image output data structure used in presenting the alternative correct words to the user with image output device 208. When the user selects one of the correct words with user input device 206, spelling correction routine 216 can call word array subroutine 218, which in turn calls character array subroutine 220 to obtain character arrays 238 automatically including arrays for the characters in the selected correct word. Word array subroutine 218 then produces array 240 for the selected word. Spelling correction routine 216 can then call replacement subroutine 222 to produce second version data 242 defining a second version of the text that includes data defining the word as defined by the word's array 240. C. An Implementation The invention could be implemented in many ways using a variety of processors. Fig. 6 shows components of a multiple processor implementation that takes advantage of software available for each processor. Fig. 7A shows an image of text, and Fig. 7B shows an image of the same text after spelling correction with the implementation of Fig. 6. Fig. 8 shows steps in producing a data structure for performing spelling correction based on recognition results. Fig. 9 shows steps in performing spelling correction using the data structure produced in Fig. 8. Fig. 10 shows steps in typesetting a word in Fig. 9. Fig. 11 shows steps in replacing a word in Fig. 9. System 250 in Fig. 6 includes scanner 260 connected to provide its output to personal computer (PC) 262. PC 262, which can be an IBM PC or a compatible processor, executes image file routine 264 to produce image file 270 defining a version of the image scanned, which could be a page of text, for example. Image file 270 can be in an appropriate format for subsequent processing. Sun workstation 272 accesses image file 270 in executing optical character recognition (OCR) routine 274, and produces recognition results data structure 276. Recognition results 276 can include identity data indicating the character types in each word, word spatial data indicating the position of each word and the position of the word in relation to a baseline, and other data as provided in the UA format by Kurzweil or Accutext OCR software available from Xerox Imaging Systems, Sunnyvale, California. Symbolics workstation 280 accesses image file 270 and recognition results 276 in executing spelling correction routine 282 to produce modified image file 284. Figs. 7A and 7B show results obtained by Symbolics workstation 280 in the implementation of Fig. 6. Fig. 7A is a view of an image that includes text, with circled words 292, 294, and 296 misspelled. Fig. 7B is a view of a modified version of the image in Fig. 7A produced by Symbolics workstation 280, showing that words 292, 294, and 296 have been replaced with new, correctly spelled words formed from new characters defined by character arrays found elsewhere in the image The effectiveness of system 250 depends, of course, on a number of factors: The accuracy obtained with OCR routine 274 will determine whether the words being corrected are genuine misspellings or misspellings introduced by the recognition process. The power of spelling-correction routine 282 will determine whether the potentially incorrect words are in fact incorrect and whether all incorrect words are detected. The contents of the scanned image will determine whether all the characters needed to provide a given correct word are available. The presence of more than one font on a page may result in the insertion of an inappropriate character unless the user is given an opportunity to approve the insertion before it is made or to select the best one of a number of available character arrays for insertion. Despite these limitations, Figs. 7A and 7B show that system 250 can successfully correct incorrectly spelled words by replacing them with new words formed from new characters. Fig. 8 shows steps taken by Symbolics workstation 280 in producing a data structure on which it can perform spelling correction. The step in box 300 receives recognition results 276 in a format such as the Kurzweil UA format. The step in box 302 produces from recognition results 276 an initial word list data structure that includes substantially all the information about each word that can be obtained from recognition results 276 except whether it is correctly spelled. The initial word list data structure includes a data unit for each word in the text. The data unit for each word in the word list data structure can include respective fields for the word's string of characters, spatial data indicating the position and shape of the word's bounding box and the position and tilt of its baseline, a spelling flag indicating whether it is spelled correctly, a last word flag indicating whether it is the last word on a line, a soft hyphen flag indicating whether it is the start of a word that is hyphenated and extends to the next line, and pointers to the next word and the previous word. All of these fields except the spelling flag are filled in the step in box 302, and can be filled based on straightforward computations from recognition results 276. The spelling flag of each data unit can take one of three values--T, indicating that the word is correctly spelled; NIL, indicating that the word is incorrectly spelled; and UNKNOWN, indicating that the spelling flag has not yet been set. All of the spelling flags are initialized to the value UNKNOWN in the step in box 302. The step in box 310 begins an iterative loop that handles each of the word data units in the initial word list from box 302. This loop begins with a test in box 312 that checks whether the spelling flag of the next word's data unit has the value UNKNOWN If not, it has already been set, so that the routine proceeds to the next word by repeating the test in box 310. If the word's spelling flag has the value UNKNOWN, the routine branches in box 314 based on the word's soft hyphen flag. If the soft hyphen flag indicates that the word does not extend to the next line, the step in box 316 calls a spell checking subroutine to check the spelling of the word. The spell checking subroutine can access a word list to determine whether the word is correctly spelled. The step in box 318 then sets the spelling flag to T or NIL based on the result returned by the spell checking subroutine. If the soft hyphen flag indicates that the word does extend to the next line, the step in box 320 tests whether there is a word on the next line using the next word pointer of the word currently being handled. The spatial data field of the next word can be used to determine whether the next word is positioned on the next line from the word being handled. If there is no next word or if the next word is positioned so that it is not on the next line, the step in box 322 sets the spelling flag of the word currently being handled to NIL. If there is a next word positioned on the next line, the step in box 324 appends the next word to the word currently being handled to form a combined word, and the step in box 326 calls the spell checking subroutine to check the spelling of the combined word. The step in box 328 then sets the spelling flags both of the word currently being handled and of the next word based on the result returned by the spell-checking subroutine. When all the words have been handled in this manner, the routine returns the completed word list data structure in box 330. Fig. 9 shows steps performed by Symbolics workstation 280 in correcting spelling using the completed word list data structure from Fig. 8 and image file 270. The steps in Fig. 9 can be performed in response to a user request for spelling correction. The step in box 350 begins an iterative loop that handles each word's data unit in the word list data structure. The step in box 352 branches based on the spelling flag of the word being handled. If the spelling flag indicates that the word is correctly spelled, the routine returns to the step in box 350 to handle the next word. When a word is found whose spelling flag indicates that it is not correctly spelled, the step in box 354 calls a subroutine to obtain alternative spellings such as the function zwei:get-all-corrections in Symbolics Lisp. This function provides alternative spellings of a string of characters. The incorrect word and its alternative spellings are then presented to the user on the display. The step in box 360 then branches on the user's response. If the user provides no response, indicating that the word need not be changed, the routine returns to the step in box 350 to handle the next word. When the user selects one of the alternative spellings or types in another spelling to replace the incorrect word, the step in box 362 prepares a two-dimensional array for the word indicated by the user. This step can be thought of as analogous to typesetting, because it is based on character arrays found elsewhere in the image. Then, the step in box 364 replaces the incorrect word with the newly typeset word to obtain a two-dimensional array defining a modified version of the image. This array can be stored in place of image file 270. When all the words have been handled in this manner, the routine ends. At this point, the array in image file 270 can be printed, displayed, or stored, as appropriate to the user's needs. Fig. 10 shows in more detail how a word is typeset in box 362 of Fig. 9. The routine of Fig. 10 is called with the character types of the word to be typeset, in box 380. The step in box 382 begins an iterative loop that handles each of the character types. The step in box 384 begins the iterative loop by testing whether the previous operations have saved a two-dimensional array and coordinate data, referred to in Fig. 10 as a "model," for the character type being handled. If so, the step in box 386 saves the model for subsequent use in typesetting, selecting from the models for that character type if more than one have been saved. If no models are saved, the step in box 390 calls a subroutine resembling that in Fig. 3 to find a word that includes an instance of the character type. The subroutine called in box 390 can begin by finding all the words in the word list data structure that it has not previously handled. The unhandled words could be sorted according to whether they include the character type being handled or in other ways to optimize the operation, such as by sorting the words according to the number of the needed character types they contain. Then each word could be handled as in boxes 104, 106, 108, and 110 in Fig. 3 until one is found for which the number of connected component sets equals the number of characters. If no such word can be found, the step in box 392 provides an error signal. But when such a word is found, the step in box 394 obtains a model for each of its character types, including the character type being handled, by saving a two-dimensional array and coordinate data for each character in the word. The coordinate data for each character's two-dimensional array can be obtained using the word's bounding box coordinates and baseline data. The model for the character type being handled is then saved for typesetting in box 386. When a model has been saved for each character type, the step in box 396 uses the models and data about the word being replaced to produce the new word's two-dimensional array. This can be done, for example, by first setting up an empty array of the correct size. The position of each character's array in the word's array can then be calculated, and the character arrays can be copied into the empty array to produce the word array. The width of the empty array can be determined based on the widths of the character arrays and of the intercharacter spaces. The spacing between characters can be obtained from the word being replaced, using a tight bounding box; the width of the models for the characters in the word being replaced can be added to obtain a total character width, and the difference between the bounding box width and the total character width can be divided by the number of intercharacter spaces to obtain an intercharacter space width for the new word. The height of the empty array can be determined using the maximum height above baseline of the character arrays, which is also used to determine the height above baseline of the word, and the maximum total height of the character arrays, adjusting for the replaced word's tilt as indicated by its coordinate data. When the word's array is produced, it is returned, together with its coordinate data, in box 398. The coordinate data for the new array can include its width, its height, height from baseline, and the position of each character within it. The new array and its coordinate data can then be used in a replacement operation. Fig. 11 shows in more detail how a word is replaced in box 364 of Fig. 9. The step in box 400 receives a call that includes the part of the word list data structure that defines the line with the word to be replaced. This part of the data structure can be obtained based on the end-of-line flags. The call also includes data indicating which word is to be replaced, and the new word's array and coordinate data. Using the spatial data from the word list data structure, the step in box 402 accesses the image file and copies the data defining each word on the line into a respective slot in a word copy data structure. Then, this step deletes the data defining each word on the line, which can be done by a BitBlt operation that loads white into the part of the image file in the word's bounding box. The step in box 404 then replaces the word being replaced in the word copy data structure, putting into its respective slot the array of the new word. The step in box 406 adjusts the interword spaces to accommodate the new word, by determining the excess width in the line and spreading it equally among the interword spaces by changing the spatial data of the words on the line. Then the step in box 408 goes through the part of the word list data structure and the word copy data structure, updating the word list data structure for each word on the line and including the array for each word in the image file, which can be done by a BitBlt operation for each word. The result is a data structure in the image file that defines a modified version of the image in which the new word has been included by replacement. The implementation described above can also include a preliminary test of whether a word identified as misspelled is misrecognized. This can be done by obtaining models for each character of the word as recognized and convolving them with their approximate locations in the image. If at least one of the models does not match the image, because its convolution score is below a threshold, this indicates that the recognizer made a mistake, and the word can be treated as correctly spelled in the image. Convolution here means an operation of holding a binary mask at a particular alignment with a binary image and summing the number of black/black and white/white correspondences to obtain a score. This can be repeated at many possible alignments, and the best score can then be used. If a character is needed for which no model is available, perhaps because it does not occur in the image, it may be possible to use a stored letter model, perhaps degraded to eliminate distinguishing features of its font, or to somehow synthesize a model from pieces of other letters found in the image. The invention could be implemented in a copying machine to provide a spelling correction capability. Rather than presenting alternative spelling corrections on an electronic display, they might be printed on paper; the user could then select one by marking it or the other alternatives appropriately and by feeding the paper back into the machine for recognition of which alternative was selected. The user could cross out the non-selected alternatives or circle or highlight the selected alternative. This technique would eliminate the need for additional user interface devices such as a CRT, keyboard, and mouse. The word list used in checking spelling could be specialized to the user of the copier, and a learning mode could be provided by which the user could construct a specialized word list. Adaptive spelling correction techniques are described in US-A-4,797,855. A set of permanently-stored fonts could be used in conjunction with the invention, so that characters from the permanently-stored fonts could be included in an image when appropriate. For example, all the characters in an image could be replaced by characters from one of the stored fonts. D. Miscellaneous The invention might be implemented by copying a character directly from the two-dimensional array defining a first version of a text in image form into an array defining a second version of the text, making it unnecessary to store a two-dimensional array of each character. Before presenting alternative spellings of a misspelled word, a system according to the invention might check first whether each alternative could be produced from available character models An alternative that could not be produced need not be presented to the user The invention might be used with character recognition software that provides data indicating each character's position. The character position data could then be used to allow character replacement. This might be problematic, however, for characters with overlapping bounding boxes and for poorly formed characters. Rather than modifying the array stored in the image file, the invention might be implemented to produce a data structure with pointers into the image file. This data structure would define a modified version of the text. The invention might be applied to a text that spans several pages, such as the text of a document. Specifically, a character might be found on one page and used to add a new character on another page The invention has been described in terms of replacing a word in a text or replacing a line of text with a line of the same length The invention might also be implemented to replace a number of lines to the end of a paragraph or the end of a page, or to replace all the lines on a page where a change in the text requires it. The invention might also be implemented to hyphenate a word where necessary. The invention has been described in relation to English text, but could be implemented for text of many other languages.

Claims: A method of changing characters in text in an image; the method comprising: holding first text image data (232; 270) in memory (230); the first text image data (232; 270) defining a first version of a text in image form, the first version of the text including a first character (32, 34, 36, 42, 52) that is an instance of a first character type; and operating processing means (202; 262, 272, 280) connected for accessing the memory (230) to produce second text image data (242; 284) using the first text image data (232; 270), the second text image data (242; 284) defining a second version of the text in image form with a second character that is an instance of the first character type, characterised in that the processing means (202; 262, 272, 280), in producing the second text image data (242; 284): operates on the first text image data (232; 270) to find the first character (32, 34, 36, 42, 52) in the first version of the text and to obtain first character data (238) defining the first character (32, 34, 36, 42, 52) in substantially the same way as it is defined by the first text image data (232; 270); and uses the first text image data (232; 270) and the first character data (238) to produce the second text image data (242; 284) with the second character defined by the second text image data (242; 284) in substantially the same way as the first character (32, 34, 36, 42, 52) is defined by the first character data (238). The method of claim 1, in which the first character data (238) is a two-dimensional array that defines the first character (32, 34, 36, 42, 52) in substantially the same way as it is defined by the first text image data (232; 270). The method of claims 1 or 2, wherein the processing means (202; 262, 272, 280), in operating on the first text image data (232; 270), executes routines (214, 216; 274, 282) in a program memory (210) to find the first character (32, 34, 36, 42, 52) and to obtain the first character data (238). The method of claim 3, wherein the processing means (202; 262, 272, 280), in executing the routines (214, 216; 274, 282): obtains character recognition results data (234; 276) indicating character types of characters and spatial data in said first text image data (232; 270), finds an incorrect word (12), and presents alternative correct words. The method of claim 4, wherein the processing means (202; 262, 272, 280), in producing the second text image data (242; 284): receives a user signal selecting an alternative correct word (22, 62, 72) which is presented to a user on an image output device (208); and in response to the user signal, executes further routines (218, 220) in program memory (210), said further routines obtaining arrays for the characters (32, 34, 36, 42, 52) in the selected correct word (22, 62, 72), producing an array for the selected correct word, and producing the second text image data (242; 284). The method of claim 5, in which the processing means (202; 262, 272, 280), in producing the second text image data (242; 284), modifies the first text image data (232; 270) to produce the second text image data (242; 284). The method of claim 2, in which the processing means (202; 262, 272, 280), in operating on the first text image data (232; 270), obtains a first character two-dimensional array that defines the first character (32, 34, 36, 42, 52) in substantially the same way as it is defined by the first text image data (232; 270). The method of claim 7, in which the processing means (202; 262, 272, 280), in operating on the first text image data (232; 270): identifies an incorrect word (12) in the text; presents an alternate correct word (22, 62, 72) on an image output device (208); receives a user signal selecting the correct word (22, 62, 72); and in response to the user signal, produces the second text image data (242; 284) with said correct word (22, 62, 72) therein, the correct word (22, 62, 72) including the second character, all characters in said correct word (22, 62, 72) being defined substantially the same way as characters of the same types are defined by the first text image data (232; 270). The method of claim 7, in which the first version of the text includes a correctly-spelled word including the first character (32, 34, 36, 42, 52), the processing means (202; 262, 272, 280), in obtaining the first character two-dimensional array: obtaining an intermediate two-dimensional array of data defining the correctly-spelled word in substantially the same way as it is defined by the first text image data (232; 270), and obtaining the first character two-dimensional array from the intermediate two-dimensional array. The method of claim 9, in which the processing means (202; 262, 272, 280), in obtaining the first character two-dimensional array from the intermediate two-dimensional array: finds connected components in the intermediate two-dimensional array, groups the connected components into a number of sets, and determines whether the number of sets is equal to a number of characters in the correctly-spelled word. A data-processing system (200; 250) comprising: processing means (202; 262, 272, 280); and memory (230) connected for being accessed by the processing means (202; 262, 272, 280); the memory (230) storing a first data structure (232; 270) that includes first text image data defining a first version of a text in image form, the text including a first character (32, 34, 36, 42, 52) that is an instance of a first character type; the processing means (202; 262, 272, 280) operating to produce second text image data (242; 284) using the first text image data (232; 270), the second text image data (242; 284) defining a second version of the text in image form with a second character that is an instance of the first character type, characterised in that the processing means (202; 262, 272, 280), in producing the second text image data (242; 284): operates on the first text image data (232; 270) to find the first character (32, 34, 36, 42, 52) in the first version of the text and to obtain first character data (238) defining the first character (32, 34, 36, 42, 52) in substantially the same way as it is defined by the first text image data (232; 270); and uses the first text image data (232; 270) and the first character data (238) to produce the second text image data (242; 284) with the second character defined by the second text image data (242; 284) in substantially the same way as the first character (32, 34, 36, 42, 52) is defined by the first character data (238).

Inventors: BAGLEY STEVEN C, DAVIES DANIEL, HICKS WAYLAND R, KAPLAN RONALD M, BAGLEY, STEVEN C., DAVIES, DANIEL, HICKS, WAYLAND R., KAPLAN RONALD M.
Applicants: XEROX CORP, XEROX CORPORATION
Application year: 1990
Main classification: G06T11
IPC codes: G06F17, G06T11, G06K9