CN107092909A - Angle detection algorithm based on triangle correspondence theorem - Google Patents

Angle detection algorithm based on triangle correspondence theorem Download PDF

Info

Publication number
CN107092909A
CN107092909A CN201710170378.XA CN201710170378A CN107092909A CN 107092909 A CN107092909 A CN 107092909A CN 201710170378 A CN201710170378 A CN 201710170378A CN 107092909 A CN107092909 A CN 107092909A
Authority
CN
China
Prior art keywords
image
curve
point
angle
curves
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
CN201710170378.XA
Other languages
Chinese (zh)
Other versions
CN107092909B (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.)
Hangzhou Sutian Technology Co Ltd
Original Assignee
Hangzhou Sutian 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 Hangzhou Sutian Technology Co Ltd filed Critical Hangzhou Sutian Technology Co Ltd
Priority to CN201710170378.XA priority Critical patent/CN107092909B/en
Publication of CN107092909A publication Critical patent/CN107092909A/en
Application granted granted Critical
Publication of CN107092909B publication Critical patent/CN107092909B/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/243Aligning, centring, orientation detection or correction of the image by compensating for image skew or non-uniform image deformations

Abstract

The invention discloses a kind of angle detection algorithm based on similar triangles, comprise the following steps:Step one, image binaryzation;Step 2, expansive working, projecting edge curve are carried out to the binary image of generation;Step 3, binary image is projected from top to bottom and from bottom to top, respectively obtains the lower edges curve of image, and respectively obtains the available point initial address and termination address of the effective row of lower edges curve first;Step 4, lower edges curve combination is handled into complete rectangular edges curve, selects one section of abscissa identical line segment on the left of image lower edges curve initial address respectively;Whether the angle for judging two sections of curves is right angle, and whether selected two sections of curves are located at the efficiency curve on the curve of image border;Step 5, selects one section of satisfactory line segment, using quick reciprocal square root algorithm and Pythagorean theorem, calculates the inverse of hypotenuse, and then obtain the sine value and cosine value at angle of inclination.

Description

