Method of measuring skew angles

Abstract: Skew angle of an image is determined based on determination of location of fiducial points on the image. Fiducial points may be located through a comparison of the scanning of a first line with scanning of a subsequent line. These fiducial points may be defined in terms of pixel color transitions located on a first scan line without a corresponding transition on the succeeding scan line. Skew angle may be determined from image data in uncompressed form or in compressed form. Where skew angle is determined from image data in compressed form, the two-dimensional CCITT facsimile recommendations may be used. In such cases, the locations of the fiducial points may be taken as the locations of the pass codes of the compressed image data. Specifically, pass codes indicating a pass of white pixels are used.

Description: The present invention relates generally to a method for detecting skew present in a scanned image, and more specifically to a method of detecting skew of an image which is based on a count of certain features of the image and in which the image may be represented in compressed form. The human eye can detect very small deviations from orthogonality, particularly in digital images of simple structures where the discontinuities caused by aliasing errors draw attention to these deviations. There is less information available about the human sensitivity to skewness of text and complex graphic images. When presented information in a well-defined coordinate frame, skew angle is consistently and significantly over-estimated. Presence of skew is not aesthetically pleasing and has pragmatic effects as well. Presence of skew may result in failure to capture all of the source area of the image, because one or more corners may fall outside of the field of view of the scanner because of the skew. Skewed images do not compress as quickly or as compactly as images correctly registered to the page coördinate system. Skewed fields are more difficult to utilize in standard page layout and composition operations such as cropping and inserting. Skew may arise in several ways, including difficulties in paper feeding, either at the time of digitization or prior to digitization at the time of photocopying, among others. In an electronic reprographics environment, where reproduction is effected by digital scanning and printing of the resulting bitmaps, early and accurate detection of skew angle can result in a significant reduction in the need for resources to correct for and store the skewed image. Skew angle determination is traditionally a two-stage process. First the feature on which alignment quality will be based is determined, and second, various tests are applied to determine if the proposed alignment is a good one relative to a prior sample alignment or other standard. An "alignment" as used herein is an orientation of the components of an image. To date, determination of skew angle has been accomplished on image data in uncompressed form. Herein, "image" is taken to mean a pattern or collection of distinguishable regions, whether a likeness, representation or neither, typically but not exclusively that which might be found on a printed page. "Image data" means herein data which are typically, though not exclusively, digital in format which may be used by an appropriate system to reproduce an image. Data in "compressed" format means herein data which have been reduced in extent, e.g., the amount of memory space, in bits, required to store the data, from data in "uncompressed" format, no matter what method is used to compress the data. Determination of skew angle from compressed image data has not been contemplated to date or, if it has, it has been dismissed under the general belief that performing skew detection on compressed image data would require the extra, and potentially unnecessary, step of transforming the image into compressed data format. A technique for the detection of skew angle in uncompressed images is described by Henry S. Baird in The Skew Angle of Printed Documents, Proceedings of SPSE Symposium on Hybrid Imaging Systems, pp. 21-24, 1987 (hereinafter " Baird "). Initially, Baird must distinguish between a mark or connected component that is text and one that is not text. In this regard, "text" marks or connected components for the purposes of the present disclosure are those comprised of letters, numbers, punctuation and related marks. This is as distinguished from "non-text" marks or connected components which are those not being text, typically graphics, symbols or illustration-type portions of an image. Because of the method used for locating fiducial points, Baird's technique will yield meaningful results only for text images. This classification as text is made by Baird on the basis that the maximum dimension of a text mark is less than or equal to the "em" in a predetermined maximum font size, e.g., 24 point. The alignment algorithm of Baird's technique operates on the basis of the alignment of selected features associated with each mark, or connected component. "Mark" shall be used herein to refer to a connected component. A "connected component" is defined for the purposes of this specification as a group of color-bearing units, typically picture elements ("pixels") of like color which touch one another. A feature commonly used for this purpose is the "fiducial point." A "fiducial point" as used herein is a point on or associated with a mark which is located by a predetermined set of rules (the same rules for each mark), and which may be used for selected purposes as a representation of a feature of the mark. For example, Baird uses the bottom center of a bounding box around each mark for the fiducial point. Baird's fiducial points 10 are shown as cross-hairs on bounding boxes 12 around marks 14 i n Fig. 1a of the accompanying drawings. In a perfectly aligned horizontal line of English text, for example, each fiducial point will lie on the same horizontal line 16 at the base of the characters (called the "baseline"), with the exceptions of dotted characters, for example the letter "i" of Fig. 1a, certain punctuation marks and characters with descenders, which are portions of the mark which descend below the base line, such as the lower case characters "g", "p", etc. Since a fiducial point is assigned to each connected component, the dotted characters "i "s and "j"s, and many punctuation marks (;?!:"), give rise to more than one fiducial point per glyph, with at least one of these points significantly misaligned with respect to the baseline. Characters with descenders will generate fiducial points away from, but near to, the baseline. Descenders are statistically uncommon enough for the method of Baird (and of the present invention) to provide a means for recognizing and compensating for their effect on determination of the true baseline. Note that there is exactly one fiducial point per connected component in the image. In essence, Baird calculates skew by determining the number of fiducial points per "line" for a variety of rotational alignments. 'Line' as used herein means, for example, one of a plurality of imaginary parallel scan lines traversing the document and oriented perpendicular to a selected feature such as a margin or page edge. The rotational alignments are calculated by trigonometric translation of the fiducial points. Referring to Figs. 1b and 1c of the drawings, counting of the number of fiducial points per line is accomplished by projecting the locations of the fiducial points 10 onto an accumulator line 18 which is perpendicular to the projection direction, as indicated by arrow p. Accumulator line 18 is partitioned into "bins" 20 of a uniform predetermined height, H, for example equal to 1/3 of the height of a six-point character. Height H may be varied as appropriate, and may be as small as two pixels. However, as H decreases, computation time increases. Importantly, as H approaches the character height, skew angle determination performance disintegrates. Returning to the bins, there is exactly one bin per line. The number of fiducial points for a selected line is then equal to the number of fiducial points projected into the bin corresponding to that line. Since this method results in a relatively small number of fiducial points (depending on the nature of the image), the alignment is made efficient by calculating the alignment on the basis of the sum of a positive power greater than 1, e.g., two (sum of squares) of the counts of the fiducial points which appear in each of the rotationally-aligned bins. The variance of the distribution is maximized by maximizing the sum of squares of the counts, resulting in an index of the "power" of the alignment, from which skew angle is determined. Fig. 1b shows the positions of the fiducial points 10 and the relative size of each bin 20 on a skewed text sample in which the bins are unaligned with the skewed text. Fig. 1c shows the distribution of the fiducial points of the same skewed image of Fig. 1b into aligned bins. Calculation of the power of each of a variety of alignments requires that the positions of each fiducial point be known. Specifically, the coordinates of a fiducial point are used to translate the fiducial point mathematically, by an angle and a displacement from an origin, to a new set of coordinates. This process is done for the complete collection of fiducial points, and the powers of the alignments before and after translation are compared. From each comparison, the angle corresponding to the alignment with the greatest power is retained. After all angular alignments within a selected range have been compared in this manner, the skew angle may be assumed to be the angle corresponding to the alignment with the greatest power. In the event of weak alignment or multiple alignments, however, this assumption may need to be verified otherwise. The present invention provides a method of skew angle determination, overcoming a number of known problems and shortcomings. Published international application WO89/05495 discloses a skew detector for a digital image processing system wherein each line in a frame of video data is organised into continuous runs of white pixels, and those runs having lengths below a given threshold are transformed to black pixels. The data is then organised into runs of black pixels, and the start position of the longest black pixel run is noted for each horizontal line. Skew angle is computed from the offset distance between the noted black run start positions of successive lines. The present invention provides a method of operating a processor connected for accessing a data structure defining an image as defined in claim 1 and methods for determining a skew angle of an image as defined in claims 4 and 8. In Baird's method of skew angle determination there is the problem that, as skew angle is increased, the distance between the bottom of the mark and the bottom of the bounding box may increase. This difference increases as a function of the sine of the angle of skew. This leads to the problem of errors in the count of fiducial points, which affects skew angle determination as a square of that error. This problem can be solved by determining skew angle based on fiducial points located on the mark itself. In this manner, the extent of the skew angle does not contribute to error in the determination of that angle. It has been discovered that line ends form a useful set of features on which to base skew determination. A particularly useful set of features are the line ends located at or near a baseline for horizontally-oriented images or a vertical line for vertical or columnar-oriented images. Detecting line ends in generic images has proven to be a difficult task. However, a method has been invent, and which forms another aspect of the present invention, to detect a group of features that includes the group of line ends. The set of features is limited in size such that the effectiveness of using line ends is not diminished. By comparing one scan line to a subsequent scan line, pixel color transitions may be located. Proper selection of the pixel color transitions can yield a set of features, including lines ends, which can be used very effectively to determine skew angle. Another problem of Baird's method of skew angle determination is that it involves computationally demanding methods of feature (fiducial point) location. According to Baird's method, not only must the mark be identified, but a bounding box must be constructed around the mark, and the bottom center of the bounding box must be located. This problem can be solved by determining fiducial points from a comparison of the scanning of a first line with scanning of a subsequent line. Location of fiducial points will correspond to the location of selected topographic features located on a first scan line without a corresponding topographic feature on the succeeding scan line or, alternatively, without a corresponding topographic feature located on the preceding scan line. In this regard, for the purposes of this disclosure, "topographic" feature is taken to mean a feature of a mark, image or portion thereof which is based on its geometrical configuration properties, such as shape, size, curvature, overlaps, etc. This is as distinguished from "non-topographic" features which are features of a mark, image or portion thereof not based on its geometrical configuration, but based on some other attribute such as color, shading, etc. It was recognized that Baird's methods of skew angle determination produce meaningful results only for text images. This is a result of the method used to determine fiducial point location. A bounding box is constructed around the mark and the bottom center of the bounding box is used as the fiducial point. Baird chose to construct bounding boxes around only text marks. This choice was made based on the presumption that the positions of text marks are aligned and non-text marks may not be. If bounding boxes were then constructed around non-text marks, the fiducial points yielded from the marks would appear as noise, distracting from the significant data needed to determine skew angle. From this comes the aspect of the present invention that skew angle determination may be performed on text or non-text images, or combinations of text and non-text. By basing skew determination on fiducial points located on the marks themselves, no bounding boxes need to be constructed. The fiducial points produced from non-text marks, according to this aspect, add significantly to the accuracy of the result. In this way, the limitation of the Baird method of dealing with only text is overcome. The CCITT Group 4 data compression format (hereafter referred to as "Group 4") is becoming standard for the transmission of facsimile images, for the intermediate transmission of images between workstations and servers, for the storage format on optical and magnetic media, and for other applications. Software implementations of the compression algorithm are available, as are certain special purpose VLSI hardware implementations. For example, Advanced Micro Device's 7971A processor is a dedicated circuit for data compression/decompression according to the CCITT format. It is therefore another aspect of the present invention to provide a method of skew determination which utilizes image data which has been compressed according to the Group 4 standard. Related to this aspect of the present invention, very useful results are achieved by utilizing the locations of so-called "pass codes" produced by Group 4 compression as the locations of fiducial points on which to base skew determination. It has been recognized that there are two types of passes -- passes of white pixels, and passes of black pixels. Although the CCITT Group 4 compression standard does not differentiate between these two, two further aspects of the present invention are, first, the discovery that by selecting pass codes that indicate passes of white pixels, the accuracy of skew angle determination is greatly improved, and second, the implementation of a method for distinguishing between the two types of pass codes in terms of skew angle determination. The present invention will now be described by way of example with reference to the accompanying drawings, in which: Fig. 1a shows the location of fiducial points on an unskewed image according to one method of the prior art; Fig. 1b shows the location of fiducial points on a skewed image according to said method of the prior art, together with a plot of the distribution of the fiducial points into unaligned bins; Fig. 1c shows the location of fiducial points on the same skewed image shown in Fig. 1b, together with a plot of the distribution of the fiducial points into aligned bins; Fig. 2 shows a portion of a computer system which is capable of operating according to the skew angle determination method of the present invention; Figs. 3a through 3c shows the three encoding modes of the CCITT Group 4 compression standard; Figs. 4a and 4b show the location of fiducial points based on pass codes of the CCITT Group 4 compression standard on unskewed and skewed text, respectively; Figs. 5a and 5b show the location of fiducial points based on white pass codes from the pass codes of the CCITT Group 4 compression standard on unskewed and skewed text, respectively; Fig. 6 shows a flow diagram of one aspect of the present invention; Fig. 7 shows a flow diagram of another aspect of the present invention; Fig. 8 shows a portion of skewed text used as an example of one aspect of the present invention; Fig. 9 shows the locations of the white pass codes for the sample text of Fig. 8 used to determine alignment according to the present invention; Fig. 10 shows a plot of the power of the alignments for an angle range for the sample skewed text of Fig. 8, and Fig. 11 shows a plot of power of alignments for text having multiple skew angles. The method of skew determination according to the present invention will now be described. It is particularly applicable to determination of skew in scanned images. In the present disclosure it is assumed that the image data are broken up into distinct units, preferably lines of the image. This may be accomplished, for example, by scanning the image and inserting an indication of the beginning and ending of each scan line or of the run length, as is well known. For convenience these units are hereafter referred to as 'scan lines'. With increasing prevalence, scanned images are being handled in compressed format. For example, facsimile machines operate on scanned images virtually entirely in compressed format. For this reason, the present invention is described assuming that the image data are in compressed form (also referred to herein as the compressed data domain). It will be evident to one skilled in the art, however, that the present invention is equally applicable to image data in uncompressed format. Fig. 2 illustrates in block format an environment in which the present invention may operate. Specifically, Fig. 2 illustrates a portion of a computer system 50 tailored to operate according to the present invention. Computer system 50 includes or is connected to receive output signals from a scanner 52, which is capable of scanning an image and producing digital data which represent that image. These digital data are communicated to a processor 54. This processor controls input and output operations and calls to program memory 56 and data memory 58 via bus 60. Program memory 56 may include, inter alia , a routine 62 for controlling the scanning of an image by scanner 62, a routine 64 for converting the digital data representing the image into a compressed data format, and a routine 66 for determining skew angle from the compressed data. Program memory 56 will thus have associated with it data memory 58 in which may be stored, inter alia , at location 68 the digital data structure produced by scanner 52 under control of the scanning control routine 62, at location 70 the data structure of the compressed representation of the scanned image produced by compression routine 64, and at location 72 the data structure containing selected point data, for example fiducial point location, produced by skew angle determination routine 66. To facilitate the communication between program memory 56 and data memory 58 necessary for operation, each is connected to bus 60 such that input and output operations may be performed. One additional point with regard to memories 56 and 58 is that they have been described as separate for the purposes of clarity but they, in fact, be parts of a single memory block of the computer system. Under processor control, skew detection routine 66 will access various parts of data memory 58 to acquire data needed to calculate skew angle. Once calculated, skew angle may then be output at 74, which may comprise a means for displaying the results, such as a CRT display, printer or the like, or may comprise a means for utilizing the results to perform further operations, such as modification of the image data to compensate for skewness, etc. It has been assumed that the image data have been compressed according to the Group 4 standard, although the present invention with proper modification will render similar results using other compression schemes, e.g., CCITT two-dimensional Group 3 format, etc. The coding scheme of Group 4 relies on the existence and relative spacing between pixel color transitions found on pairs of succeeding scan lines. In Group 4 coding each line in turn becomes a "coding line" and is coded with respect to its predecessor, the "reference line". The first line is coded with respect to an artificially defined all-white reference line. See Hunter, et al., "International Digital Facsimile Coding Standards," Proceedings of the IEEE, Vol. 68, No. 7, July 1980, pp. 854-867 and Int'l. Telecommunications Union, CCITT (Int'l. Telegraph and Telephone Consultative Committee) Red Book, Geneva 1985 (ISBN 92-61-02291-X) for a more detailed discussion of the Group 4 compression standard. Encoding in the Group 4 format has three modes -- vertical, horizontal and pass. These modes are described following with regard to Figs. 3a, 3b, and 3c. Adjacent scan lines are compared to determine whether, given a first pixel color transition on a reference line such as black to white, there exists a corresponding pixel color transition (i.e., also black to white) on the coding line. The existence and relative spacing of the transition on the coding line from the transition on the reference line is used to determine the mode. With reference to Fig. 3a, a vertical mode is used when the black-to-white or white-to-black transition positions on adjacent scan lines are horizontally close (≤ 3 pixels) and thus can be encoded in a small number of bits. Horizontal mode is used when the transition positions are further apart than three pixels, as shown in Fig. 3b. Pass mode is used when a transition on the reference line has no counterpart on the coding line, as shown in Fig. 3c. Compressed data then include, inter alia , a mode code together with a displacement which implies a displacement measured on the reference line as opposed to the coding line. Referring now to Figs. 4a and 4b, in place of the fiducial points located on the bounding box around a mark used by Baird, the present invention locates fiducial points 76 on the basis of the positions of topographic features of the mark. These topographic features are always located on the marks themselves. Specifically, skew is determined from the locations of the pass codes in the Group 4 compressed representation of the image. The positions of the pass code fiducial points 76 on unskewed and skewed text are shown as "x" marks in Figs. 4a and 4b, respectively. Since all pass codes are defined relative to a point on a mark, all fiducial points are located at some point on a mark, regardless of the extent of the skew. Further, because there may be more than one pass code in the compressed data representing a mark, there may be more than one fiducial point per mark. For example, for typical font styles, passes will be generated in two places along the baseline of many characters including upper and lower case "A", "H", "K", etc., and in three places along the baseline of an upper and lower case "M". Passes may also be generated as a result of aliasing errors, for example as shown on the underside of the crossbar of the unskewed "G" and on the right leg of the unskewed "K" in Fig. 4. Distinguishing such aliasing errors is beyond the scope of the present invention. However, aliasing errors in certain circumstances lead to useful and meaningful results. For example, when long horizontal structures are digitized aliasing errors frequently occur. Since the presence of these aliasing errors results in the generation of pass codes representing transitions from black to white, long horizontal lines provide a large number of such pass codes, with no ambiguity in the alignment which they represent. Thus, horizontally aligned graphical structures materially improve the determination of skew angle because of their tendency to generate aliasing errors. It should be added that large non-horizontal structures do not significantly degrade the performance of the present invention since they are not, in general, subject to aliasing errors which generate pass codes, because the aliasing errors are encoded using the Group 4 vertical mode. There are two types of passes -- white passes, from a pass of white pixels, and black passes, from a pass of black pixels. Since white passes are indicative of the bottoms of black structures, they are somewhat analogous to finding the bottoms of connected components in the raw bitmap, such as line ends. In fact, there is guaranteed to be at least one white pass at the bottom of each connected component. Thus, it is advantageous to use white passes as the fiducial points, although it will be apparent to one skilled in the art that black passes may also be used to determine skew angle according to the present invention in appropriate circumstances. The positions of the white pass code fiducial points 78 on unskewed and skewed text are shown as arrows in Figs. 5a and 5b, respectively. The Group 4 encoding of passes does not distinguish between white passes and black passes. To know which color of pass has been encoded, state must be maintained. According to the present invention, state is maintained by a binary state bit which is set to correspond to the fictitious all-white first line. Each event yielding a pass code causes the state bit to invert which thereby keeps running track of the state (i.e., color) of the pass code. Comparing Figs. 4a, b and 5a, b, it will be noted that fewer fiducial points are generated off the baseline of the text in Fig. 5 that in Fig. 4. For example, note that the "O" 80 in Figs. 4a and 4b has associated with it two fiducial points, upper point 82 and lower point 84. Lower point 84 is on the baseline 86, while upper point 82 is not. That same "O" 80 in Figs. 5a and 5b has associated with it only a single fiducial point 88 located on baseline 90. This is a graphical indication that white passes will be advantageous in providing fiducial points on which to base skew measurements by alignment. However, some "noise" is generated by using white passes. That is, some fiducial points are generated which are not directly on the baseline which are added to the baseline information. For example, "C" will generate two white passes, one at the bottom of the mark and one at the bottom of the stroke which forms the upper limit on the opening on the right of the "C". Similarly, the bottom of the center of the "M" which gives rise to a pass code might not lie on the baseline in some fonts. Distinguishing such noise signals is beyond the scope of the present invention. However, the occurrence of noise signals is statistically infrequent enough that they do not significantly degrade accuracy of the determined skew angle or significantly add to the calculation time. Fig. 6 shows a block diagram of an implementation of skew detection routine 66 such as might be located in program memory 56 of Fig. 2. It is assumed, for the starting point of routine 66, that an image has been scanned, that digital data have been produced corresponding to the scanned image, and that those digital data have undergone compression according to a selected data compression method, such as that producing Group 4 compressed data. To begin, the white pass codes in the data structure of compressed image data, for example that stored at location 72 of data memory 58, are located. This is indicated by box 92 of Fig. 6. Once a white pass code is located, its location in an appropriate coordinate system must be determined, as done by box 94. Rectangular coördinates having an abscissa, x, and an ordinate, y, coordinate pairs are generally convenient for this purpose, although other coordinate systems, such as polar coordinates, may be used when appropriate. An array of the coordinate pairs may then be constructed at 96 for use in computing alignments, as discussed in detail below. After storing the coordinate pairs of the locations of the white pass codes, a test is performed at 98 to determine whether the end of the scanned page has been reached. If so, skew angle determination proceeds as discussed in detail below. If not, a search is made for the next, if any, white pass code on the page. The previous four steps 92 through 98 are collectively referred to as coordinate determination routine 100, which may be a subroutine of skew determination routine 66, and which is further described now with reference to Fig. 7. Block 101 illustrates an input of data in the Group 4 compressed format. Using x-y coordinate pairs, x and y must first be initialized to 0 to indicate the start of a page. This is shown by step 102, and is done at the start of each new scanned page. Block 103 represents detection of a Group 4 code. As mentioned, there are three types of Group 4 codes -- horizontal, vertical, and pass. Detecting Group 4 codes may be implemented by character string recognition, or other method from the wide variety within the ambit of one skilled in the art for code detection. Once a Group 4 code is detected, its type must be determined. That is, which of the three Group 4 types is it and, if it is a pass code, it is a white pass code or a black pass code. This process is done through a series of tests, the results of which determine how the x coordinate is determined. The x coördinate is referred to in terms of an old value of x, that is one that is associated with the code located by step 103 in the immediately-preceding pass through coordinate determination routine 100, and a new value of x, that is one that is associated with the code located by step 103 in the current pass through coordinate determination routine 100. A code having been located, a test is performed to determine whether that code is a horizontal code. If so, the new value of x will be the old value of x added to the displacement value associated with the horizontal code. That is, the horizontal mode of Group 4 includes a code indicating the mode and a displacement indicating the number of pixels between the reference pixel color transition and the current pixel color transition. In the case of a horizontal code, the displacement is the number of pixels between a pixel color transition on the particular line and the next pixel color transition on that same line. This is indicated at 106. It is important to note that this new value of x will not become an abscissa value used to determine alignment. Rather, this value is the running value of the displacement from the first pixel position on a scan line. Only the x values relating to white pass codes are used for alignment determination. Proceeding for the moment with the assumption that a horizontal code is detected, a binary pixel color state bit is then incremented at 122, the method of and purpose for doing so are described in detail below. Once the new value of x has been calculated, x is checked at 108 to determine if the line end has been reached. This may be conveniently done by comparing x to the known length of a scan line, in pixels, and should x reach this value the line end has been detected. If the line end has not been reached, code detection continues for that line at 103. If the line end has been reached, x is set to 0 at 110 to correspond to the beginning of the next line and y, which keeps a running count of the line number, is incremented by one and checked at 111 to determine if the page end has been reached. This may be done, as with x, by comparing y to the known number of lines per page, and if y reaches this number a page end has been detected. If a page end has been reached, power is determined for various alignments swept through a number of alignment angles, at 126, as discussed in detail below. If page end has not been reached, code detection then resumes at 103. If the code is determined not to be horizontal, it must be tested to determine if it is a vertical code, which is done at 112. It is necessary to store each transition position from the previous line for use as values on the reference line in the vertical mode. This is done in an array of the type {x1 r , x2 r , ... xn r }, where r indicates a value on the reference line (the preceding scan line) and n is the total number of codes on the reference line. It is only necessary to preserve x values for the previous line, therefore, the new x values may overwrite the old once determined. This is shown at 114. Assuming now that a vertical code has been detected, the value for x is then calculated at 116 as follows. The vertical mode is coded from a displacement between a pixel transition at pixel b i on the reference line and a pixel transition at pixel a on the coding line. Since for the calculation of this displacement we are concerned only with x values, this displacement can be calculated simply as |x b i - x a i |, where x b i and x a i are the x values for pixels b i and a i , respectively. The new x value is the old x value added to this displacement. Again, the binary pixel color state bit is incremented at 122, and the new x value is tested at 108 to determine if the end of line has been reached, and at 111 to determine if end of page has been reached, and so on. If the code detected fails the tests at both 104 and 112, the code is, by process of elimination, a pass code. As already mentioned, it is important to distinguish between white and black pass codes. White pass codes will be used to determine alignment, while black pass codes will not. Although Group 4 does not distinguish between white and black pass codes, by keeping track of a binary pixel color state bit at 118, state may be determined. Initially, the state bit has been set to 0 at 102. Arbitrarily, 0 has been chosen to correspond to white pass codes. Each time a code is detected, the state bit is checked. If the state bit is not equal to 0, i.e., the pass code is not a white pass code, the new value of x is set to equal the old value of x at 120. Assuming the next code encountered is not a pass code, that next code will have associated with it the requisite information needed to calculate the next x properly. If the next code encountered is a pass code, the process is repeated until a code is encountered which is not a pass code. This is the essence of a Group 4 pass code. Continuing, the new value of x has been set at 120, and the state bit is incremented at 122 for the next-encountered pass code. If the state bit is determined to equal 0, a white pass code has been encountered. The location of this white pass must be maintained for purposes of calculating power of the alignment and for the transformation steps discussed below to sweep across several alignment angles. This may be done at selected point data location 72 of data memory 58 of Fig. 2. The maintaining of the locations of the white pass codes is performed at 124. Next, x is set, the state bit incremented and line and page ends checked, as discussed above. Returning now to Fig. 6, this description continues assuming line and page ends have been reached. If this is the case, power is to be determined for a plurality of alignments having different alignment angles, as generally indicated by reference numeral 126. Initially, alignment angle is set to 0 at 128. This alignment corresponds to the alignment that the image was scanned at. For this alignment angle, the power of the alignment is calculated, generally as described above. In this case, a call may be made to memory location 72 of data memory 58 and the number of x values stored therein determined for each line. This represents the bin size for each line. The square of the number of x values for each line will be accumulated in an array at 130 representing the power of the alignment at the present alignment angle. The array of squares will be stored, together with the present alignment angle, at 132, which may be a part of data memory 58. Next, the alignment angle is incremented by a selected amount, for example 1 degree, at 134. The power of the alignments will be determined for alignments within a range of alignment angles. Selection of the range of alignment angles will depend on a number of factors such as expected range of alignment angles, expected strength of alignments, expected number of alignments, etc. The greater the range of alignment angles, the greater the computation time for a given angle increment. In any event, an example of a range of skew angles might be -40 to + 40 degrees. Thus, once incremented, the current alignment angle must be tested to determine whether it falls outside the selected range. This is done at 136. If the current alignment angle does not fall outside the selected range, the locations of the white pass codes will be translated at 138. Several methods of translating the locations of the pass codes exist, and their applicability depends on the coordinate system used, the memory size available, the speed of calculation required, etc. As an example, an effective set of equations for use with Cartesian coordinates, with y increasing in the downward direction, in keeping with the above description, are x j = x cos α - y sin α y j = x sin α + y cos α If the current alignment angle does fall outside the selected range, maximum power may then be determined at 140 by comparing the powers of the various alignments previously stored. This maximum power may then be output at 142 in a wide variety of formats, for example an absolute angle, a spectrum of angles together with their powers, etc. The format of the output will depend on the intended use of the results, as previously described. A specific example follows to illustrate the present invention further. Example Shown in Fig. 8 is sample text used to test the method of the present invention. The bin size has been set to two pixels as a reflection of the minimum detectable skew in a digital image (that is, one pixel difference in vertical position across the width of the image). For the same reason, angular increment size has been limited such that no attempt would be made to resolve skew angles below this threshold. Alignment is measured over a +/- 80 degree sweep. White pass code locations for the sample skewed text of Fig. 8 are shown in Fig. 9. These white pass codes are used to calculate the various rotational alignments. Fig. 10 shows the power as a function of alignment relationship for these white pass fiducial points of Fig. 8. Skew angle may be determined graphically from the plot of Fig. 10 as the angle that the relative maximum power peak differs from the horizontal 0-degree indication. Note the three dashed arcs in Fig. 10. The innermost arc shows the power level to be expected if the fiducial points were unaligned. The next arc is drawn at the average power level over the 80 degree sweep. The outer-most arc is drawn at the peak power level. These arcs demonstrate the statistical significance of the peak power level as determined by the power calculation algorithm. If a Baird-like alignment process is applied to the fiducial points which correspond to the positions of white passes in the Group 4 compressed representation of the image, an efficient and accurate means of determining the skew angle in the underlying image results. Testing Testing of the present system on CCITT test data demonstrates that the present invention provides a significant improvement in skew angle detection performance in a majority of cases. A comparison of skew angle detection performance between the method of Baird and the present method is shown in table 1 below. In each instance both skew angle detection algorithms were applied to the raw bitmaps to determine the amount of skew detected by the algorithm in the supposedly unskewed image. Then the bitmaps were digitally rotated through - 3.0 degrees and + 5.0 degrees, and the skew angle determination was performed again. File No Rotation -3.0 Degree Rotation +5.0 Degree Rotation Baird Present Invention Baird Present Invention Baird Present Invention (degrees rotation) (degrees rotation) (degrees rotation) cc1 0.20 0.24 -2.76 -2.80 5.20 5.24 cc2 -1.00 0.10 -4.00 -2.12 6.00 5.02 cc3 -0.32 -0.32 -3.16 -3.24 4.88 4.76 cc4 -0.04 -0.08 -3.00 -3.00 4.92 5.00 cc5 0.52 0.48 -2.48 -2.52 5.52 5.48 cc6 0.08 0.24 -2.88 -2.88 5.08 5.12 cc7 0.16 0.16 -2.84 -2.88 5.08 5.12 cc8 0.08 -0.20 -3.20 -2.96 4.92 5.12 One notable result of the above tests is that the step of classifying marks as being either text or non-text has been obviated. In fact, the present invention yields highly relevant and accurate results for images such as cc2, which are predominantly non-textual. This result is especially important at high skew angles, arising from the fiducial points being explicitly tied to the structure whose skew angle is being determined. Presence of halftones with non-orthogonal screen angles may not degrade performance of the algorithm of the present invention since the halftone areas should be encoded using the uncompressed mode of the Group 4 recommendation and not involve the use of pass codes. Nevertheless the effect of the presence of halftone material on this technique has not yet been tested. Characterizations of the shape of the power distribution can lead to useful generalizations about the predominance of a single skew angle in the page image. With reference to Fig. 11, the presence of multiple well-defined peaks is an indication of multiple well represented alignments in the source image. The method of determining such multiple alignments does not differ materially from the method of determining skew of an image having only a single alignment. The present invention is designed to generalize about the predominant skew angle over an entire page image. However, multiple skew angles can arise in advertising copy and as an artifact of improper paste-up. In such cases, this technique will still generalize about the entire image and this generalization may or may not be valuable in the characterization of the image. Where the relative skew angles are large, as they might be in advertising copy, the assignment of a single skew angle characteristic to the page image will be meaningless, but in the case of paste-up errors, a single skew angle determination may be adequate to represent the image as well as being the only simply available measure. The present invention thus discloses methods for locating, selecting, and utilizing features, particularly topographic features, of an image for the purpose of determining skew angle. The present invention is significantly computationally less intensive than known methods. The present invention also takes advantage of the wide availability of inexpensive data compression packages and the simplicity of integrating those packages into a single system.

