CN110136069A - Text image antidote, device and electronic equipment - Google Patents

Text image antidote, device and electronic equipment Download PDF

Info

Publication number
CN110136069A
CN110136069A CN201910375401.8A CN201910375401A CN110136069A CN 110136069 A CN110136069 A CN 110136069A CN 201910375401 A CN201910375401 A CN 201910375401A CN 110136069 A CN110136069 A CN 110136069A
Authority
CN
China
Prior art keywords
text image
image
character
line
text
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
CN201910375401.8A
Other languages
Chinese (zh)
Other versions
CN110136069B (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.)
Language Network (wuhan) Information Technology Co Ltd
Original Assignee
Language Network (wuhan) Information 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 Language Network (wuhan) Information Technology Co Ltd filed Critical Language Network (wuhan) Information Technology Co Ltd
Priority to CN201910375401.8A priority Critical patent/CN110136069B/en
Publication of CN110136069A publication Critical patent/CN110136069A/en
Application granted granted Critical
Publication of CN110136069B publication Critical patent/CN110136069B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/60Rotation of whole images or parts thereof
    • G06T3/608Rotation of whole images or parts thereof by skew deformation, e.g. two-pass or three-pass rotation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/168Segmentation; Edge detection involving transform domain methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20048Transform domain processing
    • G06T2207/20061Hough transform

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Character Input (AREA)

Abstract

The embodiment of the present invention provides a kind of text image antidote, device and electronic equipment, wherein this method comprises: text image to be corrected is carried out binary conversion treatment, and utilize box filter, Fuzzy processing carried out to the text image of binaryzation, with the character gap between a line adjacent character and retains different row gaps in the ranks in the text image to filter out the binaryzation;Using multistage edge detection algorithm, the row edge of each line character in the text image of blurring is detected and connected, and be based on the row edge, by statistical probability Hough transformation, obtains the line segment that each line character is formed in the text image of the blurring;Length the maximum in all line segments is obtained, and by calculating its slope, calculates the tilt angle of the text image to be corrected;Based on the tilt angle, the text image to be corrected is rotated, to realize correction.The embodiment of the present invention also can effectively and accurately correct text image in the case where frame is not present in text.

Description

