Non-iterative method of calculating image skew
Abstract
A parallel, non-iterative, memory efficient method of determining image skew. A document skew angle is determined from a fast scan second order moment data set and a slow scan second order moment data set. A slow scan second order moment data set can be generated by receiving a current scanline of image data, updating columns sums for a set of rotation angles using scanlines within a buffer comprising a band having a predetermined number B of scanlines, and updating the buffer with the current scanline. A fast scan second order moment data set is generated by projecting a plurality of pixels within each scanline of image data received to a first rotation angle wherein the plurality pixels project onto M rows; updating M memory locations, wherein each one of the M memory locations corresponds to one of the M rows and wherein each memory location is updated using pixels projecting onto the corresponding row whereby one of the M memory locations contains a completed row; and adding the square of the completed row sum to a moment accumulator.

Term
Term ended
Projected expiry passed 16 December 2023, 2.8 years ago.
- Priority
- Filed
- Published
- Projected expiry
- Today
10 claims: 3 independent, 7 dependent
- 1A method of processing scanned image data comprising:receiving image data, the image data comprising a plurality of scanlines with each scanline comprising a plurality of pixels;generating a fast scan second order moment data set;generating a slow scan second order moment data set;anddetermining a document skew angle from the fast scan and slow scan second order moment data sets;wherein the step of generating the slow scan second order moment data set includes receiving a current scanline of image data,updating columns sums for a set of rotation angles using scanlines within a buffer comprising a band of scanlines, the band having a predetermined number B of scanlines, andupdating the buffer with the current scanline.
- 8A method of processing image data comprising:scanning a document to produce scanned image data comprising a plurality of scanlines, each scanline having a plurality of pixels;generating a first set of second order moments, the first set of second order moments being based on row sums;generating a second set of second order moments, the second set of second order moments being based on column sums ;anddetermining a document skew angle from the first and second sets of second order moments;wherein the step of generating the first set of second order moments includes receiving a first scanline, projecting a plurality of pixels within the first scanline to at least a first rotation angle,adding a first subset of the plurality of projected pixels to a first memory location,adding a second subset of the plurality of projected pixels to a second memory location,adding a third subset of the plurality of projected pixels to a third memory location, andadding the square of the pixel sum in the first memory location to a moment accumulator.
- 9A memory efficient method of processing image data to determine image skew, comprising:receiving scanned image data, the scanned image data comprising a plurality of scanlines with each scanline comprising a plurality of pixels;generating a fast scan second order moment data set;generating a slow scan second order moment data set;anddetermining a document skew angle from the fast scan and slow scan second order moment data sets;wherein the step of generating the fast scan second order moment data set includes projecting a plurality of pixels within a scanline to at least a first rotation angle wherein the plurality pixels project onto M rows;updating M memory locations, wherein each one of the M memory locations corresponds to one of the M rows and wherein each memory location is updated using pixels projecting onto the corresponding row whereby one of the memory locations contains a completed row sum and M-1 of the memory locations contain partial row sums;adding the square of the completed row sum to a moment accumulator;andrepeating the projecting, updating and adding steps for each scanline within a plurality of scanlines whereby a memory location having a completed row sum is reused to accumulate subsequent row sum so that only M memory locations are required to accumulate row sums.
Independent claims3
61 paragraphs, as filed
<u>FIELD OF THE INVENTION</u>
The present invention relates to the art of image processing. The embodiments disclosed herein find particular application in conjunction with determining and correcting image skew of a digital image, and will be described with particular reference thereto.
<u>BACKGROUND AND SUMMARY</u>
In many image processing applications, it is desirable to determine and correct skew of a document image. For example, many text recognition systems, such as optical character recognition (OCR) systems, fail if presented with text oriented with a skew of more than a few degrees, not to mention if the text is oriented sideways or upside-down. In addition, it is easier to identify text lines and text columns if the image skew is known or the image is deskewed.
A variety of methods for determining image skew using an iterative estimation approach based upon the method disclosed by Baird in U.S. Patent No. 5,001,766 have been proposed. One such approach involves using bounding boxes of connected components to estimate image skew. The coordinates of a token point, on the bottom center of the bounding box, are selected, and a function S<sub>tokens</sub> of skew angle is computed from these coordinates. Specifically, the function S<sub>tokens</sub>(2) is the sum of squares of the number of such points computed along a set of lines with the angle 2 to the raster direction. A vertical shear is simulated on the set of points and the sums over the points with the same y-coordinate are determined. Aside from a constant (independent of 2), the function S<sub>tokens</sub> is the variance of the number of tokens on a line, as a function of angle. This variance is a maximum in the direction where the tokens for each text line fall near the same line.
Another method for determining skew traverses straight lines of the image at a set of angles relative to the raster direction. A function S<sub>δ</sub>(θ) is computed that has a maximum value when the scan direction θ is along the text lines. Unlike the approach described above, which computes tokens from connected components, this method uses every pixel in the image. The function S<sub>δ</sub>(θ) is similar to the function S<sub>tokens</sub>(θ) in the sense that an angle θ is chosen and pixel sums are found along lines in the image at this angle. However, instead of squaring the sum of tokens, the second method squares the difference between sums of ON pixels on adjacent lines, and the function S<sub>δ</sub>(θ) is found by summing over all lines. The function S<sub>δ</sub> (8) is, aside from a constant, the variance in the difference between pixel sums on adjacent lines at the angle θ.
The deskew methods described above, along with other deskew methods employing an iterative estimation approach based on the teachings of Baird, require a local copy of the image to be stored. Such requirement prevents pipeline processing; while the iterative nature of the methods eliminates the possibility of parallel processing. Therefore, the speed at which an image may be deskewed is necessarily limited.
The teachings disclosed herein propose a method and apparatus for determining and correcting image skew. In particular, there is taught a parallel, non-iterative, memory efficient method of determining image skew. In accordance with an embodiment disclosed herein there is provided a method of determining image skew including scanning a document to produce scanned image data, the scanned image data comprising a plurality of scanlines with each scanline comprising a plurality of pixels; generating a fast scan second order moment data set; generating a slow scan second order moment data set; and determining a document skew angle from the fast scan and slow scan second order moment data sets; wherein the step of generating the slow scan second order moment data set includes receiving a current scanline of image data, updating columns sums for a set of rotation angles using scanlines within a buffer comprising a band of scanlines, the band having a predetermined number B of scanlines, and updating the buffer with the current scanline.
In a further embodiment the step of wherein the step of generating the fast scan second order moment data set comprises: <ul id="ul0001" list-style="none" compact="compact"><li>projecting a plurality of pixels within the current scanline to a first rotation angle;</li><li>adding a first subset of the plurality of projected pixels to a first memory location;</li><li>adding a second subset of the plurality of projected pixels to a second memory location;</li><li>adding a third subset of the plurality of projected pixels to a third memory location; and</li><li>adding the square of the pixel sum in the first memory location to a moment accumulator.</li></ul>
In a further embodiment the step of generating the fast scan second order moment data set further comprises: <ul id="ul0002" list-style="none" compact="compact"><li>projecting a plurality of pixels within a subsequent scanline to the first rotation angle;</li><li>adding a first subset of the plurality of projected pixels within the subsequent scanline to the second memory location;</li><li>adding a second subset of the plurality of projected pixels within the subsequent scanline to the third memory location;</li><li>adding a third subset of the plurality of projected pixels within the subsequent scanline to the first memory location, and</li><li>adding the square of the pixel sum in the second memory location to the moment accumulator.</li></ul>
In accordance with another embodiment disclosed herein there is provided a method of determining image skew including scanning a document to produce scanned image data comprising a plurality of scanlines, each scanline having a plurality of pixels; generating a first set of second order moments, the first set of second order moments being based on row sums; generating a second set of second order moments, the second set of second order moments being based on column sums ; and determining a document skew angle from the first and second sets of second order moments; wherein the step of generating the first set of second order moments includes receiving a first scanline, projecting a plurality of pixels within the first scanline to a first rotation angle, adding a first subset of the plurality of projected pixels to a first memory location, adding a second subset of the plurality of projected pixels to a second memory location, adding a third subset of the plurality of projected pixels to a third memory location, and adding the square of the pixel sum in the first memory location to a moment accumulator. In a further embodiment the step of generating the fast scan second order moment data set further comprises adding a fourth subset of the plurality of projected pixels to a fourth memory location. In a further embodiment the step of generating the first set of second order moments further includes: <ul id="ul0003" list-style="none" compact="compact"><li>receiving a second scanline;</li><li>projecting a plurality of pixels within the second scanline to the first rotation angle;</li><li>adding a first subset of the plurality of projected pixels within the second scanline to the second memory location;</li><li>adding a second subset of the plurality of projected pixels within the second scanline to the third memory location;</li><li>adding a third subset of the plurality of projected pixels within the second scanline to the first memory location, and</li><li>adding the square of the pixel sum in the second memory location to the moment accumulator.</li></ul> In a further embodiment the step of generating the second set of second order moments includes: <ul id="ul0004" list-style="none" compact="compact"><li>updating columns sums for a set of rotation angles using scanlines within a buffer comprising a band of scanlines, the band having a predetermined number B of scanlines, and</li><li>updating the buffer with the first scanline according to a first in, first out priority.</li></ul> In a further embodiment the step of generating the second set of second order moments further comprises: <ul id="ul0005" list-style="none" compact="compact"><li>updating columns sums for a second set of rotation angles using scanlines within the buffer, and</li><li>updating the buffer with the second scanline.</li></ul>
In accordance with another embodiment disclosed herein there is provided a method of processing image data to determine image skew, comprising: receiving scanned image data, the scanned image data comprising a plurality of scanlines with each scanline comprising a plurality of pixels; generating a fast scan second order moment data set; generating a slow scan second order moment data set; and determining a document skew angle from the fast scan and slow scan second order moment data sets; wherein the step of generating the fast scan second order moment data set includes projecting a plurality of pixels within a scanline to at least a first rotation angle wherein the plurality pixels project onto M rows; updating M memory locations, wherein each one of the M memory locations corresponds to one of the M rows and wherein each memory location is updated using pixels projecting onto the corresponding row whereby one of the memory locations contains a completed row sum and M-1 of the memory locations contain partial row sums; adding the square of the completed row sum to a moment accumulator; and repeating the projecting, updating and adding steps for each scanline within a plurality of scanlines whereby a memory location having a completed row sum is reused to accumulate subsequent row sum so that only M memory locations are required to accumulate row sums. In one embodiment of the method of processing image data to determine image skew according to claim 10, the step of updating memory locations, updates the M<sub>i</sub> memory locations for a given rotation angle in parallel.
<u>BRIEF DESCRIPTION OF THE DRAWINGS</u>
The teachings and embodiments disclosed herein will be described with reference to the accompanying drawings, which are provided for purposes of illustrating various aspects of the teachings and embodiments and are not to be construed as limiting the same, wherein:
FIG. <b>1</b> is a block diagram of an imaging apparatus which may incorporate one or more aspects of the embodiments disclosed herein;
FIG. <b>2</b> is a flow chart illustrating a an embodiment of method of determining image skew;
FIG. <b>3</b> is a flow chart illustrating an embodiment of a method for simultaneously sampling pixel data at a plurality of document rotation angles;
FIGS. <b>4</b> and <b>5</b> illustrate the projection of a pixel along a document rotation angle;
FIG. <b>6</b> is a flow chart illustrating an embodiment of a method of validating a second order moment data set;
FIG. <b>7</b> is a flow chart illustrating an embodiment of a method for combining skew angle estimates from valid data sets; and
FIGS. <b>8</b> and <b>9</b> illustrate an embodiment of obtaining row sums for selected document rotation angles in accordance with the teachings herein.
<u>DESCRIPTION</u>
For a general understanding of the teachings herein, reference is made to the drawings wherein like reference numerals have been used throughout to designate identical elements. The present description is directed in particular to elements forming part of, or cooperating more directly with a method and apparatus for determining image skew having efficient memory requirements. It is to be understood that elements not specifically shown or described may take various forms well known to those skilled in the art.
Turning now to FIG. <b>1</b>, there is shown an imaging apparatus which determines and corrects image skew in a scanned document <b>12.</b> Image skew refers to rotational error between the dominant orientation of lines of printed objects, such as characters, within a document and a reference line observed by a reader or scanner as being zero rotational error. Scanner <b>16</b> scans document <b>12</b> in a conventional manner, producing electrical scanned image data, a copy of which is stored in image data memory <b>20</b>. The scanned image data is represented as a two-dimensional data set (rows and columns) of pixels.
Due to the relative motion between the input device (<i>e.g.</i>, the image array, sensor array) of the scanner and the image being scanned, a scanline of data is acquired relatively quickly. Accordingly, the axis of the image set that is parallel to each scanline of data is referred to as the fast scan direction. Conversely, the slow scan direction refers to the direction of the relative movement between the document and the scanning system. This is the mechanical movement that causes the scanning system to generate scanlines of image data. That is, the scanned image data can be said to comprise rows of pixels in the fast scan direction and columns of pixels in the slow scan direction.
In addition to supplying image data to memory <b>20,</b> scanlines of image data are supplied to accumulator <b>24.</b> Beneficially, the scanlines of image date supplied to accumulator <b>24</b> are comprised of a plurality of binary pixels. That is, each pixel can be considered to be ON or OFF. For example, in an eight bit system with pixel values from 0 (black) to 256 (white), pixels may be defined to be ON if they are black (<i>e.g.,</i> below a preselected threshold value) and OFF if they are white (e.g., below a preselected threshold value). In such a system, the threshold may, for example, be set to a predetermined level or based on a background level determined for the document. The designation of black as ON and white as OFF simply reflects the fact that most documents of interest have a black foreground and a white background. However, it is to be appreciated that the teachings herein are equally applicable to negative images as well.
Accumulator <b>24</b> which may beneficially comprise a plurality of pixel counters, a plurality of row summers and column summers, processors, or like devices to accumulate pixel sums, sums pixel counts for rows and columns for various rotation angles to calculate a second order moment for each of the predetermined rotation angles. For each binarized scanline of image data received, accumulator <b>24</b> simultaneously samples pixel data at a plurality of document rotation angles. Second order moments are calculated as a function of document rotation angle for rows and columns by accumulator <b>24,</b> yielding row and column second order moment data sets. The row and column second order moment data sets are supplied to skew angle processor <b>30</b>, which processes the second order moment data sets to yield a resultant image skew angle. The operation of accumulator <b>24</b> and skew angle processor <b>30</b> are described more fully below.
An image processor <b>38,</b> containing a memory <b>40</b>, receives the calculated skew angle estimate and applies it to the scanned image data received from the image data memory <b>20.</b> The image processor <b>38</b> corrects the skew error present in the image in accordance with the resultant skew angle estimate received from the skew angle processor <b>30.</b> Skew correction involves rotating the original image stored in the image data memory <b>20</b> by the negative of the skew angle determined by the skew angle processor so as to deskew the image. Such means for rotating the image are well known, and include, for small angles of rotation (less than 5 degrees), applying two orthogonal shears. For larger skew angles, rotation can be approximated by three shears, with the first and third shear of equal magnitude in the horizontal direction and the second larger shear in the vertical direction. The deskewed digital image representation is output to image output device 50 which may comprise an electrostatographic (<i>e.g.</i>, electrophotographic, ionographic) printer; a liquid ink printer (<i>e.g.,</i> drop-on-demand, such as piezoelectric, acoustic, phase change wax-based or thermal); an electronic display systems such as CRTs, LCDs, LED, etc.; or similar output device.
In the embodiment of FIG. <b>1,</b> image output device <b>50</b> comprises a xerographic printer. In such embodiment, the digital image representation is transferred to an image processing controller <b>52.</b> In a conventional xerographic device, a charge retentive surface in the form of photoreceptor belt is charged to a substantially uniform potential. The belt then travels through an exposure station <b>54</b> which, in response to image data, generates modulated light beam that illuminates portions of the belt causing the charge retentive surface to be discharged so as to create an electrostatic latent image. After receiving an electrostatic latent image, the exposed image area passes through a developer station <b>56</b> at which toner is placed on the latent image using commonly known techniques. After station <b>56,</b> a sheet is brought into contact with the surface of belt wherein the toner image is transferred to the sheet. After transfer, the sheet is advanced to fuser station <b>58</b> wherein the toner is permanently affixed to the sheet to produce a hard copy <b>60</b> of the scanned image.
Turning now to FIG. <b>2</b>, there is shown a flowchart of an embodiment of a method of determining image skew of a scanned document. In accordance with the teachings herein, image skew is determined by calculating the second order projected moment in both the fast scan and slow scan direction for several predetermined rotation angles in parallel. The moments are calculated by first summing the pixel values along a projected line in the image for each rotation angle, where the projected line pitch is a function of the rotation angle. Then, for each angle, the projected line sums are squared and added together to form a single metric.
The embodiment of FIG. <b>2,</b> a document is scanned <b>200</b> in a conventional manner, to obtain one or more scanlines of image data. Optionally, the resolution of image data is reduced <b>210</b> so as to accelerate the process. Any number of conventional techniques can be employed to reduce the image data resolution. For example, the source image data can grouped into blocks of pixels with each such block being mapped to a single pixel on the destination image. The value for the destination image pixel may be determined by counting the ON pixels within the block. If the number of ON pixels in the block is greater than or equal to a threshold, the destination pixel is considered to be ON, otherwise it is considered to be OFF. Alternatively, the data may be reduced by sub-sampling such that every n<sup>th</sup> scanline and/or pixel is considered.
Row and columns of image data are sampled <b>220</b> along two directions, <i>i.e.</i>, the fast scan and slow scan directions, at one or more predetermined document rotation angle(s) in order to determined the number of ON pixels per row or column. More particularly, within a given scanline of image data, for each pixel position within that scanline, the pixel position's rotated location is calculated for all predetermined document rotation angles simultaneously and the corresponding row and column sums are updated. In other words, as each pixel is read, its location is calculated simultaneously for each document rotation angle to be sampled as if the scanline were rotated and the corresponding row and column sum for the calculated pixel location are updated at that time. This process is described more fully with reference to FIG. <b>3</b>.
Turning now to FIG. <b>3</b>, a scanline of image data is received and pixels within the scanline are sampled or read <b>300,</b> that is, determined to be either ON or OFF. Each pixel within the scanline is then projected along a plurality of predetermined document rotation angles <b>310</b> and location of each such projected pixel is determined. Based on the projected pixel locations for each document rotation angle, the corresponding row and column sums are updated 320 simultaneously. As is explained more fully below, the second order moments of the ON pixels are calculated for each predetermined document rotation angle based on the updated row and column sums. The process of steps <b>300</b> through <b>320</b> is repeated for a plurality of scanlines of image data across the scanned document. It should be appreciated that, although step 310 is described as projecting each pixel within a scanline along a plurality of predetermined document rotation angles, the process can be employed to project only a subset of the pixels within the scanline.
The pixel sample, rotation and the row/column sum process can be illustrated with addition reference to FIGS. <b>4</b> and <b>5.</b> Referring to FIG. <b>4,</b> there is illustrated a document <b>400</b> having a plurality of rows. At a given document rotation angle of zero miliradians, a particular pixel <b>410,</b> which is determined to be ON, is located in a given column (pixel position) at a certain x value along row 1200 <b>420.</b> Pixel <b>410</b> is counted and added to the row sum of the number of ON pixels for row 1200 <b>420</b> for document rotation angle of zero miliradians. However, for a different document rotation angle, <i>e</i>.<i>g</i>., α = 1 miliradian, the pixel at position <b>410</b> would move to pixel position (column) <b>430</b> on scanline 1100. It is to be appreciated that projected pixel position <b>430</b> is calculated to fall on scanline 1100 by the formula Δy = xα. This relationship holds true because tan α ≈ a for small alphas. Therefore, as each pixel is read for an initial document rotation angle, the row onto which it would be projected is calculated and the subsequent pixel count is updated for each predetermined document rotation angles to be sampled as the pixel is read.
Similarly, referring to FIG. <b>5</b>, there is illustrated a document <b>500</b> having a plurality of columns. At a given document rotation angle of zero miliradians, a particular pixel <b>510</b>, which is determined to be ON, is located in a given position or row (<i>e.g.</i>, row 1150) along column <b>520</b> corresponding to column 100. Pixel <b>510</b> is counted and added to the column sum for the column 100 for document rotation angle of zero miliradians. At a document rotation angle α, the pixel at position <b>510</b> along column 100 would project onto pixel position <b>530</b> which occurs along the same row 1150 but on column 110. Here again, it should be readily apparent that projected pixel position 530 can be obtained by the Δx = yα.
From the above, it should be appreciated the projected position of any pixel position along a row or column can be readily determined as a function of the rotation angle and the row or column in which the pixel resides. That is, the row <i>y</i> onto which any pixel <i>x</i> along a given row <i>y</i><sub><i>0</i></sub> at rotation angle α will project is given by <i>y</i> = <i>x</i>α + <i>y</i><sub><i>0</i></sub>. Similarly, the column <i>x</i> onto which any pixel <i>y</i> along a given column <i>x</i><sub><i>0</i></sub> at rotation angle α will project is given by <i>x</i> = <i>y</i>α + <i>x</i><sub><i>0</i></sub>. As an alternative to repeatedly calculating the projected pixel position, the projected pixel position for any rotation angle can be defined by its offset in the row (y) or column (x) direction. As the projected lines tend to cross a small number of row or columns given the number of pixels per row or column, the pixel offset values will be constant over a significant number of pixels allowing for compact storage of the offset values. Furthermore, as the pixel offset values simply increase one row or column at a time, the system need only identify those pixels along the row or column at which the projected pixel position shifts (is offset) to the next row or column. In such an embodiment, when updating the row or column sums, the method need only track (count) the pixels and shift the row or column sum to update at the appropriate time.
Referring back to FIG. <b>2</b>, a second order moment data set is calculated 230 for scanlines along the fast scan direction. In other words, the second order moment data set includes calculated second order moments as a function of document rotation angle. The second order moment is the mean value of the sum of the square of the number of ON pixels on each row for a given document rotation angle. More particularly, the second order moment is calculated by an equation of the form:<maths id="math0001" num=""><img file="EP1431908A2_D0001.tif" /></maths> where N is the number of rows (scanlines) along the fast scan direction, <i>n</i> is the number of ON pixels in a scanline; and <i>i</i> is a counter for the scanlines along the fast scan direction. Stated differently, for a given document rotation angle, the second order moment is calculated by summing the number of ON pixels across each scanline or row, squaring that sum, and summing over all of the scanlines. While the second order moment is the preferred metric for determining skew angle, it is to be appreciated that other metrics may be employed, such as the square of the difference between sums of ON pixels on adjacent scanlines or the variance.
The same process is employed to calculate a second order moment data set along the slow scan direction <b>235</b> by performing the above-described operation, only summing along columns rather than rows. In other words, in order to calculate the second order moment data set along the slow scan direction, the number of ON pixels along scan columns are calculated by an equation of the form:<maths id="math0002" num=""><img file="EP1431908A2_D0002.tif" /></maths> where <i>M</i> is the number of columns (pixels per scanline) along the slow scan direction, <i>m</i> is the number of ON pixels in a column, and <i>j</i> is a counter for the columns along the slow scan direction.
From the fast scan and slow scan second order moment data sets, first and second skew angles are calculated <b>240, 245.</b> Each skew angle estimate <b>240, 245</b> is passed through a validation process <b>250, 255,</b> where invalid data sets are discarded <b>260</b> and valid data sets are passed on to a compare and combine step <b>270,</b> which ultimately yields a resultant skew angle estimate <b>280.</b>
More particularly, with reference to FIG. <b>6,</b> each second order moment data set <b>600</b> is subject to a curve fit analysis <b>610</b> in order to calculate the corresponding skew angle. More particularly, each second order moment data set is fit with an equation of the form:<maths id="math0003" num="(3)"><math display="block"><mrow><msub><mrow><mtext mathvariant="italic">S</mtext></mrow><mrow><mtext mathvariant="italic">α</mtext></mrow></msub><mtext> = </mtext><msub><mrow><mtext mathvariant="italic">S</mtext></mrow><mrow><mtext mathvariant="italic">α</mtext></mrow></msub><msub><mrow><mtext></mtext></mrow><mrow><mtext>max</mtext></mrow></msub><mtext></mtext><mtext mathvariant="italic">- k</mtext><mtext>|</mtext><mtext mathvariant="italic">α -</mtext><msub><mrow><mtext> α</mtext></mrow><mrow><mtext>max</mtext></mrow></msub><mtext>|</mtext></mrow></math><img file="EP1431908A2_D0003.tif" /></maths> where <i>S</i><sub>αmax</sub> is the maximum second order moment value, and α<sub>max</sub> is the document rotation angle at which <i>S</i><sub>αmax</sub> occurs. From this fit, the document rotation angle at which the second order moment is substantially a maximum is computed for both the fast scan and slow scan second order moment data sets. In other words, the document rotation angle at which the maximum second order moment occurs is the skew angle estimate.
In order to determine whether the particular second order moment data set is valid, at least one quality factor or q-factor is calculated <b>620.</b> More particularly, from equation (3), a local quality factor, <i>Q</i><sub><i>loc</i></sub>, is calculated according to the following equation:<maths id="math0004" num="(4)"><math display="block"><mrow><msub><mrow><mtext mathvariant="italic">Q</mtext></mrow><mrow><mtext mathvariant="italic">loc</mtext></mrow></msub><mtext> = </mtext><mtext mathvariant="italic">k =</mtext><mfrac><mrow><msub><mrow><mtext mathvariant="italic">S</mtext></mrow><mrow><mtext mathvariant="italic">α</mtext></mrow></msub><mtext>-</mtext><msub><mrow><mtext mathvariant="italic">S</mtext></mrow><mrow><mtext mathvariant="italic">α</mtext></mrow></msub><msub><mrow><mtext></mtext></mrow><mrow><mtext>max</mtext></mrow></msub></mrow><mrow><msub><mrow><mtext>|α-α</mtext></mrow><mrow><mtext>max</mtext></mrow></msub><mtext>|</mtext></mrow></mfrac></mrow></math><img file="EP1431908A2_D0004.tif" /></maths><i>Q</i><sub><i>loc</i></sub> is equivalent to the slope of the equation fit to the particular second order moment data set at the local maximum. In addition, a global quality factor, <i>Q</i><sub><i>Global</i></sub>, is calculated according to the following equation:<maths id="math0005" num="(5)"><math display="block"><mrow><msub><mrow><mtext mathvariant="italic">Q</mtext></mrow><mrow><mtext mathvariant="italic">Global</mtext></mrow></msub><mtext mathvariant="italic"> =</mtext><mtext></mtext><mfrac><mrow><mtext>(</mtext><msub><mrow><mtext mathvariant="italic">S</mtext></mrow><mrow><mtext>αmax</mtext></mrow></msub><mtext>-</mtext><msub><mrow><mtext mathvariant="italic">S</mtext></mrow><mrow><mtext>αmin</mtext></mrow></msub><mtext>)</mtext></mrow><mrow><msub><mrow><mtext mathvariant="italic">S</mtext></mrow><mrow><mtext>αmax</mtext></mrow></msub></mrow></mfrac></mrow></math><img file="EP1431908A2_D0005.tif" /></maths> where <i>S</i><sub>αmin</sub> is the minimum second order moment value, and α<sub>min</sub> is the document rotation angle at which <i>S</i><sub><i>α</i></sub><sub>min</sub> occurs. It is to be appreciated that <i>Q</i><sub><i>loc</i></sub> and <i>Q</i><sub><i>Global</i></sub> are indicators of the strength and integrity of both the fast scan and slow scan second order moment data sets.
The calculated quality factors are used in a number of validation or verification steps described below. The first validation step includes verifying whether each second order moment data set includes a single dominant peak or multiple peaks <b>630.</b> In one embodiment, a predetermined peak-to-valley threshold is employed to determine the number of dominant peaks present in the second order moment data set. However, it is to be appreciated that other conventional methods are contemplated. If multiple peaks are present, the data set is determined to be invalid <b>660.</b> Assuming a single dominant peak, a peak purity test is performed in which it is determined whether the function is strictly decreasing near the dominant peak <b>640</b>. If a strictly decreasing peak is not present, such as where a side node exists adjacent the dominant peak, the data set is declared to be invalid <b>660.</b> Conversely, if the single peak is considered to be strictly decreasing, the q-factor or quality factor associated with the peak is compared <b>650</b> to a predetermined threshold value. If the q-factor does not meet the predetermined threshold, the data set is considered to be invalid and the corresponding skew angle estimate is not used in further processing. However, if the q-factor is determined to be greater than the threshold, the data set is considered to be valid <b>670</b> and the corresponding skew angle estimate is passed on to the compare and combine step <b>270.</b>
Referring FIG. <b>7</b>, a method of comparing and combining 270 skew angles from valid data sets <b>700</b> is illustrated. First, the number of valid data sets is determined <b>705.</b> If no valid data sets exist, failure is declared <b>710</b> and no skew angle is reported. It is to be appreciated that this condition may be present in document images containing extraordinarily large quantities of text and/or numerous varied dominant orientations of text. If one valid data set is present, the skew angle corresponding to the valid data set is reported <b>715</b> as the resultant skew angle for the particular image.
In the case of two valid data sets, the corresponding q-factors, <i>Q</i><sub><i>Global</i></sub> and/or <i>Q</i><sub><i>loc</i></sub>, for each valid data set are compared <b>720</b> to one another. It is determined whether or not the difference between the q-factors of the two data sets is greater than a predetermined threshold <b>725.</b> It is to be appreciated that both local and global q-factors may be considered in this determination. If the q-factor differences are greater than the predetermined thresholds, the skew angle corresponding to the data set having a higher q-factor is reported <b>730</b> as the skew angle for the image. This state is characterized as a single dominant data set, that is, a state where one data set has a significantly higher q-factor than the other. If the difference between the respective q-factors is less than the predetermined threshold, the skew angles for both data sets are compared <b>730</b>. Namely, it is determined whether the difference in skew angles is greater than a predetermined threshold <b>740.</b> If the skew angle difference is less than the predetermined threshold, the average of the two skew angles is reported <b>750</b> as the resultant skew angle for the image. In this case, it is to be appreciated that shear may be reported as well, where the shear is equivalent to the angle difference between the two skew angle estimates. However, if the difference between the first and second skew angles is greater than the predetermined threshold, the smaller skew angle estimate is reported 745. It is to be appreciated that reporting the smaller skew angle estimate provides an additional safeguard in an effort to avoid over-correction or over-manipulation of the document image.
In one embodiment, accumulator <b>24</b> of FIG. <b>1</b> employs one memory location to store each row sum for each document rotation angle. However, to implement such an embodiment wherein each of the for <i>A</i> rotation angles over <i>N</i> scanlines requires over (<i>A×N</i>) memory locations to store the projected row sums. However, it should be appreciated that at any one time, only a small subset of the memory locations are being accessed. Thus, while it is possible to implement an embodiment with such a memory requirement, it is not a particularly efficient use of memory resources.
In an embodiment of an image skew determination method as described herein where the image is received in scanline order, the pixels in each incoming scanline will project over a small number of rows. In particular, for each document angle, it is possible to calculate the number of rows P into which each incoming scanline will project. For an angle α expressed in radians, the number of row sums a scanline can project onto, <i>P</i><sub><i>α</i></sub>, is approximately (<i>αM</i>) + 1, where <i>M</i> is the number of pixels per scanline. At the end of each processed scanline, the memory holds the sum for one complete projected line plus partial sums next (<i>P</i><sub><i>α</i></sub><i> -</i> 1) lines. In other words, there is one memory location that will not be written to by subsequent scanlines. This projected row sum is complete, and can be squared and accumulated into a running sum of squares calculation. The memory holding the completed row (one for each angle) may be freed for a new row sum onto which the subsequent scanline will project.
More specifically, if the projected scanline crosses 100 rows, only 100 memory locations will be needed to store the sums for that angle. Each incoming pixel would map to one of the 100 rows and increment the corresponding memory locations. For each new scanline received, one projected scanline would be completed and the square of the row sum is calculated and accumulated. The corresponding memory location would be freed for the new scanline. To calculate the sums for an angle of 0°, the projected scanlines are identical to the incoming scanlines. A single memory register may be used to contain the sum.
The above process can be illustrated by way of example with reference to FIGS. <b>8</b> and <b>9</b> where there are shown the projections of a plurality of scanlines, at rotations of 0° and α, respectively. In particular, Fig. <b>8</b> shows three scanlines <b>70, 72</b> and <b>74</b> at 0° rotation projected onto rows y, y+1, and y+2, respectively. The projected row sum for 0° rotation angle is simply the sum of the ON pixels in row y. Similarly, the projected row sums for 0° for rows y+1 and y+2 , is simply the sum of the ON pixels in scanlines <b>72</b> and <b>74</b>, respectively. Fig. <b>9</b> shows the projection of the three scanlines <b>70, 72</b> and <b>74</b> at document rotation angle α. As can be seen from FIG. <b>9</b>, the projected row sum for row y at angle α is the number of ON pixels in the set of pixels 1 - X<sub>1</sub> of scanline <b>70.</b> The projected row sum for row y+1 at angle α is the number of ON pixels in pixels 1 - X<sub>1</sub> of scanline <b>72</b> plus the number of ON pixels in the set of pixels X<sub>1</sub> - X<sub>2</sub> of scanline <b>70.</b> Similarly, the projected row sum for row y+2 is the number of ON pixels in pixels 1 - X<sub>1</sub> of scanline <b>74</b> plus the number of ON pixels in pixels X<sub>1</sub> - X<sub>2</sub> of scanline <b>72</b> plus number of ON pixels within pixels X<sub>2</sub> - X<sub>3</sub> of scanline <b>70.</b>
In accordance with the reduced memory requirements described above, only four memory locations (L<sub>0</sub> - L<sub>3</sub>) are required to accumulate the row sums for rows y, y+1, and y+2 for document rotations of 0° and α. When scanline <b>70</b> is received, pixels 1 - X<sub>3</sub> are summed and stored in memory L<sub>0</sub>. In parallel, scanline <b>70</b> is rotated to angle α and the number of ON within pixel sets 1 - X<sub>1</sub>, X<sub>1</sub> - X<sub>2</sub>, and X<sub>2</sub> - X<sub>3</sub> of scanline <b>70</b> are added to memory locations L<sub>1</sub>, L<sub>2</sub>, and L<sub>3</sub>, respectively. At this point in processing, memory locations L<sub>0</sub> and L<sub>1</sub> hold the projected row sums for row y for angles 0° and α, and locations L<sub>2</sub> and L<sub>3</sub> hold the partial projected row sums for angle α for rows y+1 and y+2, respectively. The sums accumulated in memory locations L<sub>0</sub> and L<sub>1</sub> are squared and accumulated to second order moment for angles 0° and α, respectively. Memory locations L<sub>0</sub> and L<sub>1</sub> are then cleared and freed for use to begin to accumulate new row sums upon receipt of the next scanline.
Next, scanline <b>72</b> is received and, in accordance with the rotation to angles 0° and α, the number of ON pixels within scanline is added to memory location L<sub>0</sub> and becomes the row sum for row y+1 for angle 0°. In parallel the number of ON within pixel sets 1 - X<sub>1</sub>, X<sub>1</sub> - X<sub>2</sub>, and X<sub>2</sub> - X<sub>3</sub> of scanline <b>72</b> are added to memory locations L<sub>2</sub>, L<sub>3</sub>, and L<sub>1</sub>, respectively. At this point in processing, the projected row sums for row y+1 for angles 0° and α are completed and held in memory locations L<sub>0</sub> and L<sub>2</sub>, respectively. Locations L<sub>3</sub> and L<sub>1</sub> hold the partial row sums for rows y+2 and y+3, respectively. The row sums in L<sub>0</sub> and L<sub>2</sub> are squared and accumulated to second order moment for angles 0° and α, respectively. Memory locations L<sub>0</sub> and L<sub>2</sub> are then freed for use to begin to accumulate new row sums upon receipt of the next scanline.
Scanline <b>74</b> is then received and rotated to angles 0° and α. The number of ON pixels within scanline <b>74</b> is added to memory location L<sub>0</sub> and becomes the row sum for row y+2 for angle 0°. In parallel the number of ON within pixel sets 1 - X<sub>1</sub>, X<sub>1</sub> - X<sub>2</sub>, and X<sub>2</sub> - X<sub>3</sub> of scanline <b>74</b> are added to memory locations L<sub>3</sub>, L<sub>1</sub>, and L<sub>2</sub>, respectively. At this point in processing, locations L<sub>0</sub> and L<sub>3</sub> hold the projected row sums for row y+2 for angles 0° and α, and L<sub>1</sub> and L<sub>2</sub> hold the partial row sums for rows y+3 and y+4, respectively. The projected row sums accumulated in memory locations L<sub>0</sub> and L<sub>3</sub> are squared and accumulated to second order moment for angles 0° and α, respectively. Memory locations L<sub>0</sub> and L<sub>3</sub> are then cleared and freed for use upon receipt of the next scanline.
As should be appreciated, this above described approach significantly decreases the required memory to implement the algorithm. For hardware implementations, such as in an ASIC or FPGA, the entire memory required for A rotation angles over N scanlines may be implemented internal to the device. Using the original approach, an external memory device would be required to implementing the algorithm. For a software implementation, reducing the required memory may allow all accesses to be from cache instead of needing to access main memory. This would greatly increase the speed of execution.
In the embodiment of determining image skew of a scanned document described above with reference to FIG. <b>2</b>, image skew is determined by calculating the second order projected moment in both the fast scan and slow scan direction for several predetermined rotation angles in parallel. In calculating the second order projected moment in both the and slow scan direction, each pixel is projected onto a given column sum for each of the angles being considered. Thus, for every pixel processed each rotation angle requires a memory location to be incremented. The incremented memory location corresponds to the column the pixel would be projected into for that rotation angle. A memory increment requires 2 memory access operations: one read and one write; thus, for every scanline, this results in 2*<i>A</i>*<i>M</i> memory access, where <i>A</i> is the number of skew angles metrics being determined and <i>M</i> is the number of pixels per scanline. This update could either be done using 2*<i>A</i> memory accesses per pixel, or by doing 2*<i>A</i>*<i>M</i> memory accesses in the interline gap.
The bandwidth requirements make performance in real time an intractable problem when using currently available external memory devices as an external memory component precludes parallel accesses to the memory. Thus, the high bandwidth cannot be supported. The solution requires either the use of on chip cache for software solutions, or onchip memory for a dedicated hardware solution. For software implementations, the memory size required to hold the column sums may prevent it all being held in cache. When implementing the algorithm in hardware, such as an FPGA or ASIC, the size of the memory requires use of an external memory component, due to the size of the column sums. If the memory could be implemented in internal memory, the memory accesses could be done in parallel by implementing multiport memories and by using multiple small memories.
One approach to address this limitation is to use partial parallelism to perform the task. Using partial parallelization, it is possible to operate on several scanlines at once. Assuming the images are received a row at a time, the algorithm to calculate the column sums may be implemented over a "band" of rows. The updates of the external memory that contain the column sums are done only once per band of rows instead of every row. It is assumed that the band is sufficiently small to allow it to be held in cache for software implementations or in internal memory for hardware implementations. When a band of <i>B</i> rows are received, the projected column sums may be calculated for the <i>B</i> rows; shifted versions of the rows are summed together and the resulting partial sum is then used to update the external memory. Each angle still requires 2*<i>A</i>*<i>M</i> (actually, 2*<i>A</i>*(<i>M</i>+1)) updates, but updates now consist of adding a number between 0 and <i>B</i> to every projected sum location for each angle. This is in contrast of the previous update strategy of just possibly incrementing a memory location; the width of the number added has been increased in exchange for a greatly reduced bandwidth. Here again, the total number of memory accesses for the <i>B</i> rows will be 2*<i>A</i>*(<i>M</i>+1). However, the total memory accesses, and thus bandwitdth, to the "column sum" memory has been reduced by nearly a factor of <i>B</i>.
The cache requirements of the system have increased; previously only 1 scanline needed to be in memory. The implementation described above requires the use of <i>B</i> scanlines of memory in cache. The greater the number of scanlines <i>B</i> within the band, the faster the algorithm will run at the cost of "cache/internal" memory. Where the image is being received a row at a time, the algorithm need run only as fast as the data is being received and the buffer. Thus, <i>B</i> should be minimized to match the speed of the incoming data. However, it should be appreciated that additional memory is required to receive the next <i>B</i> band of rows while the current band of <i>B</i> rows are being processed. Thus, the above process would require 2*<i>B</i>*<i>M</i> pixels of cache or internal storage.
An alternate solution employs only one additional line of buffering. With a band of <i>B</i> complete lines available, the may be processed one angle at a time. However, instead of updating all <i>A</i> angles during the time it takes to receive the <i>B</i> scanlines (as discussed above), only <i>A</i>/<i>B</i> angles are updated in the time it takes for the new row to be received. That is, only the column sums for certain set of rotation angles are updated as each scanline is received, but after every B scanlines the column sums for all the rotation angles have been updated once. It should be appreciated that this process is analogous to the concept of time division multiplexing.
More specifically, as each new row (scanline) is received, the newly received row is "rotated" into the band and the oldest row in the band is freed to accept the next incoming row. As the incoming row is being received, the next set of <i>A</i>/<i>B</i> angles is processed and updated. In the time <i>B</i> rows are received, all <i>A</i> angles have been processed. That is, the above algorithm comprises three steps: (a) obtaining a new scanline of image data, (b) updating columns sums for a set of rotation angles using scanlines of image data within a buffer comprising a band of scanlines, and (c) updating the buffer with the newly obtained scanline using a first in, first out priority. Beneficially, the steps of obtaining a new scanline and updating column sums are performed in parallel. The total memory required is reduced to (<i>B</i>+1)*<i>M</i> pixels of cache, instead of 2*<i>B</i>*<i>M</i> slots, with no increase in external memory bandwidth requirements.
One embodiment of the above process is illustrated with reference to Table (1). As scanline 4 is obtained, the column sums for the rotation angles within angle set 1 are updated using the image data within the buffer (scanlines 1 through 3). After row 4 has been obtained and the column sums for angle set 1 have been updated, the buffer is updated in a first in, first out priority to rotate scanline 4 into the buffer and push out scanline 1. Similarly, as scanline 5 is being obtained, the column sums for the rotation angles within angle set 2 are updated using the scanlines within buffer (scanlines 2 through 4). After row 5 has been obtained, the buffer is updated to rotate in scanline 5 and rotate out scanline 2. This process can be repeated through the scan of the document. <tables id="tabl0001" num="0001"><img file="EP1431908A2_D0006.tif" /></tables>
What has thus been described is a memory efficient method for calculating the fast scan second order moments required to compute the skew of an image. There has also been described a method to reduce the number of memory accesses needed when calculating the slow scan second order moments employed in a method to compute skew of a scanned an image.
While particular embodiments have been described, alternatives, modifications, variations, improvements, and substantial equivalents that are or may be presently unforeseen may arise to applicants or others skilled in the art. Accordingly, the appended claims as filed and as they may be amended are intended to embrace all such alternatives, modifications variations, improvements, and substantial equivalents.
15 sheets
Sheet 1 Sheet 2 Sheet 3 Sheet 4 Sheet 5 Sheet 6 Sheet 7 Sheet 8 Sheet 9 Sheet 10 Sheet 11 Sheet 12 Sheet 13 Sheet 14 Sheet 15
Every citation, both ways
| Document | Relation | Office | Cited during |
|---|---|---|---|
| US5199101A | Cites | United States of America | Search report |
| US5506918A | Cites | United States of America | Search report |
9 members in 4 offices
Priority claims4
| Document | Office | Kind | Date |
|---|---|---|---|
| 321922 | United States of America | – | |
| 32192202 | United States of America | A | |
| 321922 | – | – | – |
| US20020321922 | – | – | – |
Members9
| Document | Office | Kind | |
|---|---|---|---|
| US2004114831A1 | United States of America | A1 | |
| EP1431908A2This record | European Patent Office (EPO) | A2 | |
| JP2004199679A | Japan | A | |
| EP1431908A3 | European Patent Office (EPO) | A3 | |
| EP1431908B1 | European Patent Office (EPO) | B1 | |
| DE60304983D1 | Germany | D1 | |
| DE60304983T2 | Germany | T2 | |
| US7142727B2 | United States of America | B2 | |
| JP4574981B2 | Japan | B2 |
31 legal events, as 4 offices reported them to INPADOC
Over the term
Point at a mark for the eventEvents
| Event | Code | Office | |
|---|---|---|---|
| Lapsed in a contracting state [announced via postgrant information from national office to epo]LapsedPG25 | PG25 | EP | |
| Lapsed in a contracting state [announced via postgrant information from national office to epo]LapsedPG25 | PG25 | EP | |
| Lapsed in a contracting state [announced via postgrant information from national office to epo]LapsedPG25 | PG25 | EP | |
| Notification of lapseLapsedST | ST | FR | |
| Gb: european patent ceased through non-payment of renewal feeCeasedGBPC | GBPC | EP | |
| Application deemed withdrawn, or ip right lapsed, due to non-payment of renewal feeWithdrawnR119 | R119 | DE | |
| Annual fee paid to national office [announced via postgrant information from national office to epo]GrantedPGFP | PGFP | EP | |
| Annual fee paid to national office [announced via postgrant information from national office to epo]GrantedPGFP | PGFP | EP | |
| Annual fee paid to national office [announced via postgrant information from national office to epo]GrantedPGFP | PGFP | EP | |
| No opposition filedOpposition26N | 26N | EP | |
| No opposition filed within time limitOppositionORIGINAL CODE: 0009261PLBE | PLBE | EP | |
| Information on the status of an ep patent application or granted ep patentGrantedSTATUS: NO OPPOSITION FILED WITHIN TIME LIMITSTAA | STAA | EP | |
| Fr: translation filedET | ET | EP | |
| Corresponds to:REF | REF | EP | |
| Designated contracting statesAK | AK | EP | |
| European patent grantedGrantedFG4D | FG4D | GB | |
| (expected) grantORIGINAL CODE: 0009210GRAA | GRAA | EP | |
| Grant fee paidORIGINAL CODE: EPIDOSNIGR3GRAS | GRAS | EP | |
| Despatch of communication of intention to grant a patentORIGINAL CODE: EPIDOSNIGR1GRAP | GRAP | EP | |
| Designation fees paidAKX | AKX | EP | |
| First examination report despatched17Q | 17Q | EP | |
| Request for examination filed17P | 17P | EP | |
| Designated contracting statesAK | AK | EP | |
| Request for extension of the european patentAX | AX | EP | |
| Information provided on ipc code assigned before grantRIC1 | RIC1 | EP | |
| Information provided on ipc code assigned before grantRIC1 | RIC1 | EP | |
| Information provided on ipc code assigned before grantRIC1 | RIC1 | EP | |
| Search report despatchedORIGINAL CODE: 0009013PUAL | PUAL | EP | |
| Designated contracting statesAK | AK | EP | |
| Request for extension of the european patentAX | AX | EP | |
| Public reference made under article 153(3) epc to a published international application that has entered the european phaseORIGINAL CODE: 0009012PUAI | PUAI | EP |
Numbers
- Publication
- 1431908
- Publication, DOCDB
- 1431908
- Publication, EPODOC
- EP1431908
- Application
- 3029013
- Application, DOCDB
- 03029013
- Application, EPODOC
- EP20030029013
Titles3
- German
- Nicht-iteratives Verfahren zur Berechnung der Schräglage von Bildern
- English
- Non-iterative method of calculating image skew
- French
- Méthode non-itérative pour calculer l'inclinaison d'images
Classification
- CPC, 1
- G06K9/3283
- IPC, 2
- G06T7 60
- G06K9 32
Designated states31
- Contracting states, 27
- Germany
- France
- United Kingdom
- Austria
- Belgium
- Bulgaria
- Switzerland
- Cyprus
- Czechia
- Denmark
- Estonia
- Spain
- Finland
- Greece
- Hungary
- Ireland
- Italy
- Liechtenstein
- Luxembourg
- Monaco
- Netherlands (Kingdom of the)
- Portugal
- Romania
- Sweden
and 3 moreShow fewer
- Slovenia
- Slovakia
- Türkiye
- Extension states, 4
- Albania
- Lithuania
- Latvia
- North Macedonia