Claims: A method of operating a processor connected for accessing a data structure defining an image, the method comprising: accessing (100) the data structure to obtain transition location data defining locations within the image of pixel color transitions and determining (126) a skew angle of the image using the transition location data, characterised in that the data structure defines the image in a compressed data format that includes pass codes, each pass code indicating a location in the image of a transition from one of first and second colours to the other colour in a first scanline, which transition has no counterpart in a second, reference scanline, adjacent the first scanline, and in that the step of accessing the data structure includes using the pass codes to obtain transition location data defining only locations of transitions indicated by the pass codes. The method of claim 1, wherein the first color is black and the second colour is white. The method of claim 2, wherein the the data structure defines the image in a compressed data format according to the two-dimensional CCITT facsimile recommendations. A method for determining a skew angle of an image, wherein skew angle is determined as the angle corresponding to a selected one of a group of alignments, each alignment having associated with it a power upon which the selection is based, the power of each alignment being calculated from a count per line of selected features for that alignment, the image data being of the type which includes an indication of points of pixel color transition, comprising the steps of: selecting as features points on a scanline of pixel color transition, a topographical feature of the image being located at each selected point and having no corresponding topographical feature on an adjacent, reference scanline; selecting (134) an alignment; determining (138,92-96) the locations of the selected points of pixel color transition for the alignment, and calculating (130) the power of the alignment from the locations of the selected points of pixel color transition. A method as claimed in claim 4, including the steps of: selecting (134) a first alignment; determining (138) the locations of the selected points of pixel color transition for the first alignment; calculating (130) the power of the first alignment from the locations of the selected points of pixel color transition; selecting (134) a second alignment; determining (138) the locations of the selected points of pixel color transition for the second alignment; calculating (130) the power of the second alignment from the locations of the selected points of pixel color transition, and determining the skew angle from a comparison of the powers of the first and second alignments. The method of claim 5, wherein the image data are in a compressed format which includes pass codes, each pass code indicating a location in the image of a transition from one of first and second colours to the other colour in a first scan line, which transition has no counterpart in a second scanline, adjacent the first scanline, and further including the steps of determining the locations of those pass codes, and utilizing the locations of those pass codes as the locations of the selected points of pixel color transition. The method of claim 6, including the further step of using those pass codes that indicate locations of transitions from black to white. A method for determining skew angle or angles of a scanned image, wherein skew is determined by forming a count of selected topographic features of the image, forming (130) selected weighted sums of the selected topographic features such that the topographic features form a plurality of alignments, and determining (140) as the skew angle or angles that alignment or alignments which maximize one or more of the weighted sums, including the steps of: selecting (92) a plurality of locations in the image, and using the selected points as the topographic features, characterised in that the step of selecting (92) comprises selecting two or more locations in the image that are indicated by pass codes, each pass code indicating a location in the image of a transition from one of first and second colours to the other colour in a scan line, which transition has no counterpart in a second, reference scanline, adjacent the first scanline.

Inventors: SPITZ A LAWRENCE, SPITZ, A. LAWRENCE
Applicants: XEROX CORP, XEROX CORPORATION
Application year: 1990
Main classification: G06K9
IPC codes: G06T1, G06T7, G06K9, H04N1