Angle detection algorithm based on triangle correspondence theorem
Technical field
The invention belongs to angle detection field, specifically a kind of angle detection algorithm based on triangle correspondence theorem.
Background technology
Among life of today, the certificate such as identity card, business card often duplicated, fax in terms of use because Inclined phenomenon much can all occur in the reason for manual operation, scanned image out, and these inclinations will be to business card etc. Printed page analysis, character recognition and duplicating are used and can all had undesirable effect, it is therefore desirable to inclined to there is inclined image Rake angle is detected, then carries out image rectification according to angle of inclination.
Among practical application, existing all kinds of image inclination angle detection techniques are that first input picture is filtered mostly Ripple, binaryzation etc. are operated, and obtain a width binary image, sharp-edged by image reflects, and is then calculated by Hough Son, Sobel operators, least square method scheduling algorithm analyze the boundary curve of image, finally give image inclination angle.The above method Accuracy of detection it is high, but the overall amount of calculation of module can be caused bigger than normal, add occupancy of the module to internal memory.
Chinese patent CN201210483489.3 is special《A kind of workpiece angle self-operated measuring unit and survey based on image procossing Amount method》A kind of image processing method is disclosed, image is strengthened by algorithm of histogram equalization, Susan angles are used Point detection algorithm or Harris Corner Detection Algorithm detection image angle points(Angle point:The summit of angle)The angle point of image is calculated, The topography around angle point after rim detection is extracted, the point formed on two straight lines of angle is extracted, on two straight lines Point is fitted, and obtains the slope of two straight lines, and then calculate the angle of two straight lines.
Chinese patent CN200810246629.9《The measuring method and device of image inclination angle of business card》Propose one kind The method of angle of inclination detection, image is judged with the presence or absence of inclination by the inclined degree of business card image frame straight line, then right There is the editor direction that inclined picture judges its word, and projected along word incline direction, calculated using projection properties The angle of inclination of image.
Both the above method, although the precision of detection is high, but its is computationally intensive, committed memory is high, for operation platform Be configured with certain requirement, and for the relatively low operation platform of some configurations, above method can not be applicable completely.
The content of the invention
In order to solve above-mentioned technical problem present in prior art, the invention provides a kind of based on similar triangles Angle detection algorithm, comprises the following steps:
Step one, image binaryzation:Divide an image into comprising n*n pixel in multiple pieces, each block, to the pixel in block Point is handled, and finally gives binary image, extracts image border;
Step 2, expansive working, projecting edge curve are carried out to the binary image of generation;
Step 3, binary image is projected from top to bottom and from bottom to top, and the lower edges for respectively obtaining image are bent Line, and respectively obtain the available point initial address and termination address of the effective row of lower edges curve first;
Step 4, lower edges curve combination is handled into complete rectangular edges curve, respectively in image lower edges One section of abscissa identical line segment of selection on the left of curve initial address;Utilized for the triangle using two sections of selected line segments as hypotenuse Similar triangles theorem judged, whether the angle for judging two sections of curves is right angle, and selected two sections of curves whether Efficiency curve on the curve of image border;
Step 5, selects one section of satisfactory line segment, using quick reciprocal square root algorithm and Pythagorean theorem, calculates hypotenuse Inverse, and then obtain the sine value and cosine value at angle of inclination.
Further, in the step one, the change severe degree to pixel in each piece is calculated, and can determine whether this Whether block is located at image border, and carry out binary conversion treatment.
Further, in the step 3, calculating in obtained image effective range, to image from both direction up and down Projected, respectively obtain the lower edges curve of image, obtain first available point of the effective row of top edge curve first Coordinate point_l1 and last effective point coordinates point_r1, and first of the effective row of lower edge curve first Effective point coordinates point_l2 and last effective point coordinates point_r2.
Further, in the step 3, if obtained point_l1 or point_l2 any one less than threshold value join Number, then judge that inclination is not present in the image, otherwise the image is tilted.
Further, in the step 4, by the rectangle that image lower edges one width of Curves compilation respectively obtained is complete Image border curve, on the left of lower edges curve point_l1/point_l2 in coextensive, selection starting point coordinate and Point coordinates two sections of curves of identical are terminated, whether using triangle correspondence theorem, it is right angle to judge two curve angles, while can be with Judge whether be located on the curve of image border at selected 4 points.
Further, in step one, in process block when pixel, image right side and the pixel of bottom less than n*n The block of point is without any processing.
Further, if two triangles using two sections of curves of selection as hypotenuse are similar, it is right angle to judge its angle, And two sections of selected curves are the efficiency curves being located on image border.
Further, due to detection object be rectangle business card, four angles of image are all 90 degree, if therefore two sections of curves folder Angle is right angle, then the starting point and terminating point of two sections of curves of explanation are located on the edge of rectangular image, use this two sections of curve meters Calculate the angle of inclination of business card;If the angle of two sections of curves is not right angle, illustrate starting point and the end of two sections of curves of selection Stop is not at least on the edge of rectangular image, i.e., the point is miscellaneous point, it is necessary to which two sections of curves of selection are judged in addition.
The present invention the angle detection algorithm based on triangle correspondence theorem be suitable for and internal memory not high to required precision compared with Small angle detection system.The present invention is only needed to input single pass view data, it is not necessary to which coloured image is converted into gray scale Image;Can synchronously it be carried out for the binaryzation of image, expansion, generation boundary curve, it is not necessary to which large space comes at storage image Intermediate data during reason;On the premise of precision is ensured, the processing procedure of image is simplified, the effect of angle detection is improved Rate, has saved system space.
Brief description of the drawings
Fig. 1 is original image schematic diagram;
Fig. 2 is image segmentation schematic diagram;
Fig. 3 is image expansion schematic diagram;
Fig. 4 is boundary scan schematic diagram;
Fig. 5 is tracing analysis schematic diagram.
Embodiment
The invention will be further described below in conjunction with the accompanying drawings.
The present invention is by taking business card scan image as an example.This carries out binary conversion treatment to the image of input first, passes through projection Method obtains the lower edges curve of image, each selects one section of corresponding curve in lower edges curve, judges the two of selection Whether section curve is located on the boundary curve of rectangular image, and then one section of curve of reselection calculates the angle of inclination of business card.
As shown in figure 1, system receives the business card image that width scanning is obtained, it is only necessary to its gray level image or coloured image Single-channel data, you can detection obtains the sine value and cosine value of its tilt angle theta.
As shown in Fig. 2 entire image is divided into several blocks(patch), each block(patch)It is interior to include n*n picture Vegetarian refreshments, the patch on the right side of image and bottom less than n*n pixel is without any processing;For satisfactory patch, The average value of its n*n pixel is calculated first, then calculates pixel average and block(patch)Interior each pixel it is poor exhausted To value, difference average value is taken to absolute value summation, difference average value is compared with the threshold parameter inputted, if more than threshold value, Then pixel size variation is larger in the patch, is likely located at image border, the block(patch)For available point, by the patch 1 is designated as, is otherwise Null Spot, is designated as 0.Finally give width binary image as shown in Figure 3.
As shown in figure 3, carrying out expansion process to obtained binary image, the new block of a width is generated(patch)Figure, new block (patch)Each patch values are preset as 0 in figure, if the block in the m*m size windows chosen(patch)Value and more than threshold value Parameter, then expanded, by new block(patch)Block in figure in correspondence window(patch)Value is all designated as 1, otherwise keeps new Block(patch)Former block in figure(patch)Value is constant.By the selection window of expansion to one unit of right translation, next area is selected Domain carries out expansive working;If row expansion is finished, beginning progress expansive working is first opened from next every trade.Ultimately generate width expansion Binary image afterwards, prominent image curve edge.The patch values for completing expansion are counted, statistics is effective per row/column The number of point, if result is more than threshold parameter, then the row/column is effective row/column, it is possible thereby to determine the effective district of image Domain.
As shown in figure 4, carrying out projection scanning from both direction up and down to the binary image after expansion, each row are recorded First available point and last available point, finally give the rectangular image top edge curve as shown in Fig. 4 image rights With lower edge curve.According to the effective image area of determination, record first available point point_l1 of first effective row with And last available point point_r1, and first available point point_l2 of last effective row and last Available point point_r2.If point_l1 and point_l2 are both greater than threshold parameter, the image is tilted, and otherwise judges the image In the absence of inclination.
As shown in figure 5, the lower edges curve of image can constitute the boundary curve of view picture business card image, in point_l1 and A sector address identical curve is each selected on the left of point_l2, its width is default parameter off_dis, calculates top edge bent The difference in height h1 of curve is determined in line selection, and lower edge curve selectes the difference in height h2 of curve, using triangle correspondence theorem, calculates | h1*h2-off_dis*off_dis | absolute value, and threshold parameter is compared, if result is less than threshold parameter, judges The corresponding triangle of two sections of curves is similar, and the angle that two sections of curves are formed is right angle, because four angles of rectangular image are all Right angle, therefore when the angle of two sections of selected curves is right angle, illustrate that selecting two sections of curves is all located at rectangular image edge On efficiency curve, available for the slanted angle for calculating image, otherwise selected point is miscellaneous outside the curve of image border Point is judged, it is necessary to select two sections of curves again.
According to a selected efficiency curve, using quick reciprocal square root algorithm and Pythagorean theorem, hypotenuse is calculated Inverse, and then obtain the sine value and cosine value at angle of inclination.

