CN105426887A - Method and device for text image correction - Google Patents

Method and device for text image correction Download PDF

Info

Publication number
CN105426887A
CN105426887A CN201510727019.0A CN201510727019A CN105426887A CN 105426887 A CN105426887 A CN 105426887A CN 201510727019 A CN201510727019 A CN 201510727019A CN 105426887 A CN105426887 A CN 105426887A
Authority
CN
China
Prior art keywords
text image
pixel
image
line number
value
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.)
Granted
Application number
CN201510727019.0A
Other languages
Chinese (zh)
Other versions
CN105426887B (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 invention provides a method and a device for text image correction. The method comprises steps that a white-ground black-character to-be-corrected text image is acquired; pre-processing on the to-be-corrected text image can be carried out to acquire a binary black-ground white-character first text image; the first text image is made to rotate for multiple times according to preset rules in the clockwise direction and in the anticlockwise direction, and a pixel value of the first text image after each rotation is calculated to acquire a pixel blank line number of the first text image after each rotation; a rotation angle with the largest pixel blank line number is determined to be a correction rotation angle; the to-be-corrected text image is made to rotate by the correction rotation angle, and the text image after correction is acquired. Through the method, the inclined text image can be rapidly corrected, and computational complexity is reduced.

Description

A kind of method that text image corrects and device
Technical field
The present invention relates to image technique field, particularly a kind of method that corrects of text image and device.
Background technology
At present, the demand that people read mobile terminal is more and more higher, although the text image technology such as textual scan have significant increase, the text image obtained still is difficult to the reading needs meeting people.The text image that one of them very important problem obtains tilts.Therefore, the inclination text image obtained is corrected, just become the pretreated important step of text analyzing.
In prior art, the main thought that text image corrects detects text image pitch angle, and detection method mainly comprises based on the method for Hough transform, based on the method for Fourier conversion and the method etc. based on crossing dependency.These methods all calculated amount are comparatively large, and algorithm is complicated.
Summary of the invention
A kind of method that the object of the embodiment of the present invention is to provide text image to correct and device, carrying out Fast Correction with the text image realized tilting, reducing calculated amount.
In order to achieve the above object, the embodiment of the invention discloses a kind of method that text image corrects, described method comprises:
A. the text image to be corrected of white gravoply, with black engraved characters is obtained;
B. pre-service is carried out to described text image to be corrected, obtain the first text image of the black matrix wrongly written or mispronounced character of binaryzation;
C. along clockwise direction with counterclockwise multiple rotary is carried out by preset rules to described first text image, often rotate and once the pixel value of postrotational first text image is calculated, obtain each pixel blank line number rotating rear first text image; The anglec of rotation maximum for pixel blank line number is defined as correct rotation angle;
D. described text image to be corrected is rotated described correction rotation angle, obtain the text image after correcting.
Preferably, described step C, comprising:
C1. described first text image is rotated in a clockwise direction the first angle low, obtains the second text image; Described first text image is rotated the second angle high in the counterclockwise direction, obtains the 3rd text image; The initial value of described low and high is preset value;
C2. respectively the pixel value of described second text image and the 3rd text image is calculated, obtain the pixel blank line number numlow of described second text image, and the pixel blank line number numhigh of the 3rd text image;
C3. by the pixel blank line number numlow of described second text image, compare with the pixel blank line number numhigh of the 3rd text image; If described numlow is less than described numhigh, then described first angle low is updated to (low+high)/2; If described numlow is not less than described numhigh, then described second angle high is updated to (low+high)/2;
C4. judge whether the absolute value of the difference of described first angle low and the second angle high is less than default first threshold, if, then described (low+high)/2 are the maximum anglec of rotation of pixel blank line number, described (low+high)/2 are defined as the correction rotation angle of described first text image, perform step D; If not, then described step C1 is returned.
Preferably, described pre-service is carried out to described text image to be corrected, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation, comprising:
After binary image process is carried out to described text image to be corrected, carry out the inverse process of black matrix wrongly written or mispronounced character, obtain the first text image of black matrix wrongly written or mispronounced character.
Preferably, described binary image process is carried out to described text image to be corrected, comprising:
Gray processing process is carried out to the text image to be corrected of white gravoply, with black engraved characters, obtains one dimension gray matrix image;
Otsu algorithm is adopted to calculate Second Threshold; Described Second Threshold is the threshold value making the variance between black font and white background two class maximum;
With described Second Threshold, binary conversion treatment is carried out to described one dimension gray matrix image, obtain binary image.
Preferably, after binary image process is carried out to described text image to be corrected, before carrying out the inverse process of black matrix wrongly written or mispronounced character, also comprise:
Adopt median filtering algorithm to carry out filtering to the binary image obtained, obtain level and smooth binary image;
The described inverse process carrying out black matrix wrongly written or mispronounced character, for: inverse process is carried out to level and smooth binary image, obtains the first text image of black matrix wrongly written or mispronounced character.
Preferably, the initial value of described first angle low and the second angle high, for: preset one on the occasion of with a negative value; And absolute value is between 10 degree ~ 45 degree.
Preferably, describedly respectively the pixel value of described second text image and the 3rd text image to be calculated, obtain the pixel blank line number numlow of described second text image, and the pixel blank line number numhigh of the 3rd text image, comprising:
Described second text image and the 3rd text image are scanned respectively in units of pixel, obtains the pixel value of each pixel;
Described pixel value is sued for peace line by line, obtain respectively the pixel value that described second text image and the 3rd text image often go and value;
What add up described pixel value is the line number of the pixel column of zero with value, obtains pixel blank line number numlow and numhigh of described second text image and the 3rd text image respectively.
In order to achieve the above object, the embodiment of the invention discloses the device that a kind of text image corrects, described device comprises:
Text image obtains module, for obtaining the text image to be corrected of white gravoply, with black engraved characters;
Text image pretreatment module, for carrying out pre-service to described text image to be corrected, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation;
Correct rotation angle determination module, for carrying out multiple rotary to described first text image along clockwise direction with counterclockwise by preset rules, often rotate and once the pixel value of postrotational first text image is calculated, obtain each pixel blank line number rotating rear first text image; The anglec of rotation maximum for pixel blank line number is defined as correct rotation angle;
Text image correction module, for described text image to be corrected is rotated described correction rotation angle, obtains the text image after correcting.
Preferably, described correction rotation angle determination module, comprising: gyrator module, calculating sub module, comparison sub-module and judgement submodule;
Described gyrator module, for described first text image is rotated in a clockwise direction the first angle low, obtains the second text image; Described first text image is rotated the second angle high in the counterclockwise direction, obtains the 3rd text image; The initial value of described low and high is preset value;
Described calculating sub module, for calculating the pixel value of described second text image and the 3rd text image respectively, obtains the pixel blank line number numlow of described second text image, and the pixel blank line number numhigh of the 3rd text image;
Described comparison sub-module, for the pixel blank line number numlow by described second text image, compares with the pixel blank line number numhigh of the 3rd text image; If described numlow is less than described numhigh, then described first angle low is updated to (low+high)/2; If described numlow is not less than described numhigh, then described second angle high is updated to (low+high)/2;
Described judgement submodule, whether the absolute value for the difference judging described first angle low and the second angle high is less than predetermined threshold value, if, then described (low+high)/2 are the maximum anglec of rotation of pixel blank line number, described (low+high)/2 are defined as the correction rotation angle of described first text image, trigger described text image correction module and carry out text image correction; If not, then trigger described gyrator module, enter next circulation.
Preferably, described text image pretreatment module comprises: binaryzation submodule and inverse submodule;
Described binaryzation submodule, for carrying out binary image process to described text image to be corrected;
Described inverse submodule, after carrying out binary image process to described text image to be corrected, carries out the inverse process of black matrix wrongly written or mispronounced character, obtains the first text image of black matrix wrongly written or mispronounced character.
Preferably, described binaryzation submodule comprises: gray proces submodule, Second Threshold calculating sub module and binary conversion treatment submodule;
Gray proces submodule, for carrying out gray processing process to the text image to be corrected of white gravoply, with black engraved characters, obtains one dimension gray matrix image;
Second Threshold calculating sub module, calculates Second Threshold for adopting Otsu algorithm; Described Second Threshold is the threshold value making the variance between black font and white background two class maximum;
Binary conversion treatment submodule, for carrying out binary conversion treatment with described Second Threshold to described one dimension gray matrix image, obtains binary image.
Preferably, described text image pretreatment module, also comprises: level and smooth submodule;
Described level and smooth submodule, for after carrying out binary image process to described text image to be corrected, before carrying out the inverse process of black matrix wrongly written or mispronounced character, adopts median filtering algorithm to carry out filtering to the binary image obtained, obtains level and smooth binary image;
Described inverse submodule, specifically for: the inverse process level and smooth binary image being carried out to black matrix wrongly written or mispronounced character, obtains the first text image of black matrix wrongly written or mispronounced character.
Preferably, the initial value of described first angle low and the second angle high, for: preset one on the occasion of with a negative value; And absolute value is between 10 degree ~ 45 degree.
Preferably, described calculating sub module comprises: scanning submodule, summation submodule and statistics submodule;
Described scanning submodule, for scanning in units of pixel respectively described second text image and the 3rd text image, obtains the pixel value of each pixel;
Described summation submodule, for described pixel value is sued for peace line by line, obtain respectively the pixel value that described second text image and the 3rd text image often go and value;
Described statistics submodule, is the line number of the pixel column of zero with value for what add up described pixel value, obtains pixel blank line number numlow and numhigh of described second text image and the 3rd text image respectively.
As seen from the above technical solution, first the embodiment of the present invention carries out pre-service to text image to be corrected, obtain the first text image of the black matrix wrongly written or mispronounced character of binaryzation, then along clockwise direction with counterclockwise multiple rotary is carried out by preset rules to described first text image, often rotate and once the pixel value of postrotational first text image is calculated, obtain each pixel blank line number rotating rear first text image, the maximum anglec of rotation of pixel blank line number is correction rotation angle, finally described text image to be corrected is rotated described correction rotation angle, the text image after correction can be obtained.
That is, the application embodiment of the present invention, multiple rotary is carried out according to preset rules to through pretreated text image, the each pixel blank line number rotating rear text image of statistics, the maximum rotation angle of pixel blank line number is correction rotation angle, correct rotation angle accordingly and correct text image, carrying out Fast Correction with the text image realized tilting, reducing calculated amount.Certainly, arbitrary product of the present invention is implemented or method might not need to reach above-described all advantages simultaneously.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below.Apparently, the accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
The schematic flow sheet of the method that a kind of text image that Fig. 1 provides for the embodiment of the present invention corrects;
Fig. 2 is that in Fig. 1, step S103 utilizes two points of process of iteration to determine to correct the schematic flow sheet of rotation angle;
The structural representation of the device that a kind of text image that Fig. 3 provides for the embodiment of the present invention corrects;
The structural representation of the device that the another kind of text image that Fig. 4 provides for the embodiment of the present invention corrects;
Fig. 5 is inclination text image schematic diagram;
Fig. 6 is the postrotational effect schematic 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 blank line number statistical result schematic diagram 1;
Fig. 9 is pixel blank line number statistical result schematic diagram 2;
Figure 10 is the text image schematic diagram after correcting.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, clear, complete description is carried out to the technical scheme in the embodiment of the present invention.Obviously, described embodiment is only a part of embodiment of the present invention, instead of whole embodiments.Based on the embodiment in the present invention, the every other embodiment that those of ordinary skill in the art obtain under the prerequisite not making creative work, all belongs to the scope of protection of the invention.
Embodiments provide method and the device of the correction of a kind of text image.In this scenario, first pre-service is carried out to the text image to be corrected of the white gravoply, with black engraved characters obtained, obtain the first text image of the black matrix wrongly written or mispronounced character of binaryzation.Then, along clockwise direction with counterclockwise multiple rotary is carried out by preset rules to described first text image, often rotate and once the pixel value of postrotational first text image is calculated, obtain each pixel blank line number rotating rear first text image, and the anglec of rotation maximum for pixel blank line number is defined as correct rotation angle.Finally, described text image to be corrected is rotated described correction rotation angle, obtain the text image after correcting.
Below by specific embodiment, the present invention is described in detail.
The schematic flow sheet of the method that a kind of text image that Fig. 1 provides for the embodiment of the present invention corrects, comprises the steps:
Step S101: the text image to be corrected obtaining white gravoply, with black engraved characters.
Suppose, as shown in Figure 5, to the text image to be corrected of the white gravoply, with black engraved characters of acquisition text image tilt.
Step S102: carry out pre-service to described text image to be corrected, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation.
Described pre-service is carried out to described text image to be corrected, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation, can comprise:
After binary image process is carried out to described text image to be corrected, carry out the inverse process of black matrix wrongly written or mispronounced character, obtain the first text image of black matrix wrongly written or mispronounced character.
In actual applications, binary image process is being carried out to described text image to be corrected, and after being rotated by the text image to be corrected of white gravoply, with black engraved characters, newly-increased non-image areas is often filled to be black, as shown in Figure 6.Follow-up pixel blank line statistical operation can be impacted like this.Therefore, inverse process binary image being carried out to black matrix wrongly written or mispronounced character is needed.Through inverse process, after being the text image of black matrix wrongly written or mispronounced character by the text image inverse of white gravoply, with black engraved characters, then during image rotating, then the impact of non-image areas on image-region can be eliminated, as shown in Figure 7.
Described binary image process is carried out to described text image to be corrected, can comprise:
Gray processing process is carried out to the text image to be corrected of white gravoply, with black engraved characters, obtains one dimension gray matrix image; Otsu algorithm is adopted to calculate Second Threshold; With described Second Threshold, binary conversion treatment is carried out to described one dimension gray matrix image, obtain binary image.
Particularly, described Second Threshold is the threshold value making the variance between black font and white background two class maximum.
After binary image process is carried out to described text image to be corrected, before carrying out the inverse process of black matrix wrongly written or mispronounced character, can also comprise: adopt median filtering algorithm to carry out filtering to the binary image obtained, obtain level and smooth binary image.Like this, described in carry out the inverse process of black matrix wrongly written or mispronounced character, Ke Yiwei: inverse process is carried out to level and smooth binary image, obtain the first text image of black matrix wrongly written or mispronounced character.
In actual applications, the situation through medium filtering is needed to comprise: in scan text image, to there is the isolated noise point such as ink or fine solid particle.
Step S103: along clockwise direction with counterclockwise multiple rotary is carried out by preset rules to described first text image, often rotate and once the pixel value of postrotational first text image is calculated, obtain each pixel blank line number rotating rear first text image; The anglec of rotation maximum for pixel blank line number is defined as correct rotation angle.
In actual applications, along clockwise direction with counterclockwise multiple rotary is carried out by preset rules to described first text image, often rotate once, just the pixel value of postrotational first text image is once calculated, obtain each pixel blank line number rotating rear first text image.Such as, Fig. 7 edge as shown in Figure 8, is rotated counterclockwise the pixel blank line number statistical result schematic diagram after 7 degree as shown in Figure 9 by the pixel blank line number statistical result schematic diagram of text image shown in Fig. 7.Wherein, the black region on the right side of Fig. 8 and Fig. 9 on vertical bar represents pixel blank line, and white portion represents non-pixel blank line.
Particularly, when determining to correct rotation angle, the method for point iteration of two shown in Fig. 2 can be adopted to determine the correction rotation angle of inclination text image; Also can adopt and first rotate to an angle to a direction, then be increased according to the pixel blank line number rotating rear text image or reduce, instruct the direction of rotation and the angle of rotation, finally determine to correct rotation angle; Or the pixel blank line number of text image under all angles can also be calculated, therefrom find out the rotation angle that pixel blank line number is maximum, determine to correct rotation angle.Such as, pixel blank line number in Fig. 9 is greater than the pixel blank line number in Fig. 8, can result continue to rotate text image accordingly, until pixel blank line number is maximum when finding " along being rotated counterclockwise 6 degree ", so now can determine to correct rotation angle for " along being rotated counterclockwise 6 degree ".
Step S104: described text image to be corrected is rotated described correction rotation angle, obtains the text image after correcting.
Such as, according to the correction rotation angle determined in step S103 " along being rotated counterclockwise 6 degree ", rotation diagram 5, finally obtains the image after correcting, as shown in Figure 10.
As seen from the above, in the present embodiment, multiple rotary is carried out according to preset rules to through pretreated text image, the each pixel blank line number rotating rear text image of statistics, the maximum anglec of rotation of pixel blank line number is correction rotation angle, correct rotation angle accordingly and correct text image, carrying out Fast Correction with the text image realized tilting, reducing calculated amount.
Below, for step S103, elaborate the concrete steps utilizing two points of process of iteration to determine inclination text image correction rotation angle.
Fig. 2 is that in Fig. 1, step S103 utilizes two points of process of iteration to determine the schematic flow sheet of inclination text image correction rotation angle, and it comprises the following steps:
Step S201: described first text image is rotated in a clockwise direction the first angle low, obtains the second text image; Described first text image is rotated the second angle high in the counterclockwise direction, obtains the 3rd text image.
Particularly, the initial value of described low and high is preset value, is specifically as follows: one that presets on the occasion of with a negative value, and absolute value is between 10 degree ~ 45 degree, is greater than described correction rotation angle.
Step S202: calculate the pixel value of described second text image and the 3rd text image respectively, obtains the pixel blank line number numlow of described second text image, and the pixel blank line number numhigh of the 3rd text image.
Particularly, describedly respectively the pixel value of described second text image and the 3rd text image to be calculated, obtain the pixel blank line number numlow of described second text image, and the pixel blank line number numhigh of the 3rd text image, can comprise:
Described second text image and the 3rd text image are scanned respectively in units of pixel, obtains the pixel value of each pixel;
Described pixel value is sued for peace line by line, obtain respectively the pixel value that described second text image and the 3rd text image often go and value;
What add up described pixel value is the line number of the pixel column of zero with value, obtains pixel blank line number numlow and numhigh of described second text image and the 3rd text image respectively.
In practical application, add up described pixel value be the line number of the pixel column of zero with value time, can arrange a threshold value, such as, can arrange this threshold value is 3.When pixel value be less than this threshold value with value time, just can think behavior blank line.Certainly, arrange this threshold value to be also fine for other values.
Step S203: by the pixel blank line number numlow of described second text image, compares with the pixel blank line number numhigh of the 3rd text image; If described numlow is less than described numhigh, then described first angle low is updated to (low+high)/2; If described numlow is not less than described numhigh, then described second angle high is updated to (low+high)/2.
Particularly, by the pixel blank line number numlow of described second text image, compare with the pixel blank line number numhigh of the 3rd text image; If described numlow is less than described numhigh, then described first angle low is updated to (low+high)/2, described second angle high is constant; If described numlow is not less than described numhigh, then described second angle high is updated to (low+high)/2, described first angle low is constant.
Step S204: judge whether the absolute value of the difference of described first angle low and the second angle high is less than default first threshold, if, then described (low+high)/2 are the maximum anglec of rotation of pixel blank line number, described (low+high)/2 are defined as the correction rotation angle of described first text image, perform step S104; If not, then described step S201 is returned.
Particularly, judge whether the absolute value of the difference of described first angle low and the second angle high is less than default first threshold, if, then described (low+high)/2 are the maximum anglec of rotation of pixel blank line number, wherein, low or high is the value after upgrading, and described (low+high)/2 is defined as the correction rotation angle of described first text image, performs step S104; If not, then return described step S201, enter next circulation.
Below, in conjunction with instantiation, the application is elaborated again.
Suppose, as shown in Figure 7, the initial value of described first angle low and the second angle high is respectively-10 degree and+10 degree to the first text image.Wherein, "+" number represents that, along counterclockwise, "-" number represents that edge clockwise.Suppose that first threshold is 0.01 degree.
Step S201, is rotated in a clockwise direction 10 degree by Fig. 7, obtain the second text image pic1; Fig. 7 is rotated 10 degree in the counterclockwise direction, obtains the 3rd text image pic2.
Step S202, calculates the pixel value of pic1 and pic2 respectively, and obtaining the pixel blank line number numlow of pic1, is 0, and obtaining the pixel blank line number numhigh of pic2, is 80.
Step S203, the pixel blank line number numhigh of pixel blank line number numlow and the pic2 of pic1 is compared, the value 0 of visible numlow is less than the value 80 of numhigh, then the first angle low is updated to (-10+10)/2 degree, namely 0 degree, second angle high is constant, is still+10 degree.
Step S204, judge whether the absolute value of the difference of described first angle low and the second angle high is less than default first threshold, low or high is now the value after upgrading, and namely judges whether the value of │ 0-10 │ is less than 0.01 degree, obvious judged result is "No", then return step S201.
After entering second time circulation, the value of described low and high is respectively 0 and+10 degree, the value of numlow is 40, the value of numhigh is 80, the value of numlow is less than the value of numhigh, and the first angle low is updated to (0+10)/2=+5 degree, and the second angle high is that+10 degree are constant, and │ 5-10 │ is not less than first threshold 0.01, returns step S201;
After entering third time circulation, the value of described low and high is respectively+5 degree and+10 degree, the value of numlow is 90, the value of numhigh is 80, the value of numlow is not less than the value of numhigh, and the second angle high is updated to (5+10)/2=+7.5 degree, and the first angle low is that+5 degree are constant, and │ 5-7.5 │ is not less than first threshold 0.01, returns step S201;
After entering the 4th circulation, the value of described low and high is respectively+5 degree and+7.5 degree, the value of numlow is 90, the value of numhigh is 85, the value of numlow is not less than the value of numhigh, and the second angle high is updated to (5+7.5)/2=+6.25 degree, and the first angle low is that+5 degree are constant, and │ 5-6.25 │ is not less than first threshold 0.01, returns step S201;
Enter next circulation.
After supposing to enter the N time circulation, │ low-high │ is less than 0.01, and circulation terminates, and may draw and correct rotation angle for (low+high)/2=6 degree.
As seen from the above, in the present embodiment, multiple rotary is carried out according to preset rules to through pretreated text image, the each pixel blank line number rotating rear text image of statistics, the maximum anglec of rotation of pixel blank line number is correction rotation angle, correct rotation angle accordingly and correct text image, carrying out Fast Correction with the text image realized tilting, reducing calculated amount.Meanwhile, in the present embodiment, adopt the mode of two points of iteration to calculate correction rotation angle, improve the counting yield correcting rotation angle.
The structural representation of the device that a kind of text image that Fig. 3 provides for the embodiment of the present invention corrects, corresponding with the flow process shown in Fig. 1, comprising: text image obtains module 301, text image pretreatment module 302, corrects rotation angle determination 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 pretreatment module 302, for carrying out pre-service to described text image to be corrected, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation;
Correct rotation angle determination module 303, for carrying out multiple rotary to described first text image along clockwise direction with counterclockwise by preset rules, often rotate and once the pixel value of postrotational first text image is calculated, obtain each pixel blank line number rotating rear first text image; The anglec of rotation maximum for pixel blank line number is defined as correct rotation angle;
Text image correction module 304, for described text image to be corrected is rotated described correction rotation angle, obtains the text image after correcting.
In the present embodiment, text image pretreatment module 302 can comprise: binaryzation submodule and inverse submodule (not shown).Wherein, binaryzation submodule, for carrying out binary image process to described text image to be corrected; Inverse submodule, after carrying out binary image process to described text image to be corrected, carries out the inverse process of black matrix wrongly written or mispronounced character, obtains the first text image of black matrix wrongly written or mispronounced character.
Further, described binaryzation submodule can comprise: gray proces submodule, Second Threshold calculating sub module and binary conversion treatment submodule (not shown).Wherein, gray proces submodule, for carrying out gray processing process to the text image to be corrected of white gravoply, with black engraved characters, obtains one dimension gray matrix image; Second Threshold calculating sub module, calculates Second Threshold for adopting Otsu algorithm; Binary conversion treatment submodule, for carrying out binary conversion treatment with described Second Threshold to described one dimension gray matrix image, obtains binary image.Particularly, described Second Threshold is the threshold value making the variance between black font and white background two class maximum.
Described text image pretreatment module 302, can also comprise: level and smooth submodule (not shown).Wherein, level and smooth submodule, for after carrying out binary image process to described text image to be corrected, before carrying out the inverse process of black matrix wrongly written or mispronounced character, adopts median filtering algorithm to carry out filtering to the binary image obtained, obtains level and smooth binary image.Like this, described inverse submodule specifically may be used for: the inverse process level and smooth binary image being carried out to black matrix wrongly written or mispronounced character, obtains the first text image of black matrix wrongly written or mispronounced character.
As seen from the above, in the present embodiment, multiple rotary is carried out according to preset rules to through pretreated text image, the each pixel blank line number rotating rear text image of statistics, the maximum anglec of rotation of pixel blank line number is correction rotation angle, correct rotation angle accordingly and correct text image, carrying out Fast Correction with the text image realized tilting, reducing calculated amount.
The structural representation of the device that the another kind of text image that Fig. 4 provides for the embodiment of the present invention corrects, this device comprises: text image obtains module 301, text image pretreatment module 302, corrects rotation angle determination module 303 and text image correction module 304.
Wherein, correct rotation angle determination module 303 to comprise: gyrator module 3031, calculating sub module 3032, comparison sub-module 3033 and judge submodule 3034.
Described gyrator module 3031, for described first text image is rotated in a clockwise direction the first angle low, obtains the second text image; Described first text image is rotated the second angle high in the counterclockwise direction, obtains the 3rd text image.
In the present embodiment, the initial value of described low and high is preset value, this value be specifically as follows one on the occasion of with a negative value, and absolute value is between 10 degree ~ 45 degree, is greater than described correction rotation angle.
Described calculating sub module 3032, for calculating the pixel value of described second text image and the 3rd text image respectively, obtains the pixel blank line number numlow of described second text image, and the pixel blank line number numhigh of the 3rd text image.
In the present embodiment, described calculating sub module 3032 can comprise: scanning submodule, summation submodule and statistics submodule (not shown).Wherein, scanning submodule, for scanning in units of pixel respectively described second text image and the 3rd text image, obtains the pixel value of each pixel; Summation submodule, for described pixel value is sued for peace line by line, obtain respectively the pixel value that described second text image and the 3rd text image often go and value; Statistics submodule, is the line number of the pixel column of zero with value for what add up described pixel value, obtains pixel blank line number numlow and numhigh of described second text image and the 3rd text image respectively.
Described comparison sub-module 3033, for the pixel blank line number numlow by described second text image, compares with the pixel blank line number numhigh of the 3rd text image; If described numlow is less than described numhigh, then described first angle low is updated to (low+high)/2; If described numlow is not less than described numhigh, then described second angle high is updated to (low+high)/2;
Described judgement submodule 3034, whether the absolute value for the difference judging described first angle low and the second angle high is less than predetermined threshold value, if, then described (low+high)/2 are the maximum anglec of rotation of pixel blank line number, described (low+high)/2 are defined as the correction rotation angle of described first text image, trigger text image correction module 304; If not, then gyrator module 3031 is triggered.
As seen from the above, in the present embodiment, multiple rotary is carried out according to preset rules to through pretreated text image, the each pixel blank line number rotating rear text image of statistics, the maximum anglec of rotation of pixel blank line number is correction rotation angle, correct rotation angle accordingly and correct text image, carrying out Fast Correction with the text image realized tilting, reducing calculated amount.
For device embodiment, because it is substantially similar to embodiment of the method, so describe fairly simple, relevant part illustrates see the part of embodiment of the method.
It should be noted that, in this article, the such as relational terms of first and second grades and so on is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " comprises ", " comprising " or any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, article or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, article or equipment.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment comprising described key element and also there is other identical element.
One of ordinary skill in the art will appreciate that, all or part of step in above-mentioned embodiment is that the hardware can be correlated with by programmed instruction has been come, and described program can be stored in computer read/write memory medium.Here alleged storage medium, refers to ROM/RAM, magnetic disc, CD etc.
The foregoing is only preferred embodiment of the present invention, be not intended to limit protection scope of the present invention.All any amendments done within the spirit and principles in the present invention, equivalent replacement, improvement etc., be all included in protection scope of the present invention.

Claims (14)

1. a method for text image correction, it is characterized in that, described method comprises:
A. the text image to be corrected of white gravoply, with black engraved characters is obtained;
B. pre-service is carried out to described text image to be corrected, obtain the first text image of the black matrix wrongly written or mispronounced character of binaryzation;
C. along clockwise direction with counterclockwise multiple rotary is carried out by preset rules to described first text image, often rotate and once the pixel value of postrotational first text image is calculated, obtain each pixel blank line number rotating rear first text image; The anglec of rotation maximum for pixel blank line number is defined as correct rotation angle;
D. described text image to be corrected is rotated described correction rotation angle, obtain the text image after correcting.
2. method according to claim 1, is characterized in that, described step C, comprising:
C1. described first text image is rotated in a clockwise direction the first angle low, obtains the second text image; Described first text image is rotated the second angle high in the counterclockwise direction, obtains the 3rd text image; The initial value of described low and high is preset value;
C2. respectively the pixel value of described second text image and the 3rd text image is calculated, obtain the pixel blank line number numlow of described second text image, and the pixel blank line number numhigh of the 3rd text image;
C3. by the pixel blank line number numlow of described second text image, compare with the pixel blank line number numhigh of the 3rd text image; If described numlow is less than described numhigh, then described first angle low is updated to (low+high)/2; If described numlow is not less than described numhigh, then described second angle high is updated to (low+high)/2;
C4. judge whether the absolute value of the difference of described first angle low and the second angle high is less than default first threshold, if, then described (low+high)/2 are the maximum anglec of rotation of pixel blank line number, described (low+high)/2 are defined as the correction rotation angle of described first text image, perform step D; If not, then described step C1 is returned.
3. method according to claim 1, is characterized in that, describedly carries out pre-service to described text image to be corrected, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation, comprising:
After binary image process is carried out to described text image to be corrected, carry out the inverse process of black matrix wrongly written or mispronounced character, obtain the first text image of black matrix wrongly written or mispronounced character.
4. method according to claim 3, is characterized in that, describedly carries out binary image process to described text image to be corrected, comprising:
Gray processing process is carried out to the text image to be corrected of white gravoply, with black engraved characters, obtains one dimension gray matrix image;
Otsu algorithm is adopted to calculate Second Threshold; Described Second Threshold is the threshold value making the variance between black font and white background two class maximum;
With described Second Threshold, binary conversion treatment is carried out to described one dimension gray matrix image, obtain binary image.
5. method according to claim 3, is characterized in that, after carrying out binary image process to described text image to be corrected, before carrying out the inverse process of black matrix wrongly written or mispronounced character, also comprises:
Adopt median filtering algorithm to carry out filtering to the binary image obtained, obtain level and smooth binary image;
The described inverse process carrying out black matrix wrongly written or mispronounced character, for: inverse process is carried out to level and smooth binary image, obtains the first text image of black matrix wrongly written or mispronounced character.
6. method according to claim 2, is characterized in that, the initial value of described first angle low and the second angle high, for: preset one on the occasion of with a negative value; And absolute value is between 10 degree ~ 45 degree.
7. method according to claim 2, it is characterized in that, describedly respectively the pixel value of described second text image and the 3rd text image to be calculated, obtain the pixel blank line number numlow of described second text image, pixel blank line number numhigh with the 3rd text image, comprising:
Described second text image and the 3rd text image are scanned respectively in units of pixel, obtains the pixel value of each pixel;
Described pixel value is sued for peace line by line, obtain respectively the pixel value that described second text image and the 3rd text image often go and value;
What add up described pixel value is the line number of the pixel column of zero with value, obtains pixel blank line number numlow and numhigh of described second text image and the 3rd text image respectively.
8. a device for text image correction, it is characterized in that, described device comprises:
Text image obtains module, for obtaining the text image to be corrected of white gravoply, with black engraved characters;
Text image pretreatment module, for carrying out pre-service to described text image to be corrected, obtains the first text image of the black matrix wrongly written or mispronounced character of binaryzation;
Correct rotation angle determination module, for carrying out multiple rotary to described first text image along clockwise direction with counterclockwise by preset rules, often rotate and once the pixel value of postrotational first text image is calculated, obtain each pixel blank line number rotating rear first text image; The anglec of rotation maximum for pixel blank line number is defined as correct rotation angle;
Text image correction module, for described text image to be corrected is rotated described correction rotation angle, obtains the text image after correcting.
9. device according to claim 8, is characterized in that, described correction rotation angle determination module, comprising: gyrator module, calculating sub module, comparison sub-module and judgement submodule;
Described gyrator module, for described first text image is rotated in a clockwise direction the first angle low, obtains the second text image; Described first text image is rotated the second angle high in the counterclockwise direction, obtains the 3rd text image; The initial value of described low and high is preset value;
Described calculating sub module, for calculating the pixel value of described second text image and the 3rd text image respectively, obtains the pixel blank line number numlow of described second text image, and the pixel blank line number numhigh of the 3rd text image;
Described comparison sub-module, for the pixel blank line number numlow by described second text image, compares with the pixel blank line number numhigh of the 3rd text image; If described numlow is less than described numhigh, then described first angle low is updated to (low+high)/2; If described numlow is not less than described numhigh, then described second angle high is updated to (low+high)/2;
Described judgement submodule, whether the absolute value for the difference judging described first angle low and the second angle high is less than predetermined threshold value, if, then described (low+high)/2 are the maximum anglec of rotation of pixel blank line number, described (low+high)/2 are defined as the correction rotation angle of described first text image, trigger described text image correction module and carry out text image correction; If not, then trigger described gyrator module, enter next circulation.
10. device according to claim 8, is characterized in that, described text image pretreatment module comprises: binaryzation submodule and inverse submodule;
Described binaryzation submodule, for carrying out binary image process to described text image to be corrected;
Described inverse submodule, after carrying out binary image process to described text image to be corrected, carries out the inverse process of black matrix wrongly written or mispronounced character, obtains the first text image of black matrix wrongly written or mispronounced character.
11. devices according to claim 10, is characterized in that, described binaryzation submodule comprises: gray proces submodule, Second Threshold calculating sub module and binary conversion treatment submodule;
Gray proces submodule, for carrying out gray processing process to the text image to be corrected of white gravoply, with black engraved characters, obtains one dimension gray matrix image;
Second Threshold calculating sub module, calculates Second Threshold for adopting Otsu algorithm; Described Second Threshold is the threshold value making the variance between black font and white background two class maximum;
Binary conversion treatment submodule, for carrying out binary conversion treatment with described Second Threshold to described one dimension gray matrix image, obtains binary image.
12. devices according to claim 10, is characterized in that, described text image pretreatment module, also comprises: level and smooth submodule;
Described level and smooth submodule, for after carrying out binary image process to described text image to be corrected, before carrying out the inverse process of black matrix wrongly written or mispronounced character, adopts median filtering algorithm to carry out filtering to the binary image obtained, obtains level and smooth binary image;
Described inverse submodule, specifically for: the inverse process level and smooth binary image being carried out to black matrix wrongly written or mispronounced character, obtains the first text image of black matrix wrongly written or mispronounced character.
13. devices according to claim 9, is characterized in that, the initial value of described first angle low and the second angle high, for: preset one on the occasion of with a negative value; And absolute value is between 10 degree ~ 45 degree.
14. devices according to claim 9, is characterized in that, described calculating sub module comprises: scanning submodule, summation submodule and statistics submodule;
Described scanning submodule, for scanning in units of pixel respectively described second text image and the 3rd text image, obtains the pixel value of each pixel;
Described summation submodule, for described pixel value is sued for peace line by line, obtain respectively the pixel value that described second text image and the 3rd text image often go and value;
Described statistics submodule, is the line number of the pixel column of zero with value for what add up described pixel value, obtains pixel blank line number numlow and numhigh of described second text image and the 3rd text image respectively.
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 true CN105426887A (en) 2016-03-23
CN105426887B 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)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106997470A (en) * 2017-02-28 2017-08-01 信雅达***工程股份有限公司 Tilt bearing calibration and the system of text image
CN107103587A (en) * 2017-06-05 2017-08-29 新疆大学 A kind of inclined bearing calibration of biochip image and device
CN107992869A (en) * 2016-10-26 2018-05-04 深圳超多维科技有限公司 For tilting the method, apparatus and electronic equipment of word correction
CN108647681A (en) * 2018-05-08 2018-10-12 重庆邮电大学 A kind of English text detection method with text orientation correction
CN109345462A (en) * 2018-11-29 2019-02-15 北京京东尚科信息技术有限公司 Image processing method, device and computer readable storage medium
CN109977959A (en) * 2019-03-29 2019-07-05 国家电网有限公司 A kind of train ticket character zone dividing method and device
CN109993161A (en) * 2019-02-25 2019-07-09 众安信息技术服务有限公司 A kind of text image rotational correction method and system
CN110211047A (en) * 2019-04-10 2019-09-06 陕西理工大学 The image rotating method of machine vision thread parameter measurement
CN110969052A (en) * 2018-09-29 2020-04-07 杭州萤石软件有限公司 Operation correction method and equipment