Text image antidote, device and electronic equipment
Technical field
The present invention relates to technical field of image processing, more particularly, to a kind of text image antidote, device and electricity Sub- equipment.
Background technique
When being acquired using image capture device to text image, often since placed angle of equipment etc. is asked Topic, causes collected text image different degrees of inclination occur, influences the display effect to text.
Currently, solving to mostly use in the technology of the display problem of text image based on framing mask or based on projection Slant Rectify (Radon transformation) method.But in the case where frame is not present in text, the correction of these antidotes is accurate Rate and effect will be very poor.
Summary of the invention
In order to overcome the above problem or at least be partially solved the above problem, the embodiment of the present invention provides a kind of text diagram As antidote, device and electronic equipment, can effectively and accurately be rectified in the case where frame is not present in text Positive text image.
In a first aspect, the embodiment of the present invention provides a kind of text image antidote, comprising:
Text image to be corrected is subjected to binary conversion treatment, and utilizes box filter, to the text image of binaryzation into Row Fuzzy processing with the character gap between a line adjacent character and retains difference in the text image to filter out the binaryzation Row gap in the ranks;
Using multistage edge detection algorithm, the row edge of each line character in the text image of blurring is detected and connects, and Based on the row edge, by statistical probability Hough transformation, obtain what each line character in the text image of the blurring was formed Line segment;
Length the maximum in all line segments, and the slope by calculating described length the maximum are obtained, institute is calculated State the tilt angle of text image to be corrected;
Based on the tilt angle, the text image to be corrected is rotated, to realize correction.
Second aspect, the embodiment of the present invention provide a kind of text image apparatus for correcting, comprising:
Fuzzy Processing module for text image to be corrected to be carried out binary conversion treatment, and utilizes box filter, to two The text image of value carries out Fuzzy processing, with the word between a line adjacent character in the text image to filter out the binaryzation Symbol gap simultaneously retains different row gaps in the ranks;
Edge detection and Hough transformation module, for detecting and connecting the text of blurring using multistage edge detection algorithm The row edge of each line character in this image, and the blurring is obtained by statistical probability Hough transformation based on the row edge Text image in the line segment that is formed of each line character;
Computing module, for obtaining length the maximum in all line segments, and by calculating described length the maximum Slope, calculate the tilt angle of the text image to be corrected;
Rotational correction module rotates the text image to be corrected, for being based on the tilt angle to realize correction.
The third aspect, the embodiment of the present invention provide a kind of electronic equipment, including memory, processor and are stored in described deposit On reservoir and the computer program that can run on the processor, when the processor executes the computer program, realize The step of text image antidote described in first aspect as above.
Fourth aspect, the embodiment of the present invention provide a kind of non-transient computer readable storage medium, are stored thereon with calculating Machine instruction, when the computer instruction is computer-executed, realizes text image antidote described in first aspect as above Step.
Text image antidote, device and electronic equipment provided in an embodiment of the present invention, by utilizing box filter, Fuzzy processing is carried out to the text image of binaryzation, can effectively filter out each line character trace in text image, and By carrying out further edge detection and Hough transformation, the corresponding line segment of each line character can be obtained, is on this basis Make also can effectively and accurately correct text image in the case where frame is not present in text.
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 apparent that, the accompanying drawings in the following description is this hair Bright some embodiments for those of ordinary skill in the art without creative efforts, can be with root Other attached drawings are obtained according to these attached drawings.
Fig. 1 is the flow diagram of text image antidote provided in an embodiment of the present invention;
Fig. 2 is the structural schematic diagram of text image apparatus for correcting provided in an embodiment of the present invention;
Fig. 3 is the entity structure schematic diagram of electronic equipment provided in an embodiment of the present invention.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is A part of the embodiment of the embodiment of the present invention, instead of all the embodiments.Based on the embodiment in the embodiment of the present invention, ability Domain those of ordinary skill every other embodiment obtained without making creative work, belongs to the present invention The range of embodiment protection.
The embodiment of the present invention is directed to the correction of existing antidote in the prior art in the case where frame is not present in text Accuracy rate and effect will be very poor problem, by utilize box filter, the text image of binaryzation is carried out at blurring Reason can effectively filter out each line character trace in text image, and by carrying out further edge detection and Hough Transformation, can obtain the corresponding line segment of each line character, on this basis can in the case where frame is not present in text Effectively and accurately correct text image.Below will especially by multiple embodiments to the embodiment of the present invention carry out expansion explanation and It introduces.
Fig. 1 is the flow diagram of text image antidote provided in an embodiment of the present invention, as shown in Figure 1, this method Include:
Text image to be corrected is carried out binary conversion treatment, and utilizes box filter by S101, to the text diagram of binaryzation With the character gap between a line adjacent character and retain difference as carrying out Fuzzy processing, in the text image to filter out binaryzation Row gap in the ranks.
It is to be understood that may be due to capture apparatus angle by the text image that shooting text obtains the problems such as, cause Obtained text image tilts, and influences identification and display effect, needs to correct text image, then text figure As being text image to be corrected.
On the basis of obtaining text image to be corrected, machine is identified for ease of calculation, first to the text diagram to be corrected As carrying out binary conversion treatment, the text image of binaryzation is obtained.Later, the text image of the binaryzation is input to and is set Box filter is blurred with carrying out Fuzzy processing using text image of the box filter to the binaryzation Text image.It is appreciated that for the text image of binaryzation, wherein include multirow character, multirow character in the ranks and often There is gap in the intercharacter of a line character, normally can show and identify character.For these in the ranks gap and intercharacters Gap, above-mentioned Fuzzy processing be can be used between in the text image of binaryzation with the character gap a line adjacent character It is filtered out, and retains different row gaps in the ranks.
S102 detects and connects the row side of each line character in the text image of blurring using multistage edge detection algorithm Edge, and it is based on row edge, by statistical probability Hough transformation, obtain the line that each line character is formed in the text image of blurring Section.
Specifically, being able to detect that each line character in the text image of the blurring obtained after Fuzzy processing Lower edges, and due to the difference of character or punctuation mark etc., so that the top edge of each line character or lower edge are disconnected The multistage opened, rather than a complete edge.Therefore, first with multistage edge detection algorithm, Canny algorithm, detection are such as used The segment of these lower edges of each line character out is directed to each line character later, respectively by each segment of its top edge and Each segment of lower edge is attached, and forms a complete top edge and lower edge, as row edge.
Later, using row edge obtained above as transforming object, statistical probability Hough transformation is carried out, obtains transformation knot Fruit set, and obtain line segment made of each line character is connected respectively according to transformation results set, these line segments may be by In the type of each line character and how many etc., and length is different.
S103 obtains length the maximum in all line segments, and passes through the slope of computational length the maximum, calculates wait correct The tilt angle of text image.
It is to be understood that being sought after obtaining the corresponding line segment of each line character by each line segment length of detection Length the maximum therein is looked for, namely finds longest line segment.Later, the oblique of the longest line segment is detected according to reference frame Rate, and the slope for passing through the line segment further judges the tilt angle of text image to be corrected.For example, if longest known to calculating Line segment slope be 1/2, then can further judge that text image to be corrected is to have tilted 120 degree in the counterclockwise direction.
S104 is based on tilt angle, rotates text image to be corrected, to realize correction.
Specifically, after the tilt angle for obtaining text image to be corrected, it can be according to the actual angle of inclination pair Text image to be corrected carries out rotation processing, is revolved just, namely consistent with the direction of reference frame.Such as sentence for above-mentioned Disconnected text image to be corrected is the case where having tilted 120 degree in the counterclockwise direction, and the direction of reference frame is 0 degree, then only Need will text image be corrected along wink clockwise rotate 120 degree, can will text diagram image rotation be corrected just.
Text image antidote provided in an embodiment of the present invention, by utilizing box filter, to the text of binaryzation Image carries out Fuzzy processing, can effectively filter out each line character trace in text image, and further by carrying out Edge detection and Hough transformation, the corresponding line segment of each line character can be obtained, even if being not present on this basis in text Also text image can effectively and be accurately corrected in the case where frame.
It is recognised that the embodiment of the present invention can be carried out at blurring using text image of the box filter to binaryzation Reason, therefore before the step of text image to binaryzation carries out Fuzzy processing, the text image of the embodiment of the present invention is rectified Correction method can also include:
The fuzzy window of box filter is set, so that fuzzy window meets following standard: binaryzation can be obscured It is in text image with the character gap between adjacent character in a line, and, it can retain adjacent in the text image of binaryzation The row gap of character in the ranks.
Specifically, the picture to be corrected of binaryzation is carried out at blurring using box filter (Box Filter) Reason, it is therefore an objective to noise reduction and the identifiable line segment of generation, therefore need to be configured fuzzy window in advance.When being configured, make Window selection must be obscured to satisfy two conditions: first, as far as possible obscuring the gap between word space, convenient for edge detection When generate identifiable line segment;Second, the gap of line space cannot be obscured.
Wherein, according to the above embodiments optionally, using box filter, the text image of binaryzation is obscured The step of changing processing specifically includes:
According to the size of character in the text image of binaryzation, the size that window is obscured in box filter is defined;
On the text image of binaryzation, according to sequence from left to right, from top to bottom, fuzzy window is slided, and in cunning In dynamic process, by the pixel value of the text image of the corresponding binaryzation in fuzzy window center, it is arranged to entire fuzzy window The average value of all pixels of the text image of the binaryzation of mouth covering.
Specifically, the embodiment of the present invention before being handled using box filter, will first be configured it.Its In it is optional, can according in the text image of binaryzation with the line space of the spacing of a line adjacent character and adjacent character row, The size that window is obscured in box filter is defined, such as the size of fuzzy window specifically may be configured as 6*6 pixel.
On the basis of determining fuzzy window size, mould is carried out to the text image of binaryzation by operating the fuzzy window Gelatinization processing.Specifically, fuzzy window is carried out traversal sliding on the text image of entire binaryzation, and in sliding process Middle carry out Fuzzy processing.To avoid omitting, order traversal from left to right, from top to bottom specifically can be used, naturally it is also possible to Using other order traversals, as long as meeting complete traversal.When specific progress Fuzzy Processing, when fuzzy window traverses binaryzation When some position in text image, all pixels that fuzzy window is covered are summed up into averaging, and by fuzzy window The pixel value of the corresponding pixel in center at this time is set as the average value, that is, completes the Fuzzy processing of a point.? It slides in fuzzy window procedure, above-mentioned identical Fuzzy processing mode is used to all pixels point of traversal, that is, is completed to whole The Fuzzy processing of the text image of a binaryzation exports the text image of blurring.
Wherein, according to the above embodiments optionally, using multistage edge detection algorithm, detect and connect the text of blurring The step of row edge of each line character, specifically includes in this image: using multistage edge detection algorithm, detecting the text of blurring The edge of each line character in image;Using dual threashold value-based algorithm, respectively to the edge of each line character in the text image of blurring It is attached, obtains the corresponding row edge of each line character in the text image of blurring.
It is to be understood that the embodiment of the present invention uses multistage edge detection algorithm (for example, by using Canny algorithm) first, it will The every a line in text image (namely text image of blurring) being filtered generates lower edges, uses dual threashold later Value-based algorithm is attached the lower edges of generation respectively, then for every a line, there are character edges for correspondence, as respectively The corresponding row edge of row.
Specifically, the embodiment of the present invention using using box filter come the gaussian filtering of alternate standard, in denoising While the section offer possibility that is in line of making a living.When application dual threashold value-based algorithm carries out the processing of character edge connection, need to define:
Firstly, looking for the intensity gradient (intensity gradients) of image.
The basic thought of Canny algorithm is to look for the strongest position of Strength Changes in piece image.So-called variation is most strong, i.e., Refer to gradient direction.The gradient of each pixel can be obtained by Sobel operator (a kind of convolution algorithm) in smoothed out image The n order derivative of each pixel in image) acquire the gradient along horizontal (x) and vertical direction (y) respectively using following core G_X and G_Y.
K_ { G_X }=[- 101;-2 0 2;-1 0 1];
K_ { G_Y }={-1-2-1;0 0 0;1 2 1}.
The gradient magnitude of each pixel can be acquired using formula later.It is easy sometimes for calculating, can also it make Two norms are replaced with the infinity norm of G_X and G_Y, and each of smoothed out image point is replaced with G.
Secondly, eliminating side erroneous detection using non-maximum suppression (non-maximum suppression) technology.
The purpose of this step is that the boundary for obscuring (blurred) is apparent from (sharp).Namely remain each pixel The maximum of gradient intensity on point, and delete other values.For each pixel, proceed as follows:
By one (0,45,90,135,180,225,270,315) (i.e. upper and lower left side that gradient direction is approximately in following values Right and 45 degree of directions);
Compare the gradient intensity of the pixel of the pixel and the positive negative direction of its gradient direction;
Retain if the pixel gradient intensity maximum, otherwise inhibits (to delete, that is, be set to 0).
Again, the method for dual threshold determines possible boundary.
Still there are many noise spots in image after non-maximum restraining.One kind is applied in Canny algorithm is dual threshold Technology.A threshold value upper bound and threshold value lower bound are set, the pixel in image then thinks inevitable if it is greater than the threshold value upper bound It is boundary (referred to as strong boundary, strong edge), then thinking inevitable less than threshold value lower bound is not boundary, then recognizing between the two To be candidate item (referred to as weak boundary, weak edge).
Finally, tracking boundary.
The connected weak boundary in strong boundary is considered boundary, and other weak boundaries are then not considered as boundary.
Wherein, according to the above embodiments optionally, by statistical probability Hough transformation, the text image of blurring is obtained In each line character formed line segment the step of specifically include:
A marginal point in the text image of blurring is randomly selected, the marginal point has been demarcated as certain if detecting Point on one straight line then continues to randomly select a marginal point in the remaining edge point in the text image of blurring, until All marginal points are extracted;
Hough transformation is carried out to the marginal point of extraction, and accumulation calculating is carried out to Hough transformation result;
It is based on accumulation calculating to be worth maximum point as a result, being chosen in hough space, and be greater than in the value of the maximum point of value When the first given threshold, moved using being worth maximum point as basic point along straightway where basic point according to the value for being worth maximum point, Obtain two endpoints of straightway;
Based on two endpoints, calculate the length of straightway, and if length be greater than the second given threshold, export straightway.
Specifically, can be explained as follows for the embodiment of the present invention:
Firstly, for Hough transformation principle:
Straight line can indicate (r, θ) by polar diameter and polar angle in polar coordinate system;
For a given point, all pass through can be drawn out in the range of polar angle [0,2 π] in polar coordinate plane Its straightway, the polar diameter and polar angle of these line segments can form a sine curve in θ-r coordinate system;
A series of such curves are all formed for point all in image to intersect in θ-r coordinate system, give intersection point threshold Value (is 200 in test case, it may be assumed that more than 200 curves are considered as this 200 pixels in straight line in the intersection of θ-r coordinate system On), then just detecting this 200 pixels on a line segment and the polar diameter and polar angle (r of intersection point00) it is exactly that is straight Line.
Secondly, for statistical probability Hough transformation:
Standard Hough transformation is substantially that image is mapped on its parameter space, it needs to calculate M all sides Edge point, in this way its operand and required memory headroom all can be very big.If only handling a side m (m < M) in the input image Edge point, then the selection of this m marginal point is that have certain probabilistic, therefore this method is referred to as probability Hough transformation (Probabilistic Hough Transform).There are one important features to be to detection leading-out terminal for this method, i.e., It is capable of detecting when two endpoints of straight line in image, definitely positions the straight line in image (convenient for directly calculating line segment length).
Straight line, general step are detected using statistical probability Hough transformation are as follows:
Step 1, a characteristic point in image, i.e. marginal point are randomly selected, if the point has been demarcated as being a certain Point on straight line then continues to randomly select a marginal point in remaining marginal point, until all marginal points have all extracted Until;
Step 2, Hough transformation is carried out to the point, and is added up and is calculated;
Step 3, it is chosen at the maximum point of value in hough space, if the point carries out step 4, otherwise greater than threshold value Return to step 1;
Step 4, the maximum value obtained according to Hough transformation is displaced, to find from this point along the direction of straight line Two endpoints of straight line;
Step 5, the length for calculating straight line, if it is greater than some threshold value, then the straight line output for being considered as returns to step 1。
Wherein, according to the above embodiments optionally, text image to be corrected is rotated, is specifically wrapped the step of correction with realizing It includes:
According to the corresponding inclined direction of tilt angle and angle, text image to be corrected is rotated, obtains the first correcting image, And by the way that the first correcting image is rotated by 90 ° in the same direction respectively, 180 ° and 270 °, it is corresponding to obtain the second correction figure respectively Picture, third correcting image and the 4th correcting image;
Using optical character recognition technology, identify the first correcting image respectively, the second correcting image, third correcting image and The character shown respectively in 4th correcting image, by the corresponding correcting image of correct recognition rata soprano, as final correction text This image.
It is appreciated that in actual treatment, it may be due to camera angle or the text itself that is taken, so that obtained text The case where image lateral inclination occurs or turns upside down namely tilt angle are larger, reach 90 degree, 180 degree or 270 degree of feelings Condition, at this time treat according to the above embodiments correction text image rotated on the basis of, available one is therein The direction of line segment and the consistent text image of reference direction.For example, if detecting, the slope of the line segment in image is 1/2, text The actual angle of inclination of this image may be 120 degree counterclockwise, it is also possible to be 60 degree of instantaneous value namely 300 degree counterclockwise.Through root After rotating text image according to slope 1/2, it can guarantee that text does not tilt, but text is possible to reverse.
Therefore, the embodiment of the present invention is obtained with the consistent direction of reference direction being rotated to text image according to line segment slope To on the basis of the first correcting image, which (can be successively also possible to counterclockwise) along clockwise direction Be rotated by 90 °, 180 degree and 270 degree, obtained postrotational image is corresponding be respectively the second correcting image, third correcting image and 4th correcting image.Later, using OCR tool respectively to it is above-mentioned first to fourth correcting image carry out Text region, and by its The middle highest image of recognition accuracy, as final correction result.
For the technical solution that the embodiment of the present invention will be further explained, the embodiment of the present invention provides such as according to the above embodiments Specific process flow down, but the protection scope of the embodiment of the present invention is not limited.
Step 1, text image to be corrected is subjected to binary conversion treatment, obtains the text image of binaryzation.
Step 2, the text image of binaryzation is subjected to Fuzzy processing, purpose using box filter (Box Filter) It is noise reduction and the identifiable line segment of generation, fuzzy window selection will meet two conditions (fuzzy window is 6*6 pixel):
The gap between word space is obscured as far as possible, convenient for generating identifiable line segment when edge detection;
The gap of line space cannot be obscured.
Step 3, the picture being filtered is generated into side using multistage edge detection algorithm (example uses Canny algorithm) Edge.
Step 4, the picture generated using statistics Hough transformation, detection previous step.
Step 5, longest one is obtained in the line segment that previous step detects, calculates straight slope, and calculate according to slope Picture inclination angle.
Step 6, image is rotated according to inclination angle.
Step 7, postrotational image generates the other three image (be respectively be rotated by 90 °, 180 °, 270 °) respectively, uses Ocr identifies 4 images respectively, and highest discrimination is exactly final result.
The text image antidote of the embodiment of the present invention, can not only correct tilt angle certain a small range to Text image is corrected, and the text image of lateral inclination and reversed dip can be corrected.
Based on identical design, the embodiment of the present invention provides a kind of text image apparatus for correcting according to the above embodiments, The device for realizing text image correction in the above embodiments.Therefore, it is corrected in the text image of the various embodiments described above Description and definition in method, can be used for the understanding of each execution module in the embodiment of the present invention, specifically refer to above-mentioned reality Example is applied, is not being repeated herein.
One embodiment according to an embodiment of the present invention, the structure of text image apparatus for correcting is as shown in Fig. 2, for the present invention The structural schematic diagram for the text image apparatus for correcting that embodiment provides, the device can be used to implement in above-mentioned each method embodiment The correction of text image, the device include: Fuzzy Processing module 201, edge detection and Hough transformation module 202, computing module 203 and rotational correction module 204.Wherein:
Specifically, machine identifies for ease of calculation, Fuzzy Processing module on the basis of obtaining text image to be corrected 201 carry out binary conversion treatment to the text image to be corrected first, obtain the text image of binaryzation.Later, Fuzzy Processing mould The text image of the binaryzation is input to the box filter set by block 201, to utilize the box filter to the two-value The text image of change carries out Fuzzy processing, the text image being blurred.It is appreciated that for the text diagram of binaryzation Picture, wherein include multirow character, multirow character in the ranks and there is gap in the intercharacter of each line character, with can be normal Display and identification character.For these, in the ranks gap and intercharacter spacing, above-mentioned Fuzzy processing are that can be used to two-value It is filtered out in the text image of change with the character gap between a line adjacent character, and retains different row gaps in the ranks.
Later, edge detection and Hough transformation module 202 are such as calculated using Canny first with multistage edge detection algorithm Method detects the segment of these lower edges of each line character, is directed to each line character, edge detection and Hough transformation later Each segment of each segment of its top edge and lower edge is attached by module 202 respectively, formed a complete top edge and Lower edge, as row edge.
Followed by, on the basis of obtaining each line character corresponding line segment, computing module 203 passes through each line of detection Segment length finds length the maximum therein, namely finds longest line segment.Also, computing module 203 is according to reference coordinate The slope of the longest line segment detects in system, and the inclination angle of text image to be corrected further is judged by the slope of the line segment Degree.For example, can further judge that text image to be corrected is edge if the slope of the longest line segment known to calculating is 1/2 120 degree are counterclockwise tilted.
Finally, rotational correction module 204 can treat correction text image according to the actual angle of inclination carries out rotation processing, To be revolved just, namely it is consistent with the direction of reference frame.Such as judge that text image to be corrected is along counterclockwise for above-mentioned The case where direction has tilted 120 degree, and the direction of reference frame is 0 degree, then only need will text image be corrected along instantaneous needle Direction rotates 120 degree, can will text diagram image rotation be corrected just.
Text image apparatus for correcting provided in an embodiment of the present invention is filtered by the way that corresponding execution module is arranged using boxlike Wave device carries out Fuzzy processing to the text image of binaryzation, can effectively filter out each line character trace in text image Mark, and by carrying out further edge detection and Hough transformation, the corresponding line segment of each line character can be obtained, herein basis It is upper effectively and accurately to correct text image in the case where frame is not present in text.
It is understood that can be by hardware processor (hardware processor) come real in the embodiment of the present invention Each relative program module in the device of existing the various embodiments described above.Also, the text image apparatus for correcting benefit of the embodiment of the present invention With above-mentioned each program module, the text image correction process of above-mentioned each method embodiment can be realized, for realizing above-mentioned each In embodiment of the method when the correction of text image, beneficial effect that the device of the embodiment of the present invention generates and corresponding above-mentioned each side Method embodiment is identical, can refer to above-mentioned each method embodiment, details are not described herein again.
As the another aspect of the embodiment of the present invention, the present embodiment provides a kind of electronics according to the above embodiments and sets Standby, which includes memory, processor and is stored in the computer that can be run on the memory and on the processor Program when the processor executes the computer program, realizes the step of the text image antidote as described in the various embodiments described above Suddenly.
Further, the electronic equipment of the embodiment of the present invention can also include communication interface and bus.With reference to Fig. 3, for this The entity structure schematic diagram for the electronic equipment that inventive embodiments provide, comprising: at least one processor 301, at least one processing Device 302, communication interface 303 and bus 304.
Wherein, memory 301, processor 302 and communication interface 303 complete mutual communication by bus 304, communicate Interface 303 is for the information transmission between the electronic equipment and text image equipment;Being stored in memory 301 can be in processor The computer program run on 302 when processor 302 executes the computer program, realizes the text as described in the various embodiments described above The step of this image correction method.
It is to be understood that including at least memory 301, processor 302, communication interface 303 and bus in the electronic equipment 304, and memory 301, processor 302 and communication interface 303 form mutual communication connection by bus 304, and can be complete The program instruction of text image antidote is read from memory 301 at mutual communication, such as processor 302.In addition, Communication interface 303 can also realize the communication connection between the electronic equipment and text image equipment, and achievable mutual letter Breath transmission, such as text image correction is realized by communication interface 303.
When electronic equipment is run, processor 302 calls the program instruction in memory 301, real to execute above-mentioned each method Apply method provided by example, for example, text image to be corrected is subjected to binary conversion treatment, and utilizes box filter, it is right The text image of binaryzation carries out Fuzzy processing, with the character between a line adjacent character in the text image to filter out binaryzation Gap simultaneously retains different row gaps in the ranks;Using multistage edge detection algorithm, in the text image for detecting and connecting blurring The row edge of each line character, and each row in the text image of blurring is obtained by statistical probability Hough transformation based on row edge The line segment that character is formed;Length the maximum in all line segments is obtained, and passes through the slope of computational length the maximum, is calculated wait rectify The tilt angle of positive text image;Based on tilt angle, text image to be corrected is rotated, to realize correction etc..
Program instruction in above-mentioned memory 301 can be realized and as independent by way of SFU software functional unit Product when selling or using, can store in a computer readable storage medium.Alternatively, realizing that above-mentioned each method is implemented This can be accomplished by hardware associated with program instructions for all or part of the steps of example, and program above-mentioned can store to be calculated in one In machine read/write memory medium, when being executed, execution includes the steps that above-mentioned each method embodiment to the program;And storage above-mentioned Medium includes: USB flash disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), the various media that can store program code such as magnetic or disk.
The embodiment of the present invention provides a kind of non-transient computer readable storage medium also according to the various embodiments described above, deposits thereon Computer instruction is contained, when which is computer-executed, realizes that the text image as described in the various embodiments described above is rectified The step of correction method, for example, text image to be corrected is subjected to binary conversion treatment, and utilizes box filter, to two-value The text image of change carries out Fuzzy processing, with the character gap between a line adjacent character in the text image to filter out binaryzation And retain different row gaps in the ranks;Using multistage edge detection algorithm, detects and connect each row in the text image of blurring The row edge of character, and each line character in the text image of blurring is obtained by statistical probability Hough transformation based on row edge The line segment of formation;Length the maximum in all line segments is obtained, and passes through the slope of computational length the maximum, calculates text to be corrected The tilt angle of this image;Based on tilt angle, text image to be corrected is rotated, to realize correction etc..
Electronic equipment provided in an embodiment of the present invention and non-transient computer readable storage medium, by executing above-mentioned each reality Text image antidote described in example is applied, using box filter, Fuzzy processing, energy are carried out to the text image of binaryzation Enough each line character traces effectively filtered out in text image, and by carrying out further edge detection and Hough transformation, Can obtain the corresponding line segment of each line character, on this basis even if text be not present frame in the case where can effectively and Accurately correct text image.
It is understood that the embodiment of device described above, electronic equipment and storage medium is only schematic , wherein unit may or may not be physically separated as illustrated by the separation member, it can both be located at one Place, or may be distributed on heterogeneous networks unit.Some or all of modules can be selected according to actual needs To achieve the purpose of the solution of this embodiment.Those of ordinary skill in the art are without paying creative labor To understand and implement.
By the description of embodiment of above, those skilled in the art is it will be clearly understood that each embodiment can borrow Help software that the mode of required general hardware platform is added to realize, naturally it is also possible to pass through hardware.Based on this understanding, above-mentioned Substantially the part that contributes to existing technology can be embodied in the form of software products technical solution in other words, the meter Calculation machine software product may be stored in a computer readable storage medium, such as USB flash disk, mobile hard disk, ROM, RAM, magnetic disk or light Disk etc., including some instructions, with so that a computer equipment (such as personal computer, server or network equipment etc.) Execute method described in certain parts of above-mentioned each method embodiment or embodiment of the method.
In addition, those skilled in the art are it should be understood that in the application documents of the embodiment of the present invention, term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that including a series of elements Process, method, article or equipment not only include those elements, but also including other elements that are not explicitly listed, or Person is to further include for elements inherent to such a process, method, article, or device.In the absence of more restrictions, by The element that sentence "including a ..." limits, it is not excluded that in the process, method, article or apparatus that includes the element There is also other identical elements.
In the specification of the embodiment of the present invention, numerous specific details are set forth.It should be understood, however, that the present invention is implemented The embodiment of example can be practiced without these specific details.In some instances, it is not been shown in detail well known Methods, structures and technologies, so as not to obscure the understanding of this specification.Similarly, it should be understood that in order to simplify implementation of the present invention Example is open and helps to understand one or more of the various inventive aspects, above to the exemplary embodiment of the embodiment of the present invention Description in, each feature of the embodiment of the present invention is grouped together into single embodiment, figure or descriptions thereof sometimes In.
However, the disclosed method should not be interpreted as reflecting the following intention: i.e. the claimed invention is implemented Example requires features more more than feature expressly recited in each claim.More precisely, such as claims institute As reflection, inventive aspect is all features less than single embodiment disclosed above.Therefore, it then follows specific embodiment party Thus claims of formula are expressly incorporated in the specific embodiment, wherein each claim itself is real as the present invention Apply the separate embodiments of example.
Finally, it should be noted that above embodiments are only to illustrate the technical solution of the embodiment of the present invention, rather than it is limited System;Although the embodiment of the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art it is understood that It is still possible to modify the technical solutions described in the foregoing embodiments, or part of technical characteristic is carried out etc. With replacement;And these are modified or replaceed, each embodiment skill of the embodiment of the present invention that it does not separate the essence of the corresponding technical solution The spirit and scope of art scheme.