Claims (8)

1. the angle detection algorithm based on similar triangles, it is characterised in that:Comprise the following steps:
Step one, image binaryzation:Divide an image into comprising n*n pixel in multiple pieces, each block, to the pixel in block Point is handled, and finally gives binary image, extracts image border;
Step 2, expansive working, projecting edge curve are carried out to the binary image of generation;
Step 3, binary image is projected from top to bottom and from bottom to top, and the lower edges for respectively obtaining image are bent Line, and respectively obtain the available point initial address and termination address of the effective row of lower edges curve first;
Step 4, lower edges curve combination is handled into complete rectangular edges curve, respectively in image lower edges One section of abscissa identical line segment of selection on the left of curve initial address;Utilized for the triangle using two sections of selected line segments as hypotenuse Similar triangles theorem judged, whether the angle for judging two sections of curves is right angle, and selected two sections of curves whether Efficiency curve on the curve of image border;
Step 5, selects one section of satisfactory line segment, using quick reciprocal square root algorithm and Pythagorean theorem, calculates hypotenuse Inverse, and then obtain the sine value and cosine value at angle of inclination.
2. the angle detection algorithm based on similar triangles according to claim 1, it is characterised in that:In the step one, Change severe degree to pixel in each piece is calculated, and can determine whether that whether the block is located at image border, and carry out two-value Change is handled.
3. the angle detection algorithm based on similar triangles according to claim 1, it is characterised in that:In the step 3, Calculating in obtained image effective range, image is being projected from both direction up and down, respectively obtaining the upper following of image Edge curve, obtains the first effective point coordinates point_l1 and last available point of the effective row of top edge curve first Coordinate point_r1, and first effective point coordinates point_l2 of the effective row of lower edge curve first and last Effective point coordinates point_r2.
4. the angle detection algorithm based on similar triangles according to claim 3, it is characterised in that:In the step 3, If any one is less than threshold parameter by obtained point_l1 or point_l2, then judge that inclination is not present in the image, otherwise The image is tilted.
5. the angle detection algorithm based on similar triangles according to claim 3, it is characterised in that:In the step 4, By the rectangular image boundary curve that image lower edges one width of Curves compilation respectively obtained is complete, in lower edges curve On the left of point_l1/point_l2 in coextensive, selection starting point coordinate and termination point coordinates two sections of curves of identical, profit Triangle correspondence theorem is used, whether judge two curve angles is right angle, while may determine that whether be located at figure at selected 4 points As on boundary curve.
6. the angle detection algorithm based on similar triangles according to claim 2, it is characterised in that:In step one, at place When managing pixel in block, image right side and bottom are without any processing less than the block of n*n pixel.
7. the angle detection algorithm based on similar triangles according to claim 5, it is characterised in that:If with the two of selection Section curve is similar for two triangles of hypotenuse, and it is right angle to judge its angle, and two sections of selected curves are to be located at image side Efficiency curve on edge.
8. the angle detection algorithm based on similar triangles according to claim 7, it is characterised in that:Because detection object is Rectangle business card, four angles of image are all 90 degree, if therefore the angles of two sections of curves is right angle, illustrate the starting point of two sections of curves And terminating point is located on the edge of rectangular image, the angle of inclination of business card is calculated using this two sections of curves;If the folder of two sections of curves Angle is not right angle, then illustrates the starting point and terminating point of two sections of curves of selection at least not at the edge of rectangular image On, i.e., the point is miscellaneous point, it is necessary to which two sections of curves of selection are judged in addition.
CN201710170378.XA 2017-03-21 2017-03-21 Angle detection algorithm based on triangle correspondence theorem Active CN107092909B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710170378.XA CN107092909B (en) 2017-03-21 2017-03-21 Angle detection algorithm based on triangle correspondence theorem

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710170378.XA CN107092909B (en) 2017-03-21 2017-03-21 Angle detection algorithm based on triangle correspondence theorem