Citations (6)

* 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
US20100215285A1 (en) * 2009-02-20 2010-08-26 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
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

Patent Citations (6)

* 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
US20100215285A1 (en) * 2009-02-20 2010-08-26 Avermedia Information, Inc. Method and device for detecting and correcting skewed image data
CN101639933A (en) * 2009-07-16 2010-02-03 上海合合信息科技发展有限公司 Image rotation correction method and system and electronic device
US20110052094A1 (en) * 2009-08-28 2011-03-03 Chunyu Gao Skew Correction for Scanned Japanese/English Document Images
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
吴飞飞: "文本图像倾斜校正算法的研究与应用", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107992869A (en) * 2016-10-26 2018-05-04 深圳超多维科技有限公司 For tilting the method, apparatus and electronic equipment of word correction
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
CN107103587A (en) * 2017-06-05 2017-08-29 新疆大学 A kind of inclined bearing calibration of biochip image and device
CN107103587B (en) * 2017-06-05 2023-04-21 新疆大学 Method and device for correcting inclination of biochip image
CN108647681A (en) * 2018-05-08 2018-10-12 重庆邮电大学 A kind of English text detection method with text orientation correction
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
CN109993161A (en) * 2019-02-25 2019-07-09 众安信息技术服务有限公司 A kind of text image rotational correction method and system
CN109993161B (en) * 2019-02-25 2021-08-03 众安信息技术服务有限公司 Text image rotation correction method and system
CN109977959A (en) * 2019-03-29 2019-07-05 国家电网有限公司 A kind of train ticket character zone dividing method and device
CN109977959B (en) * 2019-03-29 2021-07-06 国家电网有限公司 Train ticket character area segmentation method and device
CN110211047A (en) * 2019-04-10 2019-09-06 陕西理工大学 The image rotating method of machine vision thread parameter measurement
CN110211047B (en) * 2019-04-10 2023-04-07 陕西理工大学 Image rotation method for machine vision thread parameter measurement