Claims (10)

1. a kind of text image antidote characterized by comprising
Text image to be corrected is subjected to binary conversion treatment, and utilizes box filter, mould is carried out to the text image of binaryzation Gelatinization processing, in the text image to filter out the binaryzation with the character gap between a line adjacent character and retain it is different in the ranks Row gap;
Using multistage edge detection algorithm, the row edge of each line character in the text image of blurring is detected and connected, and is based on The row edge obtains the line segment that each line character is formed in the text image of the blurring by statistical probability Hough transformation;
Obtain length the maximum in all line segments, and the slope by calculating described length the maximum, calculate it is described to Correct the tilt angle of text image;
Based on the tilt angle, the text image to be corrected is rotated, to realize correction.
2. text image antidote according to claim 1, which is characterized in that in the text image to binaryzation Before the step of carrying out Fuzzy processing, further includes:
The fuzzy window of the box filter is set, so that the fuzzy window meets following standard:
It can obscure in the text image of the binaryzation and be in the character gap between adjacent character in a line, and, it can Retain the row gap of adjacent character in the ranks in the text image of the binaryzation.
3. text image antidote according to claim 2, which is characterized in that it is described to utilize box filter, to two The step of text image progress Fuzzy processing of value, specifically includes:
According to the size of character in the text image of the binaryzation, the size that window is obscured in box filter is defined;
On the text image of the binaryzation, according to sequence from left to right, from top to bottom, the fuzzy window is slided, and During sliding, the pixel value of the text image of the corresponding binaryzation in the fuzzy window center is arranged to whole The average value of all pixels of the text image of the binaryzation of a fuzzy window covering.
4. text image antidote according to claim 1, which is characterized in that described to be calculated using multistage edge detection Method is detected and is specifically included the step of connecting the row edge of each line character in the text image of blurring:
Using the multistage edge detection algorithm, the edge of each line character in the text image of the blurring is detected;
Using dual threashold value-based algorithm, the edge of each line character in the text image of the blurring is attached respectively, is obtained The corresponding row edge of each line character in the text image of the blurring.
5. text image antidote according to claim 4, which is characterized in that described to be become by statistical probability Hough The step of changing, obtaining the line segment that each line character is formed in the text image of the blurring specifically includes:
A marginal point in the text image of the blurring is randomly selected, the marginal point has been demarcated as certain if detecting Point on one straight line then continues to randomly select a marginal point in the remaining edge point in the text image of the blurring, Until all marginal points are extracted;
Hough transformation is carried out to the marginal point of extraction, and accumulation calculating is carried out to Hough transformation result;
It is based on the accumulation calculating to be worth maximum point as a result, being chosen in hough space, and in the value of the maximum point of described value When greater than the first given threshold, according to the value of the maximum point of described value, using the maximum point of described value as basic point, along the basic point Place straightway is mobile, obtains two endpoints of the straightway;
Based on described two endpoints, calculate the length of the straightway, and if the length be greater than the second given threshold, export The straightway.
6. text image antidote according to any one of claims 1-5, which is characterized in that described in the rotation to Text image is corrected, is specifically included the step of correction with realizing:
According to the corresponding inclined direction of the tilt angle and angle, the text image to be corrected is rotated, obtains the first correction Image, and by the way that first correcting image is rotated by 90 ° in the same direction respectively, 180 ° and 270 °, it is corresponding to obtain the respectively Two correcting images, third correcting image and the 4th correcting image;
Using optical character recognition technology, first correcting image is identified respectively, and second correcting image, the third are rectified The character shown respectively in positive image and the 4th correcting image makees the corresponding correcting image of correct recognition rata soprano Finally to correct text image.
7. text image antidote according to claim 3, which is characterized in that the text according to the binaryzation The size of character in image, define box filter in obscure window size the step of specifically include:
According to the line space of the spacing of a line adjacent character and adjacent character row, defining institute in the text image of the binaryzation State the size of fuzzy window.
8. a kind of text image apparatus for correcting characterized by comprising
Fuzzy Processing module for text image to be corrected to be carried out binary conversion treatment, and utilizes box filter, to binaryzation Text image carry out Fuzzy processing, it is empty with the character between a line adjacent character in the text image to filter out the binaryzation Gap simultaneously retains different row gaps in the ranks;
Edge detection and Hough transformation module, for detecting and connecting the text diagram of blurring using multistage edge detection algorithm The row edge of each line character as in, and the text of the blurring is obtained by statistical probability Hough transformation based on the row edge The line segment that each line character is formed in this image;
Computing module, for obtaining length the maximum in all line segments, and by calculating the oblique of described length the maximum Rate calculates the tilt angle of the text image to be corrected;
Rotational correction module rotates the text image to be corrected, for being based on the tilt angle to realize correction.
9. a kind of electronic equipment, including memory, processor and it is stored on the memory and can transports on the processor Capable computer program, which is characterized in that when the processor executes the computer program, realize as in claim 1 to 7 The step of described in any item text image antidotes.
10. a kind of non-transient computer readable storage medium, is stored thereon with computer instruction, which is characterized in that the calculating The step of machine instruction is when being computer-executed, and realizes the text image antidote as described in any one of claims 1 to 7.
CN201910375401.8A 2019-05-07 2019-05-07 Text image correction method and device and electronic equipment Active CN110136069B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910375401.8A CN110136069B (en) 2019-05-07 2019-05-07 Text image correction method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910375401.8A CN110136069B (en) 2019-05-07 2019-05-07 Text image correction method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN110136069A true CN110136069A (en) 2019-08-16
CN110136069B CN110136069B (en) 2023-05-16