Publications (2)

Publication Number Publication Date
CN107092909A true CN107092909A (en) 2017-08-25
CN107092909B CN107092909B (en) 2019-06-14

Family

ID=59648988

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710170378.XA Active CN107092909B (en) 2017-03-21 2017-03-21 Angle detection algorithm based on triangle correspondence theorem

Country Status (1)

Country Link
CN (1) CN107092909B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112509033A (en) * 2020-11-25 2021-03-16 国网四川省电力公司阿坝供电公司 Iron tower inclination automatic detection method and device based on image processing

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5832110A (en) * 1996-05-28 1998-11-03 Ricoh Company, Ltd. Image registration using projection histogram matching
CN101420507A (en) * 2007-10-26 2009-04-29 村田机械株式会社 Image processing apparatus, image scanning apparatus, and image processing method
CN101625760A (en) * 2009-07-28 2010-01-13 谭洪舟 Method for correcting certificate image inclination
CN101770575A (en) * 2008-12-31 2010-07-07 汉王科技股份有限公司 Method and device for measuring image inclination angle of business card
CN101930594A (en) * 2010-04-14 2010-12-29 山东山大鸥玛软件有限公司 Rapid correction method for scanning document image
CN104966089A (en) * 2015-06-24 2015-10-07 福建联迪商用设备有限公司 Two-dimensional code image edge detection method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5832110A (en) * 1996-05-28 1998-11-03 Ricoh Company, Ltd. Image registration using projection histogram matching
CN101420507A (en) * 2007-10-26 2009-04-29 村田机械株式会社 Image processing apparatus, image scanning apparatus, and image processing method
CN101770575A (en) * 2008-12-31 2010-07-07 汉王科技股份有限公司 Method and device for measuring image inclination angle of business card
CN101625760A (en) * 2009-07-28 2010-01-13 谭洪舟 Method for correcting certificate image inclination
CN101930594A (en) * 2010-04-14 2010-12-29 山东山大鸥玛软件有限公司 Rapid correction method for scanning document image
CN104966089A (en) * 2015-06-24 2015-10-07 福建联迪商用设备有限公司 Two-dimensional code image edge detection method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
仇伟涛: "《复杂文本图像倾斜校正算法研究》", 《中国优秀硕士学位论文全文数据库信息科技辑》 *
吴飞飞: "《文本图像倾斜校正算法的研究与应用》", 《中国优秀硕士学位论文全文数据库信息科技辑》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112509033A (en) * 2020-11-25 2021-03-16 国网四川省电力公司阿坝供电公司 Iron tower inclination automatic detection method and device based on image processing
CN112509033B (en) * 2020-11-25 2024-04-09 国网四川省电力公司阿坝供电公司 Automatic iron tower inclination detection method and device based on image processing