Also Published As

Publication number Publication date
CN105426887B (en) 2019-04-12

Similar Documents

Publication Publication Date Title
CN105426887A (en) Method and device for text image correction
US9122954B2 (en) Performing a histogram using an array of addressable registers
CN109409366B (en) Distorted image correction method and device based on angular point detection
CN110348264B (en) QR two-dimensional code image correction method and system
CN110084236B (en) Image correction method and device
US9639777B1 (en) Systems and methods for providing an image classifier
CN107169489B (en) Method and apparatus for tilt image correction
US20110123114A1 (en) Character recognition device and method and computer-readable medium controlling the same
CN105069394A (en) Two-dimension code weighted average gray level method decoding method and system
US9865038B2 (en) Offsetting rotated tables in images
US9824267B2 (en) Writing board detection and correction
CN104899589A (en) Method for realizing two-dimensional bar code preprocessing by using threshold binarization algorithm
CN112419207A (en) Image correction method, device and system
CN111104941B (en) Image direction correction method and device and electronic equipment
CN110163894B (en) Sub-pixel level target tracking method based on feature matching
CN105184294A (en) Inclination character judgment and identification method based on pixel tracking
CN107545259A (en) A kind of Quick Response Code reconstructing method based on Da-Jin algorithm
CN112613526B (en) Feature matching method and system based on optical flow tracking
CN104503662A (en) Generation method and device for geometric outline of desktop element
US10460189B2 (en) Method and apparatus for determining summation of pixel characteristics for rectangular region of digital image avoiding non-aligned loads using multiple copies of input data
CN111178111A (en) Two-dimensional code detection method, electronic device, storage medium and system
CN112766256B (en) Grating phase diagram processing method and device, electronic equipment and storage medium
US20150279039A1 (en) Object detecting apparatus and method
CN115797327A (en) Defect detection method and device, terminal device and storage medium
CN111862132A (en) Curve detection method, device, equipment and medium

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