The present invention relates generally to image processing. More particularly, the present invention relates to a method and system for identifying contours within pixel-based image data. The identified contours may be used, for example, to identify circled regions on a scanned document, allowing the image processing system to extract content within the circled region to index the document or perform other processing tasks based on the information.
There is considerable interest today in intelligent, automated document imaging systems that can store and retrieve scanned documents and other pixel-based image data with minimal document coding by the user. In a conventional document imaging system, the scanned image is displayed on the computer screen, and the user may highlight a portion of the scanned image from which indexing information may be extracted. For example, the user could highlight the caption of a scanned newspaper article. The caption is processed through optical character recognition (OCR) and then used as an index or label for that scanned image. The index or label is used to later retrieve the scanned newspaper clipping.
While the use of the computer display to highlight relevant portions of a document works well in some applications, there are other applications where physical interaction with the computer screen is not convenient. In such instances, it may be more convenient for the user to simply encircle the region of interest on the hard copy document prior to scanning it into the system. In other words, the user would use a pencil or pen to draw a circle around the region of interest, and the image processing system would then identify the user's hand-drawn circle, extract and process the text within the circled region, and use it for indexing or document processing purposes.
Identifying a circled region within the pixel-based image data of a scanned document is a fairly challenging problem. Traditional algorithms for identifying circled regions attempt to identify connected components that have a profile of attributes indicating that they might constitute a circled region.
Traditionally, a connected component comprises a collection of black, contiguously adjoining pixels. Depending on the algorithm used, adjoining pixels are those that lie in the immediate neighborhood surrounding a given pixel, typically either the four pixels arranged like points a compass, or the eight pixels including those four plus diagonals. When a conventional connected component analysis is performed, the scanned image may contain a number of connected component candidates which could represent a user-drawn circle. Post processing algorithms are performed on the connected component data to rule out those that are too small, and thus more likely to correspond to individual letters or noise data. Post processing algorithms also examine the connected component data to determine if there is closure within a given connected component. In this way, closed circles are identified and other markings such as marginal lines or underlining are eliminated.
While conventional connected component analysis does a reasonably good job of identifying potential circled region candidates, the process is fairly computationally expensive. The present invention addresses this issue through a far more efficient algorithm. Instead of seeking connected components in the conventional fashion—a process that will potentially generate many candidates that each must be analyzed—the present algorithm uses a single data structure that is populated with run length information as the image is being scanned. As will be more fully explained herein, the data structure maintains parent, child and sibling relationship information about each “run” of contiguous pixels within a given scanned row. The parent, child and sibling information is then traversed to identify contours that represent closed circles of suitable size. The run length algorithm thus eliminates the need to painstakingly explore each pixel to its neighboring pixels in the conventional connected component fashion. Moreover, although the algorithm is well suited for identifying circled regions, in its more general case, the algorithm can be used to identify a variety of different contours that meet a set of predefined criteria. Also, while the present “black-and-white” embodiment seeks to identify runs of contiguous black pixels, the algorithm can readily be extended to accommodate gray scale and color pixel image data as well. In such applications, the system merely needs to identify which pixel states or pixel values (e.g., shades or colors) may constitute a member of a run, and the algorithm will identify contours made up of pixels having any of the identified states or values.
According to one aspect of the invention, the method for identifying contours within pixel-based image data comprises expressing the image data as a grid of columns and rows. A scan order is then established over the grid to define parent-child relationships between contiguous pixels in adjacent rows and sibling relationships among non-contiguous pixels in the same row. A run data structure is established in the computer-readable memory that defines a run member by its row position and by its starting and ending column positions. The run data structure further defines parent, child and sibling structures for storing information about these relationships.
As the image data is scanned according to the scan order established above, the processor identifies contiguous pixels of a predetermined state as identified run members. It also determines the parent-child and sibling relationships of the identified run members. This information is populated into the run data structure with the row position and starting and ending column positions of the identified run member and with the parent-child and sibling relationships of the identified run member. The populated data structure is then traversed by following the parent-child and sibling relationships to identify contours within the pixel-based image data. If desired, once the contours have been identified, additional processing can be performed to improve the likelihood that the identified contour represents a user-drawn circle. These additional processing aids discriminate between one user-drawn circle from another, when two circles overlap. The additional processing involves computing feature points along the contour and then breaking the contour into segments at the feature points. The broken contours are then used to generate reconstructed circles, each having its own identity and thus each being separate from other circles which it may overlap.
For a more complete understanding of the invention, its objects and advantages, refer to the following specification and to the accompanying drawings.
The run length based method of the preferred embodiment scans image data in a pre-established scan order to identify parent, child and sibling structures within the image data. In this regard, the image data may be expressed as a rectangular grid 10 of columns and rows comprising individual pixels that are represented in
As will be more fully explained below, the processing algorithm scans the grid of pixel data in a predetermined scan order. For illustration purposes, it will be assumed that the scan order is from top to bottom and from left to right. Thus the grid 10 would be scanned beginning at pixel 14 in the upper left-hand corner and ending with pixel 16 in the lower right-hand corner.
The algorithm is designed to identify and correlate groups of adjacent pixels that define a linear string termed a run or run length. The scanning process groups pixels of a predetermined state together to form run lengths within the image.
The preferred embodiment considers run lengths to be defined by a collection of contiguous pixels of a predetermined state (e.g., the black pixel state in a black-and-white image). Three such run lengths 20, 22, and 24 are illustrated in
Individual pixels (such as the black pixels in
The scanning algorithm and the associated data structure of
The scanning algorithm and its associated data structure 30 also define a sibling relationship between two run lengths that lie on the same row and share the same parent, such as run lengths 22 and 24. The scanning algorithm automatically detects sibling relationships and stores them in data structure 30, as will be more fully described in connection with
The presently preferred run data structure 30 defines each run length 34 by its associated x-minimum value 36, x-maximum value 38 and y-coordinate value 40. The run length data structure also has associated with it a parent pointer 42, a child pointer 44 and a sibling pointer 46. The parent, child and sibling pointers 42-46 establish a linked list of the run length data structures. The scanning algorithm populates this data structure as it visits each pixel in grid 10. In the preferred embodiment a single, multiple linked list is populated with individual run length data structures 34 corresponding to each run length identified by the scanning algorithm.
The relationship of scan lengths k, j and s are shown diagrammatically at 50 for convenience. The scanning algorithm begins at step 60 by scanning the image in the predetermined scan order, searching for occurrences of run lengths. As discussed above, run lengths are identified as contiguous pixels in a common row that have the same pixel state (e.g. contiguous black pixels). The preferred scanning algorithm is recursive. For each run length identified (such as run length ′j) the following process is performed.
If, as illustrated at step 62, the identified run length (j) is vertically adjacent to a run length (k) from a previous row, then the current run length's parent data structure (j's parent data structure) is populated with a reference to the vertically adjacent run length (k), as shown at 64. The scanning algorithm then tests k's child data structure at step 66 to determine if it is currently empty (containing a null value). If a null value is found, the algorithm populates k's child data structure with a reference to scan length j, as illustrated at 68. If k's child data structure is not currently empty (in other words if it contains a reference to another child(s), the algorithm detects this at step 70 and then populates j's sibling data structure with the value stored as k's child(s), as shown at 72. Thus, steps 66-72 essentially test whether the child of k is null. If so, it sets j to the child of k. Otherwise it sets j as the sibling of the child of k.
In some instances the algorithm detects that the child(s) already has a sibling. In this case the algorithm sets the child as the sibling's sibling, and so on. This is shown in steps 74 and 76. When siblings are identified the algorithm sets their respective sibling pointers to each other as shown at step 72 and 78.
The scanning algorithm illustrated in
Note that the u-shaped contour in
Once the run data structure 30 has been populated by the scanning process, a connected component retrieval process is commenced. Referring to the flow diagram of
The connected components that remain are processed as follows. Beginning with the run length occupying the upper left-most corner (determined by its x-minimum, x-maximum and y-coordinate values), the process first identifies, by examining the run data structure, if that run length has a child. This is depicted at step 104 and also illustrated in the connected component retrieval diagram of
While the procedure described so far is well adapted at identifying connected components found in pixel-based images, some image processing tasks, such as identifying circled regions, benefit by further processing. Specifically, the presently preferred embodiment converts the connected component into a contour, which may then be used to generate new structures that are more easily and reliably processed. In an application where user-drawn circles are identified so that the encircled region can be extracted, the connected components are converted into contours. The contours are then used to re-generate circles that are more easily processed by the computer.
The contour following algorithm uses the same data structure that generated the connected components. namely the run data structure 30. When retrieving connected components, the algorithm recursively retrieves the child or parent of each run length. If no child or parent is found, the algorithm switches to siblings. For each sibling, the algorithm continues to search for children and parents first. The parent and child relationship ensures that the related run lengths retrieved have pixels that belong to the same contour and are next to each other in a section of the contour.
In the presently preferred embodiment the contour following algorithm defines the mid-point of each run length. The mid-point P is thus defined by its Px and Py components as follows:
The contour following algorithm assigns the mid-point at the end of a contour to be the beginning mid-point of the subsequent contour. In this way, both contours are linked together, as illustrated in
To more fully understand how the run length based connected component analysis may be used in an application, refer to the flow diagram of Figure 9.
Beginning at step 200, the procedure first pre-processes the image to convert the image data into suitable resolution and bit-depth for connected component analysis. This is an optional step that may be performed, for example, to convert color image data into black-and-white data or to convert gray scale data into black-and-white data.
The procedure next proceeds to step 202 where connected component analysis is performed using the run length analysis techniques described above. If desired, at step 204, half-tone data may be eliminated and small gaps in pixel data (attributable to noise) may be eliminated. Individual white pixels in an otherwise black pixel domain may be converted to black pixels to “fill in” or de-speckle the image data.
After the connected components have been identified and the run data structure populated, the process advances to step 206, where contour segment information is extracted from the data. The contour segment extraction process is performed as described above, resulting in one or more connected contours, such as the connected contour shown in
Various alterations to the scanning algorithm can be made that fall within the scope of the present invention. For example,
In some instances the algorithm will detect that the child (s) already has a sibling. In this case the algorithm checks whether (s)'s sibling has a sibling, and so on. This is shown in steps 170 and 172. When a null reference is finally reached at 170, the null reference is replaced with a reference to (j) as shown at step 174.
The description of the invention is merely exemplary in nature and, thus, variations that do not depart from the gist of the invention are intended to be within the scope of the invention. Such variations are not to be regarded as a departure from the spirit and scope of the invention.
This application is a continuation-in-part of U.S. patent application Ser. No. 09/773,214 filed on Jan. 31, 2001, the disclosure of which is incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
Parent | 09773214 | Jan 2001 | US |
Child | 11108168 | Apr 2005 | US |