Family

ID=67576519

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910375401.8A Active CN110136069B (en) 2019-05-07 2019-05-07 Text image correction method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN110136069B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111260586A (en) * 2020-01-20 2020-06-09 北京百度网讯科技有限公司 Method and device for correcting distorted document image
CN111768378A (en) * 2020-06-29 2020-10-13 广东电网有限责任公司 Crimping hardware tool live-line detection method and device
CN111768345A (en) * 2020-05-12 2020-10-13 北京奇艺世纪科技有限公司 Method, device and equipment for correcting back image of identity card and storage medium
CN111768344A (en) * 2020-05-12 2020-10-13 北京奇艺世纪科技有限公司 Method, device and equipment for correcting front image of identity card and storage medium
CN112070678A (en) * 2020-08-10 2020-12-11 华东交通大学 Batch Western blot membrane strip inclination correction and segmentation method and system
CN112528724A (en) * 2020-09-17 2021-03-19 上海海隆软件有限公司 Table cell extraction method, device, equipment and computer readable storage medium
WO2022179471A1 (en) * 2021-02-25 2022-09-01 华为技术有限公司 Card text recognition method and apparatus, and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105761219A (en) * 2016-02-03 2016-07-13 北京云江科技有限公司 Inclination correction method and system of text image
CN105989366A (en) * 2015-01-30 2016-10-05 深圳市思路飞扬信息技术有限责任公司 Inclination angle correcting method of text image, page layout analysis method of text image, vision assistant device and vision assistant system
CN106097254A (en) * 2016-06-07 2016-11-09 天津大学 A kind of scanning document image method for correcting error
CN108681729A (en) * 2018-05-08 2018-10-19 腾讯科技(深圳)有限公司 Text image antidote, device, storage medium and equipment
WO2019056346A1 (en) * 2017-09-25 2019-03-28 深圳传音通讯有限公司 Method and device for correcting tilted text image using expansion method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105989366A (en) * 2015-01-30 2016-10-05 深圳市思路飞扬信息技术有限责任公司 Inclination angle correcting method of text image, page layout analysis method of text image, vision assistant device and vision assistant system
CN105761219A (en) * 2016-02-03 2016-07-13 北京云江科技有限公司 Inclination correction method and system of text image
CN106097254A (en) * 2016-06-07 2016-11-09 天津大学 A kind of scanning document image method for correcting error
WO2019056346A1 (en) * 2017-09-25 2019-03-28 深圳传音通讯有限公司 Method and device for correcting tilted text image using expansion method
CN108681729A (en) * 2018-05-08 2018-10-19 腾讯科技(深圳)有限公司 Text image antidote, device, storage medium and equipment

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
冯雷;耿英楠;: "基于hough变换的倾斜文档图像快速校正", 内蒙古师范大学学报(自然科学汉文版) *
周冠玮;平西建;程娟;: "基于改进Hough变换的文本图像倾斜校正方法", 计算机应用 *
尚新萍;兰瑛;: "一种新的基于Hough变换的文档图像倾斜矫正方法", 科技信息(科学教研) *
王晓君;陈锐;刁彦华;: "一种倾斜文本图像的旋转校正技术", 邯郸职业技术学院学报 *
王民等: "改进的SURF算法在书法笔画匹配识别中的应用", 《计算机工程与科学》 *

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111260586A (en) * 2020-01-20 2020-06-09 北京百度网讯科技有限公司 Method and device for correcting distorted document image
US11756170B2 (en) 2020-01-20 2023-09-12 Beijing Baidu Netcom Science Technology Co., Ltd. Method and apparatus for correcting distorted document image
CN111768345A (en) * 2020-05-12 2020-10-13 北京奇艺世纪科技有限公司 Method, device and equipment for correcting back image of identity card and storage medium
CN111768344A (en) * 2020-05-12 2020-10-13 北京奇艺世纪科技有限公司 Method, device and equipment for correcting front image of identity card and storage medium
CN111768344B (en) * 2020-05-12 2023-06-30 北京奇艺世纪科技有限公司 Correction method, device, equipment and storage medium for front image of identity card
CN111768378A (en) * 2020-06-29 2020-10-13 广东电网有限责任公司 Crimping hardware tool live-line detection method and device
CN112070678A (en) * 2020-08-10 2020-12-11 华东交通大学 Batch Western blot membrane strip inclination correction and segmentation method and system
CN112070678B (en) * 2020-08-10 2023-04-11 华东交通大学 Batch Western blot membrane strip inclination correction and segmentation method and system
CN112528724A (en) * 2020-09-17 2021-03-19 上海海隆软件有限公司 Table cell extraction method, device, equipment and computer readable storage medium
WO2022179471A1 (en) * 2021-02-25 2022-09-01 华为技术有限公司 Card text recognition method and apparatus, and storage medium

