CN105426887B - A kind of method and device of text image correction - Google Patents

A kind of method and device of text image correction Download PDF

Info

Publication number
CN105426887B
CN105426887B CN201510727019.0A CN201510727019A CN105426887B CN 105426887 B CN105426887 B CN 105426887B CN 201510727019 A CN201510727019 A CN 201510727019A CN 105426887 B CN105426887 B CN 105426887B
Authority
CN
China
Prior art keywords
text image
image
pixel
text
submodule
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510727019.0A
Other languages
Chinese (zh)
Other versions
CN105426887A (en
Inventor
李甫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201510727019.0A priority Critical patent/CN105426887B/en
Publication of CN105426887A publication Critical patent/CN105426887A/en
Application granted granted Critical
Publication of CN105426887B publication Critical patent/CN105426887B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/24Aligning, centring, orientation detection or correction of the image
    • G06V10/242Aligning, centring, orientation detection or correction of the image by image rotation, e.g. by 90 degrees

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Editing Of Facsimile Originals (AREA)
  • Character Input (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the invention provides a kind of method and devices of text image correction.The specific embodiment of the method includes: the text image to be corrected for obtaining white gravoply, with black engraved characters;The text image to be corrected is pre-processed, the first text image of the black matrix wrongly written or mispronounced character of binaryzation is obtained;Multiple rotary is carried out with counter clockwise direction along clockwise direction by preset rules to first text image, every rotation once calculates the pixel value of postrotational first text image, obtains the pixel gap number of lines of the first text image after rotation every time;The maximum rotation angle of pixel gap number of lines is determined as to correct rotation angle;The text image to be corrected is rotated into the correction rotation angle, the text image after being corrected.Using the present embodiment, it can be realized and inclined text image is quickly corrected, reduce calculation amount.

Description

A kind of method and device of text image correction
Technical field
The present invention relates to image technique field, in particular to a kind of method and device of text image correction.
Background technique
Currently, the demand that people read mobile terminal is higher and higher, although the text images technology such as textual scan is existing Significant increase, but obtained text image is still difficult to meet the reading needs of people.One of them critically important problem Exactly obtained text image is inclined.Therefore, obtained inclination text image is corrected, just becomes text point Analyse pretreated important link.
In the prior art, the main thought of text image correction is detection text image inclination angle, and detection method is mainly wrapped Include the method based on Hough transform, the method based on Fourier transformation and method based on crossing dependency etc..These methods All calculation amount is larger, and algorithm is complicated.
Summary of the invention
The method and device for being designed to provide a kind of text image correction of the embodiment of the present invention, to realize to inclined Text image is quickly corrected, and calculation amount is reduced.
In order to achieve the above object, the embodiment of the invention discloses a kind of method of text image correction, the method packets It includes:
A. the text image to be corrected of white gravoply, with black engraved characters is obtained;
B. the text image to be corrected is pre-processed, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation;
C. multiple rotary is carried out with counter clockwise direction along clockwise direction by preset rules to first text image, often Rotation once calculates the pixel value of postrotational first text image, obtains the picture of the first text image after rotation every time Plain blank number of lines;The maximum rotation angle of pixel gap number of lines is determined as to correct rotation angle;
D. the text image to be corrected is rotated into the correction rotation angle, the text image after being corrected.
Preferably, the step C, comprising:
C1. first text image is rotated in a clockwise direction first angle low, obtains the second text image;It will First text image is rotated in the counterclockwise direction second angle high, obtains third text image;The low's and high Initial value is preset value;
C2. the pixel value of second text image and third text image is calculated respectively, obtains described second The pixel gap number of lines numlow of the text image and pixel gap number of lines numhigh of third text image;
C3. the pixel gap by the pixel gap number of lines numlow of second text image, with third text image Number of lines numhigh is compared;If the numlow is less than the numhigh, the first angle low is updated to (low+high)/2;If the numlow is not less than the numhigh, the second angle high is updated to (low+ high)/2;
C4. judge whether the first angle low and the absolute value of the difference of second angle high are less than preset first threshold Value, if it is, (low+high)/2 is the maximum rotation angle of pixel gap number of lines, by (the low+ High)/2 it is determined as the correction rotation angle of first text image, executes step D;If it is not, then returning to the step C1.
Preferably, described pre-process the text image to be corrected, the first of the black matrix wrongly written or mispronounced character of binaryzation is obtained Text image, comprising:
After carrying out binary image processing to the text image to be corrected, the inverse processing of black matrix wrongly written or mispronounced character is carried out, is obtained First text image of black matrix wrongly written or mispronounced character.
Preferably, described carry out binary image processing to the text image to be corrected, comprising:
Gray processing processing is carried out to the text image to be corrected of white gravoply, with black engraved characters, obtains one-dimensional gray matrix image;
Second threshold is calculated using Otsu algorithm;The second threshold is so that between two class of black font and white background The maximum threshold value of variance;
Binary conversion treatment is carried out to the one-dimensional gray matrix image with the second threshold, obtains binary image.
Preferably, carrying out the inverse of black matrix wrongly written or mispronounced character after carrying out binary image processing to the text image to be corrected Before processing, further includes:
Obtained binary image is filtered using median filtering algorithm, obtains smooth binary image;
The inverse processing for carrying out black matrix wrongly written or mispronounced character, are as follows: inverse processing is carried out to smooth binary image, obtains black matrix First text image of wrongly written or mispronounced character.
Preferably, the initial value of the first angle low and second angle high, are as follows: a preset positive value and one Negative value;And absolute value is between 10 degree~45 degree.
Preferably, described respectively calculate the pixel value of second text image and third text image, obtain The pixel gap number of lines numlow of the second text image and pixel gap number of lines numhigh of third text image, Include:
Second text image and third text image are scanned as unit of pixel respectively, obtain each pixel Pixel value;
The pixel value is summed line by line, obtains second text image and the every row of third text image respectively Pixel value and value;
The line number for counting the pixel column pixel value and that value is zero, respectively obtains second text image and third Pixel gap the number of lines numlow and numhigh of text image.
In order to achieve the above object, the embodiment of the invention discloses a kind of device of text image correction, described device packets It includes:
Text image obtains module, for obtaining the text image to be corrected of white gravoply, with black engraved characters;
Text image preprocessing module obtains the black of binaryzation for pre-processing to the text image to be corrected First text image of bottom wrongly written or mispronounced character;
Correct rotation angle determining module, for first text image by preset rules along clockwise direction and the inverse time Needle direction carries out multiple rotary, and every rotation once calculates the pixel value of postrotational first text image, obtains each The pixel gap number of lines of first text image after rotation;The maximum rotation angle of pixel gap number of lines is determined as correction rotation Corner;
Text image correction module is corrected for the text image to be corrected to be rotated the correction rotation angle Text image afterwards.
Preferably, the correction rotation angle determining module, comprising: rotation submodule, computational submodule, Comparative sub-module and Judging submodule;
The rotation submodule is obtained for first text image to be rotated in a clockwise direction first angle low Second text image;First text image is rotated in the counterclockwise direction second angle high, obtains third text image; The initial value of the low and high is preset value;
The computational submodule, carry out by the pixel value respectively to second text image and third text image based on It calculates, obtains the pixel gap number of lines numlow of second text image and the pixel gap number of lines of third text image numhigh;
The Comparative sub-module, for by the pixel gap number of lines numlow of second text image, with third text The pixel gap number of lines numhigh of this image is compared;If the numlow is less than the numhigh, by described the One angle low is updated to (low+high)/2;If the numlow is not less than the numhigh, by the second angle High is updated to (low+high)/2;
The judging submodule, for judge the first angle low and second angle high absolute value of the difference whether Less than preset threshold, if it is, (low+high)/2 is the maximum rotation angle of pixel gap number of lines, it will be described (low+high)/2 be determined as the correction rotation angle of first text image, trigger the text image correction module and carry out Text image correction;If it is not, then the rotation submodule is triggered, into next circulation.
Preferably, the text image preprocessing module includes: binaryzation submodule and inverse submodule;
The binaryzation submodule, for carrying out binary image processing to the text image to be corrected;
The inverse submodule carries out black matrix after carrying out binary image processing to the text image to be corrected The inverse of wrongly written or mispronounced character is handled, and obtains the first text image of black matrix wrongly written or mispronounced character.
Preferably, the binaryzation submodule includes: gray proces submodule, second threshold computational submodule and binaryzation Handle submodule;
Gray proces submodule carries out gray processing processing for the text image to be corrected to white gravoply, with black engraved characters, obtains one-dimensional Gray matrix image;
Second threshold computational submodule, for calculating second threshold using Otsu algorithm;The second threshold is so that black The maximum threshold value of variance between two class of color font and white background;
Binary conversion treatment submodule, for being carried out at binaryzation with the second threshold to the one-dimensional gray matrix image Reason, obtains binary image.
Preferably, the text image preprocessing module, further includes: smooth submodule;
The smooth submodule, for carrying out black after carrying out binary image processing to the text image to be corrected Before the inverse processing of bottom wrongly written or mispronounced character, obtained binary image is filtered using median filtering algorithm, obtains smooth two-value Change image;
The inverse submodule, is specifically used for: the inverse for carrying out black matrix wrongly written or mispronounced character to smooth binary image is handled, and is obtained First text image of black matrix wrongly written or mispronounced character.
Preferably, the initial value of the first angle low and second angle high, are as follows: a preset positive value and one Negative value;And absolute value is between 10 degree~45 degree.
Preferably, the computational submodule includes: scanning submodule, summation submodule and statistic submodule;
The scanning submodule, for second text image and third text image respectively as unit of pixel into Row scanning, obtains the pixel value of each pixel;
The summation submodule obtains second text image for the pixel value to be summed line by line respectively With the pixel value of the every row of third text image and value;
The statistic submodule respectively obtains institute for counting the line number of the pixel column pixel value and that value is zero State pixel gap the number of lines numlow and numhigh of the second text image and third text image.
As seen from the above technical solution, the embodiment of the present invention first pre-processes text image to be corrected, obtains two First text image of the black matrix wrongly written or mispronounced character of value, then to first text image by preset rules along clockwise direction with it is inverse Clockwise carries out multiple rotary, and every rotation once calculates the pixel value of postrotational first text image, obtains every The pixel gap number of lines of first text image after secondary rotation, the maximum rotation angle of pixel gap number of lines are to correct rotation The text image to be corrected is finally rotated the correction rotation angle, the text image after can be obtained correction by angle.
That is, using the embodiment of the present invention, it is more to being carried out by pretreated text image according to preset rules Secondary rotation, counts the pixel gap number of lines of text image after rotation every time, and the maximum rotation angle of pixel gap number of lines is Rotation angle is corrected, rotation angle is corrected accordingly to correct text image, inclined text image is quickly corrected with realizing, is subtracted Few calculation amount.Certainly, implement any of the products of the present invention or method it is not absolutely required at the same reach all the above excellent Point.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described.It should be evident that the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is a kind of flow diagram of the method for text image correction provided in an embodiment of the present invention;
Fig. 2 is the flow diagram that step S103 determines correction rotation angle using two points of iterative methods in Fig. 1;
Fig. 3 is a kind of structural schematic diagram of the device of text image correction provided in an embodiment of the present invention;
Fig. 4 is the structural schematic diagram of the device of another text image correction provided in an embodiment of the present invention;
Fig. 5 is inclination text image schematic diagram;
Fig. 6 is the postrotational effect diagram of white gravoply, with black engraved characters text image;
Fig. 7 is black matrix wrongly written or mispronounced character text image schematic diagram;
Fig. 8 is pixel gap number of lines statistical result schematic diagram 1;
Fig. 9 is pixel gap number of lines statistical result schematic diagram 2;
Figure 10 is the text image schematic diagram after correction.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Whole description.Obviously, described embodiment is only a part of the embodiments of the present invention, instead of all the embodiments.Base Embodiment in the present invention, those of ordinary skill in the art are obtained all without making creative work Other embodiments shall fall within the protection scope of the present invention.
The embodiment of the invention provides a kind of method and devices of text image correction.In this scenario, first to acquisition The text image to be corrected of white gravoply, with black engraved characters pre-processed, obtain the first text image of the black matrix wrongly written or mispronounced character of binaryzation.Then, Multiple rotary is carried out along clockwise direction with counter clockwise direction by preset rules to first text image, every rotation is primary right The pixel value of postrotational first text image is calculated, and the pixel gap line number of the first text image after rotation every time is obtained Mesh, and the maximum rotation angle of pixel gap number of lines is determined as to correct rotation angle.Finally, by the text image to be corrected Rotate the correction rotation angle, the text image after being corrected.
Below by specific embodiment, the present invention is described in detail.
Fig. 1 is a kind of flow diagram of the method for text image correction provided in an embodiment of the present invention, including walks as follows It is rapid:
Step S101: the text image to be corrected of white gravoply, with black engraved characters is obtained.
It is assumed that the text image to be corrected of the white gravoply, with black engraved characters obtained is as shown in figure 5, text image is inclined.
Step S102: pre-processing the text image to be corrected, obtains the first text of the black matrix wrongly written or mispronounced character of binaryzation This image.
It is described that the text image to be corrected is pre-processed, obtain the first text diagram of the black matrix wrongly written or mispronounced character of binaryzation Picture may include:
After carrying out binary image processing to the text image to be corrected, the inverse processing of black matrix wrongly written or mispronounced character is carried out, is obtained First text image of black matrix wrongly written or mispronounced character.
In practical applications, binary image processing carried out to the text image to be corrected, and by white gravoply, with black engraved characters Text image to be corrected rotated after, newly-increased non-image areas is often filled to be black, as shown in Figure 6.In this way Subsequent pixel gap row statistical operation can be impacted.Therefore, it is necessary to the inverse of black matrix wrongly written or mispronounced character is carried out to binary image Processing.It handles, i.e., schemes the text image inverse of white gravoply, with black engraved characters for the text image of black matrix wrongly written or mispronounced character and then rotation by inverse When picture, then influence of the non-image areas to image-region can be eliminated, as shown in Figure 7.
It is described that binary image processing is carried out to the text image to be corrected, may include:
Gray processing processing is carried out to the text image to be corrected of white gravoply, with black engraved characters, obtains one-dimensional gray matrix image;Using big Saliva algorithm calculates second threshold;Binary conversion treatment is carried out to the one-dimensional gray matrix image with the second threshold, obtains two Value image.
Specifically, the second threshold is the maximum threshold value of variance so that between two class of black font and white background.
After carrying out binary image processing to the text image to be corrected, before the inverse processing for carrying out black matrix wrongly written or mispronounced character, It can also include: to be filtered using median filtering algorithm to obtained binary image, obtain smooth binary image.This Sample, the inverse processing for carrying out black matrix wrongly written or mispronounced character, can be with are as follows: carry out inverse processing to smooth binary image, obtain black matrix First text image of wrongly written or mispronounced character.
In practical applications, it needs to include: that there are printing ink or thin in scan text image by the case where median filtering The isolated noise points such as micro dust.
Step S103: first text image is carried out repeatedly with counter clockwise direction along clockwise direction by preset rules Rotation, every rotation once calculate the pixel value of postrotational first text image, obtain the first text after rotation every time The pixel gap number of lines of image;The maximum rotation angle of pixel gap number of lines is determined as to correct rotation angle.
In practical applications, first text image is carried out with counter clockwise direction along clockwise direction by preset rules Multiple rotary, every rotation is primary, is just once calculated the pixel value of postrotational first text image, obtains rotation every time The pixel gap number of lines of first text image afterwards.For example, the pixel gap number of lines statistical result of text image shown in Fig. 7 is shown It is intended to as shown in figure 8, pixel gap number of lines statistical result schematic diagram of the Fig. 7 after 7 degree of rotation counterclockwise is as shown in Figure 9. Wherein, the black region on the right side of Fig. 8 and Fig. 9 on vertical bar represents pixel gap row, and white area represents non-pixel gap row.
Specifically, determining that the method that can use two points of iteration shown in Fig. 2 determines inclination text when correcting rotation angle The correction rotation angle of image;It can also be using first rotating by a certain angle to a direction, then according to text image after rotation Pixel gap number of lines is increased or reduces, final to determine correction rotation to instruct the direction of rotation and the angle of rotation Corner;Or can also calculate angled hereafter this image pixel gap number of lines, therefrom find out pixel gap line number The maximum rotation angle of mesh determines correction rotation angle.For example, the pixel gap number of lines in Fig. 9 is greater than the pixel gap row in Fig. 8 Number result can continue to rotate text image accordingly, and pixel gap number of lines is most when finding " along 6 degree of rotation counterclockwise " Until big, then can determine that correction rotation angle is " along 6 degree of rotation counterclockwise " at this time.
Step S104: the text image to be corrected is rotated into the correction rotation angle, the text image after being corrected.
For example, rotating Fig. 5 according to the correction rotation angle " along 6 degree of rotation counterclockwise " determined in step S103, finally obtaining Image after correction, as shown in Figure 10.
As seen from the above, it in the present embodiment, is repeatedly revolved to by pretreated text image according to preset rules Turn, counts the pixel gap number of lines of text image after rotation every time, the maximum rotation angle of pixel gap number of lines is school Dextrorotation corner corrects rotation angle accordingly to correct text image, is quickly corrected with realizing to inclined text image, reduced Calculation amount.
In the following, being directed to step S103, elaborates and determine inclination text image correction rotation using two points of iterative methods The specific steps at angle.
Fig. 2 is that step S103 determines that the process for tilting text image correction rotation angle is illustrated using two points of iterative methods in Fig. 1 Figure comprising following steps:
Step S201: first text image is rotated in a clockwise direction first angle low, obtains the second text diagram Picture;First text image is rotated in the counterclockwise direction second angle high, obtains third text image.
Specifically, the initial value of the low and high is preset value, is specifically as follows: a preset positive value and one Negative value, and absolute value is greater than the correction rotation angle between 10 degree~45 degree.
Step S202: respectively calculating the pixel value of second text image and third text image, obtains institute State the pixel gap number of lines numlow of the second text image and the pixel gap number of lines numhigh of third text image.
Specifically, described that the pixel value of second text image and third text image is calculated respectively, it obtains The pixel gap number of lines numlow of the second text image and pixel gap number of lines numhigh of third text image, May include:
Second text image and third text image are scanned as unit of pixel respectively, obtain each pixel Pixel value;
The pixel value is summed line by line, obtains second text image and the every row of third text image respectively Pixel value and value;
The line number for counting the pixel column pixel value and that value is zero, respectively obtains second text image and third Pixel gap the number of lines numlow and numhigh of text image.
In practical application, when counting the line number of the pixel column pixel value and that value is zero, a threshold can be set Value, for example, it is 3 that the threshold value, which can be set,.When pixel value is when being less than the threshold value with value, so that it may think behavior blank line. Certainly, it is that other values are also possible that the threshold value, which is arranged,.
Step S203: the picture by the pixel gap number of lines numlow of second text image, with third text image Plain blank number of lines numhigh is compared;If the numlow is less than the numhigh, more by the first angle low Newly it is (low+high)/2;If the numlow is not less than the numhigh, the second angle high is updated to (low +high)/2。
Specifically, the pixel by the pixel gap number of lines numlow of second text image, with third text image Blank number of lines numhigh is compared;If the numlow is less than the numhigh, the first angle low is updated For (low+high)/2, the second angle high is constant;If the numlow is not less than the numhigh, by described the Two angle high are updated to (low+high)/2, and the first angle low is constant.
Step S204: it is preset to judge whether the absolute value of the difference of the first angle low and second angle high is less than First threshold, if it is, (low+high)/2 is the maximum rotation angle of pixel gap number of lines, it will be described (low+high)/2 it is determined as the correction rotation angle of first text image, executes step S104;If it is not, then described in returning Step S201.
Specifically, judge whether the absolute value of the difference of the first angle low and second angle high are less than preset the One threshold value, if it is, (low+high)/2 be the maximum rotation angle of pixel gap number of lines, wherein low or High is updated value, and (low+high)/2 is determined as to the correction rotation angle of first text image, is executed Step S104;If it is not, then the step S201 is returned to, into next circulation.
In the following, elaborating again in conjunction with specific example to the application.
It is assumed that the first text image is as shown in fig. 7, the initial value of the first angle low and second angle high is distinguished For -10 degree and+10 degree.Wherein, "+" number indicates that along counterclockwise, "-" number is indicated along clockwise.Assuming that first threshold is 0.01 degree.
Fig. 7 is rotated in a clockwise direction 10 degree, obtains the second text image pic1 by step S201;By Fig. 7 along counterclockwise Direction rotates 10 degree, obtains third text image pic2.
Step S202 respectively calculates the pixel value of pic1 and pic2, obtains the pixel gap number of lines of pic1 Numlow is 0, obtains the pixel gap number of lines numhigh of pic2, is 80.
Step S203, by the pixel gap number of lines numhigh of pixel gap the number of lines numlow and pic2 of pic1 into Row compares, it is seen that the value 0 of numlow is less than the value 80 of numhigh, then first angle low is updated to (- 10+10)/2 degree, i.e., 0 Degree, second angle high is constant, remains as+10 degree.
It is preset to judge whether the absolute value of the difference of the first angle low and second angle high is less than by step S204 Whether first threshold, low or high at this time is updated value, that is, judge the value of │ 0-10 │ less than 0.01 degree, it is clear that judgement The result is that "No", then return step S201.
After recycling into second, the value of the low and high are respectively 0 and+10 degree, and the value of numlow is 40, The value of numhigh is that the value of 80, numlow is less than the value of numhigh, and first angle low is updated to (0+10)/2=+5 degree, Second angle high is that+10 degree are constant, and │ 5-10 │ is not less than first threshold 0.01, return step S201;
After recycling into third time, the value of the low and high are respectively+5 degree and+10 degree, and the value of numlow is 90, The value of numhigh is that the value of 80, numlow is not less than the value of numhigh, and second angle high is updated to (5+10)/2=+ 7.5 degree, first angle low is that+5 degree are constant, and │ 5-7.5 │ is not less than first threshold 0.01, return step S201;
Into after the 4th circulation, the value of the low and high are respectively+5 degree and+7.5 degree, and the value of numlow is 90, The value of numhigh is that the value of 85, numlow is not less than the value of numhigh, and second angle high is updated to (5+7.5)/2=+ 6.25 degree, first angle low is that+5 degree are constant, and │ 5-6.25 │ is not less than first threshold 0.01, return step S201;
Into next circulation.
Assuming that less than 0.01, circulation terminates │ low-high │ after recycling into n-th, it may show that correction rotation angle is (low+high)/2=6 degree.
As seen from the above, it in the present embodiment, is repeatedly revolved to by pretreated text image according to preset rules Turn, counts the pixel gap number of lines of text image after rotation every time, the maximum rotation angle of pixel gap number of lines is school Dextrorotation corner corrects rotation angle accordingly to correct text image, is quickly corrected with realizing to inclined text image, reduced Calculation amount.Meanwhile in the present embodiment, correction rotation angle is calculated by the way of two points of iteration, improves the meter of correction rotation angle Calculate efficiency.
Fig. 3 is a kind of structural schematic diagram of the device of text image correction provided in an embodiment of the present invention, and shown in FIG. 1 Process is corresponding, comprising: text image obtains module 301, text image preprocessing module 302, correction rotation angle determining module 303 and text image correction module 304.
Wherein, text image obtains module 301, for obtaining the text image to be corrected of white gravoply, with black engraved characters;
Text image preprocessing module 302 obtains binaryzation for pre-processing to the text image to be corrected First text image of black matrix wrongly written or mispronounced character;
Correct rotation angle determining module 303, for first text image by preset rules along clockwise direction and Multiple rotary is counterclockwise carried out, every rotation once calculates the pixel value of postrotational first text image, obtains The pixel gap number of lines of first text image after rotating every time;The maximum rotation angle of pixel gap number of lines is determined as school Dextrorotation corner;
Text image correction module 304 obtains school for the text image to be corrected to be rotated the correction rotation angle Text image after just.
In the present embodiment, text image preprocessing module 302 may include: binaryzation submodule and inverse submodule (figure In be not shown).Wherein, binaryzation submodule, for carrying out binary image processing to the text image to be corrected;Inverse Module carries out the inverse processing of black matrix wrongly written or mispronounced character, obtains after carrying out binary image processing to the text image to be corrected First text image of black matrix wrongly written or mispronounced character.
Further, the binaryzation submodule may include: gray proces submodule, second threshold computational submodule and Binary conversion treatment submodule (not shown).Wherein, gray proces submodule, for the text diagram to be corrected to white gravoply, with black engraved characters As carrying out gray processing processing, one-dimensional gray matrix image is obtained;Second threshold computational submodule, for being calculated using Otsu algorithm Second threshold;Binary conversion treatment submodule, for carrying out binaryzation to the one-dimensional gray matrix image with the second threshold Processing, obtains binary image.Specifically, the second threshold is the variance so that between two class of black font and white background Maximum threshold value.
The text image preprocessing module 302 can also include: smooth submodule (not shown).Wherein, smoothly Submodule, for after carrying out binary image processing to the text image to be corrected, carrying out the inverse processing of black matrix wrongly written or mispronounced character Before, obtained binary image is filtered using median filtering algorithm, obtains smooth binary image.In this way, described Inverse submodule specifically can be used for: the inverse for carrying out black matrix wrongly written or mispronounced character to smooth binary image is handled, and obtains black matrix wrongly written or mispronounced character The first text image.
As seen from the above, it in the present embodiment, is repeatedly revolved to by pretreated text image according to preset rules Turn, counts the pixel gap number of lines of text image after rotation every time, the maximum rotation angle of pixel gap number of lines is school Dextrorotation corner corrects rotation angle accordingly to correct text image, is quickly corrected with realizing to inclined text image, reduced Calculation amount.
Fig. 4 is the structural schematic diagram of the device of another text image correction provided in an embodiment of the present invention, the device packet Include: text image obtains module 301, text image preprocessing module 302, correction rotation angle determining module 303 and text image Correction module 304.
Wherein, correction rotation angle determining module 303 includes: rotation submodule 3031, computational submodule 3032, compares submodule Block 3033 and judging submodule 3034.
The rotation submodule 3031, for first text image to be rotated in a clockwise direction first angle low, Obtain the second text image;First text image is rotated in the counterclockwise direction second angle high, obtains third text Image.
In the present embodiment, the initial value of the low and high are preset values, which is specifically as follows a positive value and one Negative value, and absolute value is greater than the correction rotation angle between 10 degree~45 degree.
The computational submodule 3032, for the pixel value respectively to second text image and third text image into Row calculates, and obtains the pixel gap number of lines numlow of second text image and the pixel gap row of third text image Number numhigh.
In the present embodiment, the computational submodule 3032 may include: scanning submodule, summation submodule and statistics submodule Block (not shown).Wherein, submodule is scanned, is used for second text image and third text image respectively with pixel It is scanned for unit, obtains the pixel value of each pixel;Summation submodule, for the pixel value to be summed line by line, Obtain respectively the pixel value of second text image and the every row of third text image and value;Statistic submodule, for counting The line number of the pixel column pixel value and that value is zero, respectively obtains the picture of second text image and third text image Plain blank number of lines numlow and numhigh.
The Comparative sub-module 3033, for by the pixel gap number of lines numlow of second text image, with The pixel gap number of lines numhigh of three text images is compared;If the numlow is less than the numhigh, by institute It states first angle low and is updated to (low+high)/2;If the numlow is not less than the numhigh, by described second jiao Degree high is updated to (low+high)/2;
The judging submodule 3034, for judging the absolute value of the difference of the first angle low and second angle high Whether preset threshold is less than, if it is, (low+high)/2 is the maximum rotation angle of pixel gap number of lines, it will (low+high)/2 is determined as the correction rotation angle of first text image, triggers text image correction module 304; If it is not, then triggering rotation submodule 3031.
As seen from the above, it in the present embodiment, is repeatedly revolved to by pretreated text image according to preset rules Turn, counts the pixel gap number of lines of text image after rotation every time, the maximum rotation angle of pixel gap number of lines is school Dextrorotation corner corrects rotation angle accordingly to correct text image, is quickly corrected with realizing to inclined text image, reduced Calculation amount.
For device embodiment, since it is substantially similar to the method embodiment, related so describing fairly simple Place illustrates referring to the part of embodiment of the method.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or any other variant be intended to it is non- It is exclusive to include, so that the process, method, article or equipment for including a series of elements not only includes those elements, It but also including other elements that are not explicitly listed, or further include solid by this process, method, article or equipment Some elements.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including There is also other identical elements in the process, method, article or equipment of the element.
It will appreciated by the skilled person that all or part of the steps in above embodiment is can to pass through journey What sequence instructed relevant hardware to complete, the program can store in computer-readable storage medium.It is designated herein Storage medium refers to ROM/RAM, magnetic disk, CD etc..
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all Any modification, equivalent substitution, improvement and etc. done within the spirit and principles in the present invention, are all contained in protection scope of the present invention It is interior.

Claims (14)

1. a kind of method of text image correction, which is characterized in that the described method includes:
A. the text image to be corrected of white gravoply, with black engraved characters is obtained;
B. the text image to be corrected is pre-processed, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation;
C. multiple rotary, every rotation are carried out with counter clockwise direction along clockwise direction by preset rules to first text image Once the pixel value of postrotational first text image is calculated, obtains the pixel sky of the first text image after rotation every time White number of lines;The maximum rotation angle of pixel gap number of lines is determined as to correct rotation angle;
D. the text image to be corrected is rotated into the correction rotation angle, the text image after being corrected.
2. the method according to claim 1, wherein the step C, comprising:
C1. first text image is rotated in a clockwise direction first angle low, obtains the second text image;It will be described First text image is rotated in the counterclockwise direction second angle high, obtains third text image;The low's and high is initial Value is preset value;
C2. the pixel value of second text image and third text image is calculated respectively, obtains second text The pixel gap number of lines numlow of the image and pixel gap number of lines numhigh of third text image;
C3. the pixel gap line number by the pixel gap number of lines numlow of second text image, with third text image Mesh numhigh is compared;If the numlow is less than the numhigh, the first angle low is updated to (low+ high)/2;If the numlow is not less than the numhigh, the second angle high is updated to (low+high)/2;
C4. judge whether the first angle low and the absolute value of the difference of second angle high are less than preset first threshold, such as Fruit is that then (low+high)/2 is the maximum rotation angle of pixel gap number of lines, by (low+high)/2 It is determined as the correction rotation angle of first text image, executes step D;If it is not, then returning to the step C1.
3. the method according to claim 1, wherein described pre-process the text image to be corrected, Obtain the first text image of the black matrix wrongly written or mispronounced character of binaryzation, comprising:
After carrying out binary image processing to the text image to be corrected, the inverse processing of black matrix wrongly written or mispronounced character is carried out, black matrix is obtained First text image of wrongly written or mispronounced character.
4. according to the method described in claim 3, it is characterized in that, described carry out binary picture to the text image to be corrected As processing, comprising:
Gray processing processing is carried out to the text image to be corrected of white gravoply, with black engraved characters, obtains one-dimensional gray matrix image;
Second threshold is calculated using Otsu algorithm;The second threshold is the side so that between two class of black font and white background The maximum threshold value of difference;
Binary conversion treatment is carried out to the one-dimensional gray matrix image with the second threshold, obtains binary image.
5. according to the method described in claim 3, it is characterized in that, carrying out binary image to the text image to be corrected After processing, before the inverse processing for carrying out black matrix wrongly written or mispronounced character, further includes:
Obtained binary image is filtered using median filtering algorithm, obtains smooth binary image;
The inverse processing for carrying out black matrix wrongly written or mispronounced character, are as follows: inverse processing is carried out to smooth binary image, obtains black matrix wrongly written or mispronounced character The first text image.
6. according to the method described in claim 2, it is characterized in that, the first angle low's and second angle high is initial Value, are as follows: a preset positive value and a negative value;And absolute value is between 10 degree~45 degree.
7. according to the method described in claim 2, it is characterized in that, described respectively to second text image and third text The pixel value of image is calculated, and the pixel gap number of lines numlow and third text diagram of second text image are obtained The pixel gap number of lines numhigh of picture, comprising:
Second text image and third text image are scanned as unit of pixel respectively, obtain the picture of each pixel Element value;
The pixel value is summed line by line, obtains the pixel of second text image and the every row of third text image respectively Be worth and value;
The line number for counting the pixel column pixel value and that value is zero, respectively obtains second text image and third text Pixel gap the number of lines numlow and numhigh of image.
8. a kind of device of text image correction, which is characterized in that described device includes:
Text image obtains module, for obtaining the text image to be corrected of white gravoply, with black engraved characters;
Text image preprocessing module obtains the white with black of binaryzation for pre-processing to the text image to be corrected First text image of word;
Correction rotation angle determining module, for along clockwise direction and square counterclockwise by preset rules to first text image To multiple rotary is carried out, every rotation once calculates the pixel value of postrotational first text image, obtains rotation every time The pixel gap number of lines of first text image afterwards;The maximum rotation angle of pixel gap number of lines is determined as correction rotation Angle;
Text image correction module, for the text image to be corrected to be rotated the correction rotation angle, after being corrected Text image.
9. device according to claim 8, which is characterized in that the correction rotation angle determining module, comprising: rotation submodule Block, computational submodule, Comparative sub-module and judging submodule;
The rotation submodule obtains second for first text image to be rotated in a clockwise direction first angle low Text image;First text image is rotated in the counterclockwise direction second angle high, obtains third text image;It is described The initial value of low and high is preset value;
The computational submodule is calculated for the pixel value respectively to second text image and third text image, Obtain the pixel gap number of lines numlow of second text image and the pixel gap number of lines of third text image numhigh;
The Comparative sub-module, for by the pixel gap number of lines numlow of second text image, with third text diagram The pixel gap number of lines numhigh of picture is compared;If the numlow is less than the numhigh, by described first jiao Degree low is updated to (low+high)/2;If the numlow is not less than the numhigh, more by the second angle high Newly it is (low+high)/2;
The judging submodule, for judging whether the absolute value of the difference of the first angle low and second angle high is less than Preset threshold, if it is, (low+high)/2 is the maximum rotation angle of pixel gap number of lines, it will be described (low+high)/2 it is determined as the correction rotation angle of first text image, triggers the text image correction module and carry out text This image rectification;If it is not, then the rotation submodule is triggered, into next circulation.
10. device according to claim 8, which is characterized in that the text image preprocessing module includes: two-value beggar Module and inverse submodule;
The binaryzation submodule, for carrying out binary image processing to the text image to be corrected;
The inverse submodule carries out black matrix wrongly written or mispronounced character after carrying out binary image processing to the text image to be corrected Inverse processing, obtain black matrix wrongly written or mispronounced character the first text image.
11. device according to claim 10, which is characterized in that the binaryzation submodule includes: gray proces submodule Block, second threshold computational submodule and binary conversion treatment submodule;
Gray proces submodule carries out gray processing processing for the text image to be corrected to white gravoply, with black engraved characters, obtains one-dimensional gray scale Matrix image;
Second threshold computational submodule, for calculating second threshold using Otsu algorithm;The second threshold is so that black word The maximum threshold value of variance between two class of body and white background;
Binary conversion treatment submodule, for carrying out binary conversion treatment to the one-dimensional gray matrix image with the second threshold, Obtain binary image.
12. device according to claim 10, which is characterized in that the text image preprocessing module, further includes: smooth Submodule;
The smooth submodule, for carrying out white with black after carrying out binary image processing to the text image to be corrected Before the inverse processing of word, obtained binary image is filtered using median filtering algorithm, obtains smooth binary picture Picture;
The inverse submodule, is specifically used for: the inverse for carrying out black matrix wrongly written or mispronounced character to smooth binary image is handled, and obtains black matrix First text image of wrongly written or mispronounced character.
13. device according to claim 9, which is characterized in that the first angle low's and second angle high is initial Value, are as follows: a preset positive value and a negative value;And absolute value is between 10 degree~45 degree.
14. device according to claim 9, which is characterized in that the computational submodule includes: scanning submodule, summation Submodule and statistic submodule;
The scanning submodule, for being swept as unit of pixel respectively to second text image and third text image It retouches, obtains the pixel value of each pixel;
The summation submodule obtains second text image and for the pixel value to be summed line by line respectively The pixel value of the every row of three text images and value;
The statistic submodule respectively obtains described for the line number of pixel column that count the pixel value and that value is zero Pixel gap the number of lines numlow and numhigh of two text images and third text image.
CN201510727019.0A 2015-10-30 2015-10-30 A kind of method and device of text image correction Active CN105426887B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510727019.0A CN105426887B (en) 2015-10-30 2015-10-30 A kind of method and device of text image correction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510727019.0A CN105426887B (en) 2015-10-30 2015-10-30 A kind of method and device of text image correction

Publications (2)

Publication Number Publication Date
CN105426887A CN105426887A (en) 2016-03-23
CN105426887B true CN105426887B (en) 2019-04-12

Family

ID=55505086

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510727019.0A Active CN105426887B (en) 2015-10-30 2015-10-30 A kind of method and device of text image correction

Country Status (1)

Country Link
CN (1) CN105426887B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107992869B (en) * 2016-10-26 2020-09-22 深圳超多维科技有限公司 Method and device for correcting tilted characters and electronic equipment
CN106997470A (en) * 2017-02-28 2017-08-01 信雅达***工程股份有限公司 Tilt bearing calibration and the system of text image
CN107103587B (en) * 2017-06-05 2023-04-21 新疆大学 Method and device for correcting inclination of biochip image
CN108647681B (en) * 2018-05-08 2019-06-14 重庆邮电大学 A kind of English text detection method with text orientation correction
CN110969052A (en) * 2018-09-29 2020-04-07 杭州萤石软件有限公司 Operation correction method and equipment
CN109345462A (en) * 2018-11-29 2019-02-15 北京京东尚科信息技术有限公司 Image processing method, device and computer readable storage medium
CN109993161B (en) * 2019-02-25 2021-08-03 众安信息技术服务有限公司 Text image rotation correction method and system
CN109977959B (en) * 2019-03-29 2021-07-06 国家电网有限公司 Train ticket character area segmentation method and device
CN110211047B (en) * 2019-04-10 2023-04-07 陕西理工大学 Image rotation method for machine vision thread parameter measurement

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101425142A (en) * 2008-09-17 2009-05-06 北大方正集团有限公司 Method and device for determining page angle of slope
CN101639933A (en) * 2009-07-16 2010-02-03 上海合合信息科技发展有限公司 Image rotation correction method and system and electronic device
CN103714327A (en) * 2013-12-30 2014-04-09 上海合合信息科技发展有限公司 Method and system for correcting image direction
CN104834930A (en) * 2015-05-25 2015-08-12 山东中孚信息产业股份有限公司 Image Chinese character search method for multi system platform

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI425444B (en) * 2009-02-20 2014-02-01 Avermedia Information Inc Method and device for detecting and correcting skewed image data
US20110052094A1 (en) * 2009-08-28 2011-03-03 Chunyu Gao Skew Correction for Scanned Japanese/English Document Images

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101425142A (en) * 2008-09-17 2009-05-06 北大方正集团有限公司 Method and device for determining page angle of slope
CN101639933A (en) * 2009-07-16 2010-02-03 上海合合信息科技发展有限公司 Image rotation correction method and system and electronic device
CN103714327A (en) * 2013-12-30 2014-04-09 上海合合信息科技发展有限公司 Method and system for correcting image direction
CN104834930A (en) * 2015-05-25 2015-08-12 山东中孚信息产业股份有限公司 Image Chinese character search method for multi system platform

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
文本图像倾斜校正算法的研究与应用;吴飞飞;《中国优秀硕士学位论文全文数据库 信息科技辑》;20140915;I138-942第1-42页

Also Published As

Publication number Publication date
CN105426887A (en) 2016-03-23

Similar Documents

Publication Publication Date Title
CN105426887B (en) A kind of method and device of text image correction
CN112348815B (en) Image processing method, image processing apparatus, and non-transitory storage medium
KR101733539B1 (en) Character recognition device and control method thereof
CN111951290B (en) Edge detection method and device for object in image
Mohammad et al. Optical character recognition implementation using pattern matching
CN103080950B (en) Two-dimensional code reader and program
CN109409366A (en) Distorted image correction method and device based on Corner Detection
US8189952B2 (en) Image noise reduction method based on local correlation
CN111178355B (en) Seal identification method, device and storage medium
CN101807257A (en) Method for identifying information of image tag
EP2605186B1 (en) Method and apparatus for recognizing a character based on a photographed image
CN103714327A (en) Method and system for correcting image direction
CN111259878A (en) Method and equipment for detecting text
CN107992869B (en) Method and device for correcting tilted characters and electronic equipment
CN106845314B (en) A kind of method for rapidly positioning of two dimensional code
US10136103B2 (en) Identifying consumer products in images
US9858481B2 (en) Identifying consumer products in images
CN111275049B (en) Method and device for acquiring text image skeleton feature descriptors
CN113705673A (en) Character detection method, device, equipment and storage medium
Arvind et al. Line removal and restoration of handwritten strokes
Smith et al. Effect of" ground truth" on image binarization
CN114820621A (en) Bolt loss defect detection method, system and device
CN107545259A (en) A kind of Quick Response Code reconstructing method based on Da-Jin algorithm
Shi et al. Image enhancement for degraded binary document images
CN108701204A (en) A kind of method and device of one-dimension code positioning

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant