Linear high-precision repositioning method based on Hough transform result and image sub-pixel edge point regression
By integrating Hough transform with sub-pixel edge point regression, the problems of insufficient linear positioning accuracy and low efficiency in industrial inspection are solved, and high-precision part size measurement and linear highway sign positioning are achieved.
Patent Information
- Application Number
- CN202510898476.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-07-01
AI Technical Summary
In existing technologies, traditional methods for industrial inspection and linear traffic sign positioning have difficulty achieving sub-pixel-level linear positioning, and suffer from quantization errors, noise interference, and low computational efficiency.
By fusing the coarse positioning results of Hough transform with the local regression optimization of sub-pixel edge points, and combining gradient calculation, sub-pixel edge point selection, cubic spline interpolation and least squares fitting, accurate fitting of straight line parameters is achieved.
It improves the accuracy and efficiency of part size measurement, avoids the omission of key indicators, and significantly improves the precision and accuracy of straight line detection.
Smart Images

Figure CN120765745A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision and image processing technology, and specifically to a high-precision straight line repositioning method based on Hough transform and sub-pixel edge point regression. The method is particularly suitable for precise dimension calculation in industrial inspection and component measurement, as well as for positioning of linear highway signs and other related industries. Background Art
[0002] In related fields such as industrial inspection and linear traffic sign positioning, image dimensional measurement of components (such as common nuts and bolts) requires sub-pixel accuracy to ensure product quality. Traditional manual measurement or integer pixel-based inspection methods are susceptible to quantization errors and noise interference, making it difficult to meet high-precision requirements. In addition, part measurement often requires extracting geometric parameters such as side distance and thickness. However, the existing Hough transform discretizes the parameter space, leading to linear positioning deviations. While sub-pixel technology can improve edge accuracy, it lacks the constraints of a global linear model and has low computational efficiency.
[0003] The Hough transform, a classic line detection method, suffers from quantization errors due to the discretization of parameter space, resulting in limited line positioning accuracy and susceptibility to noise. Sub-pixel edge detection techniques (such as the moment method and gradient optimization) can further improve edge positioning accuracy, but they have high global computational complexity and lack line model constraints. Traditional line fitting methods (such as the least squares method) are sensitive to outliers and struggle to integrate sub-pixel information to optimize global parameters. Existing improved solutions (such as the two-stage method and parameter space interpolation) combine the Hough transform with sub-pixel points but are still limited by initial parameter deviations and computational efficiency. The urgent need for high sub-pixel line precision in fields such as industrial inspection and 3D reconstruction has driven the development of new methods based on Hough coarse positioning and local sub-pixel iterative regression, achieving a balance between accuracy and efficiency through error compensation models and robust optimization. Summary of the Invention
[0004] The purpose of the present invention is to provide a high-precision straight line repositioning method based on Hough transform results and sub-pixel edge point regression to measure the size of parts or locate linear highway signs in an image. By fusing the coarse positioning results of the Hough transform with the local regression optimization of sub-pixel edge points, accurate fitting of straight line parameters is achieved, solving the problems of insufficient part size measurement accuracy and low efficiency in industrial inspection.
[0005] The technical solutions for achieving the purpose of the present invention are as follows:
[0006] A high-precision line relocation method based on Hough transform results and image sub-pixel edge point regression includes the following steps:
[0007] 1) Perform gradient calculation on the original image to calculate the gradient in the horizontal and vertical directions respectively, as shown in formula (1) and formula (2), and calculate the gradient modulus to obtain the edge strength, as shown in formula (3):
[0008] (1)
[0009] (2)
[0010] (3)
[0011] Among them, x and y represent the pixel coordinates in the image, g x and g y is the gradient component in the x and y directions, I(x, y) represents the grayscale value of the image at the pixel (x, y), and g represents the gradient amplitude; then, the sub-pixel edge points are selected;
[0012] In the x-direction or y-direction, three sampling points are formed, such as g1(x1,y), g2(x2,y), g3(x3,y) in the x-direction and g1(x,y1), g2(x,y2), g3(x,y3) in the y-direction. The coordinates of the sub-pixel edge points are calculated by cubic spline interpolation. The interpolation formula is shown in the following equation (4):
[0013] (4)
[0014] Among them, g1 and g3 are the gradient amplitudes of adjacent integer edge points, g2 is the gradient amplitude of the current integer edge point, is the offset of the current pixel relative to the integer coordinate; and is the offset in the x and y directions, and The values are equal, and the precise sub-pixel coordinates in the x-direction are obtained based on the calculated offset. and the y-direction sub-pixel coordinates , Indicates the coordinates of the center point;
[0015] 2) Define a two-dimensional accumulator matrix to store each integer pixel edge point (x I i , y I i ), calculate the corresponding distance at different angles ; The calculation formula is as follows:
[0016] (5)
[0017] in, is the vertical distance from the origin to the line in Hough space, is the angle between the vertical line and the positive direction of the x-axis; the most significant straight line can be obtained in turn by using the method of finding the maximum value and the method of non-maximum suppression. and Parameter, k represents the total number of lines to be detected;
[0018] from Polar coordinates to Cartesian coordinates The conversion formula is as shown in formula (6), where x and y represent the abscissa x and ordinate y in the Cartesian coordinate system respectively:
[0019] (6)
[0020] After obtaining the preliminary line parameters, given , according to formula (7), from the entire sub-pixel point set of the image Extract the sub-image edge point set that meets the following conditions :
[0021] (7)
[0022] For the extracted sub-pixel edge point set Perform the least squares straight line fitting, as shown in formula (8):
[0023] (8)
[0024] in, is the coordinate of the sub-pixel edge point, based on the integer edge point It is concluded that is the predicted value of the fitted line; n represents the number of sub-pixel edge points used for fitting; the error function is , in order to minimize the sum of squared errors, that is ,tidy and , as shown in formula (9) and formula (10) respectively:
[0025] (9)
[0026] (10)
[0027] The beneficial effects of this invention include: By integrating coarse positioning using the Hough transform with local regression optimization of sub-pixel edge points, the invention achieves precise fitting of line parameters, addressing the issues of insufficient precision, low efficiency, and missed key indicators in part dimensional measurement during industrial inspection. This method achieves high-precision linear positioning in industrial inspections, significantly improving the efficiency and accuracy of dimensional measurement of standard parts such as nuts compared to manual measurement and traditional algorithms, while also avoiding missed key indicators. BRIEF DESCRIPTION OF DRAWINGS
[0028] Figure 1 For optoelectronic experiment platform.
[0029] Figure 2 (b) and Figure 2 (c) are shown, respectively, the horizontal and vertical gradients of the image are calculated, and the results of the two are fused by formula (6) to obtain Figure 2 (c), the real edge points are retained by the screening method of the center pixel edge point. From Figure 2 (c) and Figure 2 The comparison of the magnified results of (c) and (d) can be seen that the edge line after screening is narrower, and can more accurately reflect the geometric contour in the image. Only the edge points with gradient amplitude exceeding the threshold value of 40 are retained, and finally the image as Figure 2 (e) is beneficial to subsequent straight line detection and high-precision positioning
[0030] Figure 3 The point is the integer type edge point coordinate after segmentation in the last section, and the offset of the direction can be determined by . The offset of the direction can be determined by . Figure 3 The white in represents the integer type edge point, and the red represents the sub-pixel edge point. It can be seen that the red point has ( ) offset from the white point.
[0031] Figure 4 The schematic diagrams of Hough straight line detection using integer type pixel points and Hough transform straight line detection using sub-pixel points are respectively shown in (a) and (b), and it can be seen that Figure 4 is closer to the outer contour of the edge, significantly improving the precision of straight line detection.
[0032] Figure 5 The schematic diagram of high-precision measurement of the distance between the nut part and the edge and the thickness by using image processing technology is shown in (a), which is a usable case of the present application. DETAILED DESCRIPTION
[0033] In Example 1, the original image is first obtained through the photoelectric platform. The physical resolution of the photoelectric platform is determined by the field of view and the width or height of the image captured by the camera. The width and height of the image captured by the MV-HP500GM industrial camera are 2448 pixels and 2048 pixels respectively, the total number of pixels is 5 million, and the physical size width of the chip target surface is 47.83 mm. Therefore, the physical resolution of the photoelectric platform is approximately 47.83 mm / 2448 pixels = 0.0195 mm / pixel. Figure 1 As shown, the original image is then subjected to gradient calculation, with the horizontal and vertical gradients calculated separately, and the gradient modulus calculated to obtain the edge strength. The center point of the maximum gradient value is located by fusion results, and the width of the edge pixels is gradually reduced. Then, the invalid edge points are filtered out by the center maximum principle to obtain accurate integer edges. Finally, the cubic spline gradient value maximum criterion is used to accurately locate the coordinates of the sub-pixel edge points. In order to further filter out image noise, only edge points with a gradient amplitude exceeding the threshold value greater than 40 (general selection method) are retained by thresholding, and finally the following is generated. Figure 2 (e) shows the edge point extraction result, and Figure 2 (c) and Figure 2 (d) Compared with Figure 2 The edge line in (e) only occupies one pixel, which is beneficial for subsequent line detection and high-precision positioning.
[0034] Example 2 starts with extracting sub-pixel edge points from an image. Direction or direction, three sampling points will be formed, such as Directional and Directional The coordinates of the sub-pixel edge points are calculated by cubic spline interpolation. The interpolation formula is (6). According to the calculated offset, the precise Sub-pixel coordinates in the y and y directions, such as Figure 3 Points in is the integer edge point coordinate after segmentation in the previous section, then It can be determined Direction offset ,Depend on It can be determined Direction offset .exist Figure 3 It can be seen that the sub-pixel edge points (red dots) are offset compared to the integer edge points.
[0035] Example 3 defines a two-dimensional accumulator matrix AC, the value range of its direction variables is , this matrix is used to store each For each integer pixel edge point (x I i , y I i ), calculated at different angles The corresponding distance under The corresponding unit AC in the accumulator matrix Increment by 1 to complete the voting statistics of all edge points. Use the non-maximum suppression method in the cumulative matrix to gradually extract the line parameters. To avoid repeated detection, find the position with obvious maximum value from the cumulative matrix each time. , suppress the neighborhood range. After obtaining the initial straight line parameters by converting formula (8), give , usually , extract the sub-image edge point set Q that meets the following conditions from the entire sub-pixel point set P of the image. For the extracted sub-pixel edge point set Q={( , ),( , ), ,…,( , )}, use formula (10) to perform least squares linear fitting, in order to minimize the sum of squared errors, sort a S and b S , as in formula (11) and formula (12), through the return parameter (a S , b S ), and find the starting coordinates of the line segments contained in the straight line through threshold judgment and the end point coordinates ,as follows Figure 4 As shown in the figure, there are schematic diagrams of using integer pixel points for Hough line detection (green line) and using sub-pixel points for Hough transform line detection (blue line). It can be seen that the straight line obtained by sub-pixel point Hough transform line detection is closer to the outer contour of the edge than the straight line obtained by integer pixel point Hough line detection, thereby significantly improving the accuracy of line detection.
[0036] The sub-pixel straight line fitting algorithm based on Hough transform used in Example 4 measures the nut side distance and the side line segments after fitting are named , . Line segment The starting point coordinates and the end point coordinates can be expressed as 、 Similarly, line segments The starting point coordinates and the end point coordinates can be expressed as 、 First calculate the coordinates of the center point of each line and , expressed as , ,in, and Line segments and Next, calculate the distance from each center point to another line segment. To the straight line The distance is expressed as , center point To the straight line The distance is expressed as The final distance between the edges is the average of these two distances. The measurement diagram is Figure 5 .
[0037] Matters not covered by the present invention are known technologies.
[0038] The above embodiments are intended only to illustrate the technical concepts and features of the present invention. Their purpose is to enable those skilled in the art to understand the contents of the present invention and implement them accordingly. They are not intended to limit the scope of protection of the present invention. Any equivalent changes or modifications made in accordance with the spirit of the present invention are intended to be covered by the scope of protection of the present invention.
Claims
1. A high-precision line relocation method based on Hough transform results and image sub-pixel edge point regression, characterized by: 1) Perform gradient calculation on the original image to calculate the gradient in the horizontal and vertical directions respectively, as shown in formula (1) and formula (2), and calculate the gradient modulus to obtain the edge strength, as shown in formula (3): (1); (2); (3); Among them, x and y represent the pixel coordinates in the image, g x and g y is the gradient component in the x and y directions, I(x, y) represents the grayscale value of the image at the pixel (x, y), and g represents the gradient amplitude; then, the sub-pixel edge points are selected; 2) Define a two-dimensional accumulator matrix to store each integer pixel edge point (x I i , y I i ), calculate the corresponding distance at different angles ; The calculation formula is as follows: (5); in, is the vertical distance from the origin to the line in Hough space, is the angle between the vertical line and the positive direction of the x-axis; the most significant straight line can be obtained in turn by using the method of finding the maximum value and the method of non-maximum suppression. and Parameter, k represents the total number of lines to be detected; from Polar coordinates to Cartesian coordinates The conversion formula is as shown in formula (6), where x and y represent the abscissa x and ordinate y in the Cartesian coordinate system respectively: (6); After obtaining the preliminary line parameters, given , according to formula (7), from the entire sub-pixel point set of the image Extract the sub-image edge point set that meets the following conditions : (7); For the extracted sub-pixel edge point set Perform the least squares straight line fitting, as shown in formula (8): (8); in, is the coordinate of the sub-pixel edge point, based on the integer edge point It is concluded that is the predicted value of the fitted line; n represents the number of sub-pixel edge points used for fitting; the error function is , in order to minimize the sum of squared errors, that is ,tidy and , as shown in formula (9) and formula (10) respectively: (9) (10)。 2. The linear high-precision repositioning method according to claim 1, wherein: The sub-pixel edge point selection in step (1) is as follows: in the x-direction or y-direction, three sampling points are formed, such as g1(x1,y), g2(x2,y), g3(x3,y) in the x-direction and g1(x,y1), g2(x,y2), g3(x,y3) in the y-direction; the coordinates of the sub-pixel edge points are calculated by the cubic spline interpolation method, and the interpolation formula is shown in the following formula (4): (4); Among them, g1 and g3 are the gradient amplitudes of adjacent integer edge points, g2 is the gradient amplitude of the current integer edge point, is the offset of the current pixel relative to the integer coordinate; and is the offset in the x and y directions, and The values are equal, and the precise sub-pixel coordinates in the x-direction are obtained based on the calculated offset. and the y-direction sub-pixel coordinates , Indicates the center point coordinates.
Citation Information
Patent Citations
Rapid sub pixel edge detection and locating method based on machine vision
CN104268857A
Workpiece linear edge positioning method for machine vision
CN108416787A
Complex-shape guide rail sliding block size measurement method based on intelligent vision
CN119984033A
High-density circuit board circular hole sub-pixel detection method based on gaussian fitting
WO2018209941A1
Hough transform-based license plate tilt correction method
WO2023097931A1