Also Published As

Publication number Publication date
CN110136069B (en) 2023-05-16

Similar Documents

Publication Publication Date Title
CN110136069A (en) Text image antidote, device and electronic equipment
US10885644B2 (en) Detecting specified image identifiers on objects
CN112348815B (en) Image processing method, image processing apparatus, and non-transitory storage medium
US20200184187A1 (en) Feature extraction and matching for biometric authentication
CN108351961B (en) Biological recognition system and computer implemented method based on image
KR20190129947A (en) Methods and apparatus for determining facial image quality, electronic devices and computer storage media
KR101032446B1 (en) Apparatus and method for detecting a vertex on the screen of a mobile terminal
US10349832B2 (en) Method of detecting boundary between iris and sclera
Lo et al. Joint trilateral filtering for depth map super-resolution
CN110427932A (en) The method and device of multiple document fields in a kind of identification image
CN110660072B (en) Method and device for identifying straight line edge, storage medium and electronic equipment
CN107545223B (en) Image recognition method and electronic equipment
CN110738078A (en) face recognition method and terminal equipment
CN109948521A (en) Image correcting error method and device, equipment and storage medium
US11687886B2 (en) Method and device for identifying number of bills and multiple bill areas in image
CN113947611A (en) Liquid level detection method and device, storage medium and electronic equipment
CN109190517A (en) A kind of finger venous image edge extracting and direction antidote
Vyacheslavovich et al. Advanced Hough-based method for on-device document localization
CN110598647A (en) Head posture recognition method based on image recognition
CN113870190B (en) Vertical line detection method, device, equipment and storage medium
CN108304840B (en) Image data processing method and device
Datta Credit Card Processing Using Cell Phone Images
Jang et al. Stroke-based semi-automatic region of interest detection algorithm for in-situ painting recognition
KR102616938B1 (en) Method for detecting barcode area and device for performing the method
CN112733829B (en) Feature block identification method, electronic equipment and computer readable storage medium

Legal Events

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