Also Published As

Publication number Publication date
CN107092909B (en) 2019-06-14

Similar Documents

Publication Publication Date Title
CN108335302B (en) Region segmentation method and device
TWI655586B (en) Method and device for detecting specific identification image in predetermined area
CN105469027B (en) For the horizontal and vertical lines detection and removal of file and picture
JP4847592B2 (en) Method and system for correcting distorted document images
CN105426834B (en) A method of form image detection is carried out based on projection properties and structure feature
JP2012243307A (en) Method for detecting strain in input image, device for detecting strain in input image and computer readable medium
JP2002133426A (en) Ruled line extracting device for extracting ruled line from multiple image
CN110188778B (en) Residential area element outline regularization method based on image extraction result
CN109376740A (en) A kind of water gauge reading detection method based on video
CN107452035B (en) Method and apparatus for analyzing lane line image and computer readable medium thereof
CN103488986A (en) Method for segmenting and extracting characters in self-adaptation mode
CN109886935A (en) A kind of road face foreign matter detecting method based on deep learning
CN112364834A (en) Form identification restoration method based on deep learning and image processing
KR101377910B1 (en) Image processing method and image processing apparatus
JP2002228423A (en) Tire detecting method and device
JP3471578B2 (en) Line direction determining device, image tilt detecting device, and image tilt correcting device
CN112733855B (en) Table structuring method, table recovering device and device with storage function
CN114140416A (en) Glass edge detection method and system based on machine vision
CN112036232B (en) Image table structure identification method, system, terminal and storage medium
JPH0418351B2 (en)
CN107092909B (en) Angle detection algorithm based on triangle correspondence theorem
US7440636B2 (en) Method and apparatus for image processing
CN112419207A (en) Image correction method, device and system
CN105930813B (en) A method of detection composes a piece of writing this under any natural scene
CN108629226B (en) Vehicle detection method and system based on image layering technology

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