A kind of automatic correction method for tilted image
Technical field
The present invention relates to a kind of digital image processing method, particularly relate to a kind of method of automatic correct tilt image.
Background technology
In the file scan process, the situation that scanning document occurs through regular meeting can be given consulting and handle and bringing very big inconvenience of file like this.Therefore detection and the correction to the input picture angle of inclination is absolutely necessary.Slant correction to image at first needs the angle of inclination of image is detected, and adjusts according to detected angle of inclination again, and image is adjusted to neat position.
So-called slant correction technology just is meant by the angle of inclination of the text that detects the scanner input, image etc. is undertaken from normal moveout correction.Calculate the correct angle of document image by the orientation of mesh lines in the document and literal.This technology both can be used alone the pre-service that also can be used as OCR (optical character identification) and use.
The slant correction of image mainly divide manual correction with from two kinds of normal moveout correction.Manual correction mainly is to proofread and correct by observation of naked eyes etc.Can analyze image from normal moveout correction, judge the angle of inclination of image, then image be corrected automatically.The shortcoming of the correction software that some is traditional is to cause jagged image border.
Existing disposal route of automatically tilted image being proofreaied and correct comprises: section sciagraphy, Hough transform method, crossing dependency method, adjacent feature point clustering procedure etc., below one one is introduced:
The section sciagraphy is along the projection value maximum of certain feature of the section of text vergence direction in text.This disposal route is by suitable structural energy function, can obtain reasonable effect, but this method relies on character area to a great extent, for the less image of character area, can't obtain satisfied effect.
Hough transformation (Hough transform) is the basic skills to rim detection in the image and Geometric Shape Recognition, it has utilized the characteristic of Hough transformation, with the polar coordinate space of videoing of the foreground pixel in the image, obtain the angle of inclination of image by the accumulated value of statistics polar coordinate space each point.But Hough transformation is also just more effective to the image of plain text.
The crossing dependency method is to adopt the thought of calculated crosswise to carry out the angle of inclination detection.The principal direction that this algorithm has solved literal line change and document in comprise the problem of figure and table, be the higher algorithm of a kind of accuracy, but arithmetic accuracy is lower.
Adjacent feature point clustering procedure is a kind of inclination angle detection method based on statistics.By improving, can solve the interference that chart brings, obtain reasonable effect, but because this method obtains the result based on statistics, so needing has more character area in the image, otherwise can be because the unique point of participate in calculating be less, can't obtain abundant statistics and influence final result.
More than four kinds be more common method during the angle of inclination is detected.And in fact, a lot of disposal routes all are the wherein combinations of several thinkings.From the processing procedure of four kinds of disposal routes as can be seen, for plain text document, these methods can both obtain reasonable treatment effect.But for chart, and the less digital picture of character area, effect is just relatively poor relatively.So most disposal routes all rely on character area, and do not take into account the useful information of image.In addition, most of disposal route all is from the content detail of document image and relation, and not from the one-piece construction of image, and some information in the image is helpful for the angle of inclination of judging image.
Therefore how handling the tilted image of content complexity such as including literal, figure, table simultaneously, become the focus of research, also is the key point that improves accuracy of detection and accuracy.
Summary of the invention
Technical matters to be solved by this invention is to provide a kind of automatic correction method for tilted image, and it can be discerned and the correct tilt image automatically, guaranteeing cheaply simultaneously, improves the accuracy of Flame Image Process.
To achieve these goals, the invention provides a kind of automatic correction method for tilted image, it can catch the angle of inclination of original image automatically, and with its adjustment, its characteristics are that this method comprises the steps: to scan this original image, obtain the pixel value of this original image; With this original image binaryzation; Datum line of match in this original image; Determine the angle of inclination of image according to this datum line; And image is adjusted according to this angle of inclination.
Above-mentioned automatic correction method for tilted image, its characteristics are, also comprise original image is carried out pre-service, the step of the noise in the removal of images.
Above-mentioned automatic correction method for tilted image, its characteristics are, also comprise this original image is carried out the step that the edge strengthens.
Above-mentioned automatic correction method for tilted image, its characteristics are that the step of a datum line of this match also comprises: determine selected pixel; In this original image, set in regular turn and treat alignment; Calculate each selected pixel and treat the mean distance of alignment to this; This mean value and a distance threshold are compared; And if this mean distance less than this distance threshold, should current wire tag undetermined be a datum line then.
Above-mentioned automatic correction method for tilted image, its characteristics are that this distance threshold is 1/3rd of this line length undetermined.
Above-mentioned automatic correction method for tilted image, its characteristics are that this selected pixel is the non-isolated set of pixels of overall number greater than the number threshold value.
Above-mentioned automatic correction method for tilted image, its characteristics are that this number threshold value is 3.
Above-mentioned automatic correction method for tilted image, its characteristics be, sets the step for the treatment of alignment in regular turn, for from an end of this original image to the other end, set in order according to a preset distance and to treat alignment.
Above-mentioned automatic correction method for tilted image, its characteristics are, also comprise the step of eliminating noise pixel in the selected pixel.
Above-mentioned automatic correction method for tilted image, its characteristics be, this noise pixel is compared pixel greater than a prearranged multiple for the distance for the treatment of alignment to this with this mean distance.
Effect of the present invention is to catch automatically the file of inclination, and with its rotation, one-piece construction from image, angle by match best base directrix obtains tilting has characteristics such as accuracy height, strong robustness, fast operation, also is suitable for for most of ORC system simultaneously.
Describe the present invention below in conjunction with the drawings and specific embodiments, but not as a limitation of the invention.
Description of drawings
Fig. 1 is the overview flow chart of the automatic correction method for tilted image that the present invention carried;
Fig. 2 is the process flow diagram of match datum line of the present invention;
Fig. 3 is the operation workflow figure of the embodiment of the invention;
Fig. 4 is the synoptic diagram of the selected pixel of the embodiment of the invention; And
Fig. 5 is the synoptic diagram of the noise pixel in the selected pixel of the embodiment of the invention.
Wherein, Reference numeral:
Step 110-obtains the pixel value of original image
Step 120-is with this original image binaryzation
Step 130-is datum line of match in this original image
Step 140-determines the angle of inclination of image according to this datum line
Step 150-adjusts image according to this angle of inclination
Step 1301-determines selected pixel
Step 1302-sets in regular turn in this original image and treats alignment
Step 1303-calculates each selected pixel is treated alignment to this mean distance
Step 1304-compares this mean value and a distance threshold
Step 1305-was if this mean distance less than this distance threshold, should current wire tag undetermined be a datum line then
Step 310-obtains bitmap images
Step 320-arrives extra buffer with copying image
Step 330-edge strengthens
Step 340-carries out binaryzation to image
Step 350-determines selected pixel
Step 360-match datum line
Is the absolute value at step 370-angle of inclination between 0.1 ~ 30?
Step 380-withdraws from
Step 390-rotates image
The 410-isolated pixel, the 420-set of pixels
Noise point in the selected pixel of 510-, 520-treats alignment
Embodiment
Under a lot of situations, the original image that we obtain all is a complex image, and it may not only have plain text, also may comprise various figure and table, and the content in the text may be vertically also may be horizontal.Font also may be various simultaneously.Various noises appear in the scanning process inevitably.Dreamboat output of the present invention is that a width of cloth is without any the image that tilts.
The present invention is a kind of automatic correction method for tilted image, at first by Fig. 1 system of the present invention is described, this figure is the overview flow chart of the automatic correction method for tilted image that the present invention carried, and is described as follows:
Step 110, at first scan this original image, obtain the pixel value of this original image, step 120 is then with this original image binaryzation, step 130, datum line of match in this original image, step 140 is determined the angle of inclination of image according to this datum line, step 150 is adjusted image according to this angle of inclination at last.
In said process, the process of match datum line sees also Fig. 2, and this figure is the process flow diagram of match datum line of the present invention.
Step 1301, at first determine selected pixel, step 1302 is set in regular turn in this original image then and is treated alignment, step 1303, calculate each selected pixel and treat the mean distance of alignment to this, step 1304 compares this mean value and a distance threshold, step 1305, if this mean distance less than this distance threshold, should current wire tag undetermined be a datum line then, described distance threshold is 1/3rd of this line length undetermined.
Concrete processing procedure sees also Fig. 3, and this figure is the operation workflow figure of the embodiment of the invention.
Step 310 at first obtains the original bitmap image, and original image is by optical instrument, as image scanner, facsimile recorder or any photographic goods, image changed in the computing machine obtains.Step 320 arrives extra buffer with copying image then, image is carried out pre-service, the noise in the removal of images.Step 330 is carried out the edge enhancement process to image again, strengthens the edge in the image, so that post-treatment operations.Step 340 is then carried out binaryzation to gray scale and colored image, and step 350 is determined selected pixel then, and selected pixel is the non-isolated set of pixels of overall number greater than a number threshold value.See also Fig. 4, be the synoptic diagram of the selected pixel of the embodiment of the invention.The number threshold value is 3 in the present embodiment, that is to say, number is selected pixel greater than the set of 3 non-isolated pixel.As shown in the figure, pixel 410 is an isolated pixel, and set of pixels 420 is selected pixel.The noise point that to select again in the pixel is eliminated, and the noise point in the selected pixel is meant the point that the match datum line is not had reference value.More particularly the noise pixel is compared pixel greater than a prearranged multiple for the distance for the treatment of alignment to this with this mean distance.As shown in Figure 5, this figure is the synoptic diagram of the noise pixel in the selected pixel of the embodiment of the invention.The set 510 of pixel is the noise point in the selected pixel, it is to the distance D for the treatment of alignment 520, treat to this that than all selected pixels the mean distance of alignment 520 is big, and the difference of this distance D and this mean distance is a predetermined value, this predetermined value is the product of this mean distance and a preset parameter.In image, set the step for the treatment of alignment in this way in regular turn, from an end of this original image to the other end (for example from the top to the bottom), set in order according to a preset distance and to treat alignment, step 360, according to flow process match datum line shown in Figure 2, until simulating satisfactory datum line.Step 370, whether the absolute value of judging this datum line angle of inclination then between 0.1 ~ 30, if not between this angular range, illustrates that then there is not the angle of inclination in original image, then need not rotation; If whether the absolute value at this datum line angle of inclination between 0.1 ~ 30, then with the image rotation, thereby is adjusted the position of original image.
Certainly; the present invention also can have other various embodiments; under the situation that does not deviate from spirit of the present invention and essence thereof; those of ordinary skill in the art can make various corresponding changes and distortion according to the present invention, but these corresponding changes and distortion all should belong to the protection domain of claim of the present invention.