Method for evaluating precision of sub-pixel-level edge detection algorithm
The standard test images are generated by preset edge equations and function models, and the problems of artificial subjective factors and ideal edge simplification processing in the prior art are solved, and a more practical evaluation of subpixel-level edge detection algorithm accuracy is achieved.
Patent Information
- Application Number
- CN202411946287.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-27
AI Technical Summary
The existing subpixel-level edge detection algorithm accuracy evaluation methods have problems such as human subjective factors and ideal edge simplification processing, which leads to the lack of practical significance in the evaluation results.
The edges that conform to the real scene are constructed by preset edge equations, a standard test image is generated using a functional model, and the standard test image is detected using the subpixel-level edge detection algorithm to be evaluated, and the deviation between the detected value and the preset edge truth value is calculated to obtain the accuracy of the algorithm.
This method can generate test images that are more suitable for the actual scene, avoid the influence of human subjective factors, and simulate multiple complex edge features under one model, so that the algorithm evaluation results are more practical and universal.
Smart Images

Figure CN119762516A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method for evaluating the accuracy of a sub-pixel edge detection algorithm. Background Art
[0002] Image edge detection is the foundation of computer vision and image processing. Its core purpose is to identify the contours and structural information of objects in images. Image edge refers to the area where the local grayscale of the image changes significantly, which contains image features and plane geometric parameter information. Therefore, the accuracy of image edge detection directly affects the accuracy of subsequent image processing. With the continuous improvement of the requirements for image edge detection accuracy in practical applications, more and more sub-pixel edge detection algorithms have emerged.
[0003] As for the evaluation methods of sub-pixel edge detection algorithm accuracy, there are currently two main methods: manual labeling method and evaluation method based on ideal edge:
[0004] The manual labeling method manually labels the real edges in the image and compares the edges extracted by the algorithm with the manually labeled edges. The labeling process of this method is time-consuming and laborious, and human subjective factors may affect the labeling results. Especially when dealing with large-scale data sets, it is difficult to ensure the consistency and accuracy of the labeling.
[0005] The evaluation method based on ideal edge is to generate an ideal edge image through a theoretical model or a specific algorithm, and then compare the ideal edge with the edge extracted by the algorithm to be evaluated. Although this method can avoid the influence of human factors, the existing ideal edge construction method is to change the ideal edge grayscale into a neat mutation edge, which is a simplified processing of the edge of the real scene and cannot simulate the complexity and diversity of the image edge in the real scene. As a result, the accuracy obtained by the algorithm to be evaluated under this method cannot reflect its application performance in the real scene, which has limitations. Summary of the invention
[0006] In order to solve the above technical problems, the present invention provides a sub-pixel edge detection algorithm accuracy evaluation method, which can construct edges that conform to real scenes, and can construct a variety of complex and diverse edges for evaluation under one model, thereby making the evaluation more practical.
[0007] To this end, the technical solution is as follows:
[0008] A method for evaluating the accuracy of a sub-pixel edge detection algorithm comprises the following steps:
[0009] S1. Use a straight line equation or a curve equation to simulate an edge, and record it as edge line A; preset the minimum grayscale value on both sides of edge line A as G1 and the maximum grayscale value as G2; establish an image coordinate system, use i as the row mark and j as the column mark, and record one side of edge line A as positive and the other side as negative;
[0010] Remember, d ij = the distance between the center of the pixel in the i-th row and the j-th column and the edge line A; its positive or negative value is determined based on the position of the pixel in the i-th row and the j-th column relative to the edge line A;
[0011] S2, with d ij The gray value of each pixel is the independent variable, and the gray value of each pixel is the dependent variable. A function model is constructed to obtain the gray value of different pixels in the image and generate a standard test image.
[0012] The function model is a monotonic function, and the derivative has a unique maximum value;
[0013] The grayscale values of the different pixel points are between G1 and G2;
[0014] S3, using the sub-pixel edge detection algorithm to be evaluated to detect the standard test image, and obtaining the coordinates of each point on the edge line A in the measured image coordinate system, which are recorded as detection values;
[0015] S4. Calculate the deviation between the detection value and the edge line A in the standard test image, and use it as the accuracy of the sub-pixel edge detection algorithm to be evaluated.
[0016] Furthermore, the evaluation method further comprises the following steps:
[0017] S5. Adjust the coefficients of the independent variables, G1, and G2 in the function model of step S2, and repeat steps S2 to S4 to obtain the accuracy evaluation results of the sub-pixel edge detection algorithm to be evaluated in different transition band widths and different grayscale upper and lower bounds.
[0018] Furthermore, the function model in step S2 is a Sigmoid function, specifically:
[0019]
[0020] Among them, y(d ij ) represents the grayscale value of the pixel in the i-th row and j-th column in the standard test image, and e is a natural constant.
[0021] Furthermore, the function model in step S2 is a hyperbolic tangent function, specifically:
[0022]
[0023] Among them, y(d ij) represents the grayscale value of the pixel in the i-th row and j-th column in the standard test image, and tanh() represents the hyperbolic tangent function operation.
[0024] Furthermore, the function model in S2 is an inverse tangent function; specifically:
[0025]
[0026] Among them, y(d ij ) represents the grayscale value of the pixel in the i-th row and j-th column in the standard test image, and arctan() represents the inverse tangent function operation.
[0027] Furthermore, the method for calculating the deviation between the detection value and the edge line A in the standard test image in step S4 is:
[0028] 1) Calculate the distance between the detection value and the edge line A;
[0029] 2) Calculate the variance of all distance values obtained in 1) and then calculate the root mean square error.
[0030] Further, the method of calculating the deviation between the detection value and the edge line A in the standard test image in step S4 is: calculating the distance value from the detection value to the edge line A, determining the positive sign and the negative sign based on the position of the detection value relative to the edge line A, and recording the positive sign, the negative sign and the distance value finally determined as the value B;
[0031] Based on the value B, any one of the range, the sum of squares of deviations from the mean, the variance, the standard deviation and the coefficient of variation is calculated and taken as the deviation.
[0032] This method achieves the acquisition of the pixel image of the ideal edge true value by presetting the edge equation, and constructs a function model that converts pixel values into grayscale values based on the characteristics that the grayscale changes of pixels on both sides of the edge conform to the trend of a monotonic function, and uses the function model as a medium to generate a standard test image; the sub-pixel edge detection algorithm to be evaluated is used to detect the standard test image, thereby obtaining the detection value of the ideal edge image; the deviation between the detection value and the preset edge true value is calculated to obtain the detection accuracy data of the algorithm. This method achieves the acquisition of the ideal edge true value by presetting the edge equation, and introduces a function model to generate a standard test image, so that the generation process of the ideal edge test image is more in line with the edge grayscale change characteristics, and the test image is more in line with the actual scene, which not only avoids the influence of human subjective factors brought by manual annotation in the existing technology, but also overcomes the problem of the difference between the ideal edge and the actual edge in the existing method, making the algorithm evaluation more practical;
[0033] At the same time, this method provides a method for obtaining multiple groups of ideal edge images with different grayscale differences and different transition band widths under a function model, which can simulate edge features in different scenes, thereby obtaining the performance of the sub-pixel edge extraction algorithm to be evaluated in multiple scenes, avoiding the problem in the existing technology that the evaluation results cannot reflect its application performance in complex and changeable real scenes; making this method more universal and with practical application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a schematic diagram of the process flow of the method for evaluating the accuracy of the sub-pixel edge detection algorithm of the present invention;
[0035] Figure 2 It is a schematic diagram of the corresponding relationship between the edge grayscale image and the pixel grayscale value curve;
[0036] Figure 3a This is a schematic diagram of the process of constructing a function model using the Sigmoid function;
[0037] Figure 3b Schematic diagram of the distance between the pixel center and the edge line when building the function model. DETAILED DESCRIPTION
[0038] The technical solution of the present invention is described in detail below in conjunction with the accompanying drawings and embodiments.
[0039] A method for evaluating the accuracy of sub-pixel edge detection algorithms, such as Figure 1 As shown, the following steps are included:
[0040] S1. Use a straight line equation or a curve equation to simulate an edge, and record it as edge line A; preset the minimum grayscale value on both sides of edge line A as G1 and the maximum grayscale value as G2; establish an image coordinate system, use i as the row mark and j as the column mark, and record one side of edge line A as positive and the other side as negative;
[0041] Remember, d ij = the distance between the center of the pixel in the i-th row and the j-th column and the edge line A; its positive or negative value is determined based on the position of the pixel in the i-th row and the j-th column relative to the edge line A;
[0042] S2, with d ij The gray value of each pixel is the independent variable, and the gray value of each pixel is the dependent variable. A function model is constructed to obtain the gray value of different pixels in the image and generate a standard test image.
[0043] Among them, the function model is a monotonic function, and the derivative has a unique maximum value;
[0044] The grayscale values of different pixels are between G1 and G2;
[0045] S3, using the sub-pixel edge detection algorithm to be evaluated to detect the standard test image, and obtaining the coordinates of each point on the edge line A in the measured image coordinate system, which are recorded as detection values;
[0046] S4. Calculate the deviation between the detection value and the edge line A in the standard test image, and use it as the accuracy of the sub-pixel edge detection algorithm to be evaluated.
[0047] Furthermore, in order to obtain edges with different transition band widths and different grayscale upper and lower bounds for evaluation, the evaluation method further includes the following steps:
[0048] S5. Adjust the coefficients of the independent variables, G1, and G2 in the function model of step S2, and repeat steps S2 to S4 to obtain the accuracy evaluation results of the sub-pixel edge detection algorithm to be evaluated in different transition band widths and different grayscale upper and lower bounds.
[0049] In specific implementation, the edge transition band width can be adjusted by adjusting the coefficients of the independent variables in the function model; by adjusting G1 and G2, standard test images with different grayscale upper and lower limits can be obtained, that is, the grayscale on both sides of the edge line can be adjusted according to needs; by adjusting the edge transition band width and the grayscale values on both sides of the edge line, the edge lines in various actual situations can be simulated; the value range of G1 and G2 is 0 to 255.
[0050] like Figure 2 As shown in the figure, along the normal direction of the edge line A on the grayscale image, the grayscale value curve g(d) of each pixel point conforms to the law of monotonically increasing or monotonically decreasing, where the edge of the image is located in the area where the curve changes the steepest, that is, the first-order derivative g'(d) of the grayscale value curve is calculated, and the position where the first-order derivative is the largest is the theoretical position of its edge.
[0051] Therefore, in the specific implementation, the function model in step S2 can use the Sigmoid function as a specific implementation method, such as Figure 3a , 3b As shown, according to step S1, the upper and lower limits of the grayscale values on both sides of the edge line A are G1 and G2. ij = 0, that is, the independent variable of the Sigmoid function is 0, the slope of the curve is the largest, and the gray value changes most dramatically, indicating that the pixel is located on the edge line; when the distance d from the pixel to the edge line A is ij When approaching positive infinity or negative infinity, the dependent variable of the Sigmoid function gradually approaches G2 or G1, indicating that the farther the pixel is from the edge line, the smoother the gray value changes, which is consistent with the edge characteristics of the image. Therefore, a model based on the Sigmoid function can be constructed to generate a standard test image, specifically;
[0052]
[0053] Among them, y(d ij ) represents the gray value of the pixel in the i-th row and j-th column in the standard test image, and e is a natural constant. By adopting this function model, the corresponding gray value can be assigned to each pixel in step S1, so that the edge line A in step S1 is converted from a pixel image to a gray image, that is, a standard test image of the edge line A is generated.
[0054] As a second implementation of constructing the function model in step S2, the function model in step S2 may also be a hyperbolic tangent function, specifically:
[0055]
[0056] Among them, y(d ij ) represents the grayscale value of the pixel in the i-th row and j-th column in the standard test image, and tanh() represents the hyperbolic tangent function operation.
[0057] Further, as a third implementation of constructing the function model in step S2, the function model in step S2 may be an inverse tangent function; specifically:
[0058]
[0059] Among them, y(d ij ) represents the grayscale value of the pixel in the i-th row and j-th column in the standard test image, and arctan() represents the inverse tangent function operation.
[0060] Furthermore, the method for calculating the deviation between the detection value and the edge line A in the standard test image in step S4 is:
[0061] 1) Calculate the distance between the detection value and the edge line A;
[0062] 2) Calculate the variance of all distance values obtained in 1) and then calculate the root mean square error.
[0063] The smaller the RMS error is, the higher the detection accuracy of the sub-pixel edge detection algorithm is.
[0064] As another implementation, the method of calculating the deviation between the detection value and the edge line A in the standard test image in step S4 is: calculating the distance value from the detection value to the edge line A, determining the positive sign and the negative sign based on the position of the detection value relative to the edge line A, and recording the final determined positive sign, negative sign and distance value as the value B;
[0065] Based on the value B, any one of the extreme difference, the sum of squares of the deviation from the mean, the variance, the standard deviation and the coefficient of variation is obtained, and the deviation is taken as the deviation. The smaller the calculated deviation value is, the higher the detection accuracy of the sub-pixel edge detection algorithm is. Those skilled in the art may also select other existing deviation calculation methods in combination with the purpose of achieving the goal.
[0066] This method achieves the acquisition of pixel images of ideal edge true values by presetting edge equations, and constructs a function model that converts pixel values into gray values based on the characteristics that the grayscale changes of pixels on both sides of the edge conform to the trend of a monotonic function, and generates a standard test image using the function model as a medium; the sub-pixel edge detection algorithm to be evaluated is used to detect the standard test image, thereby obtaining the detection value of the ideal edge image; because the ideal edge true value is known by presetting, and the standard test image is generated based on the ideal edge true value, in order to obtain the detection accuracy of the algorithm, the deviation between the detection value and the preset edge true value can be directly calculated. This method achieves the acquisition of the edge line true value by presetting the edge equation, and introduces a function model to complete the generation of a standard test image of the edge line true value, thereby achieving the acquisition of an ideal edge test image that fits the actual application scenario; it overcomes the problem of differences between ideal edges and actual edges in existing methods;
[0067] At the same time, a method for obtaining multiple groups of ideal edge images with different grayscale differences and different transition band widths under a function model is given. This method can be used to simulate edge features in different scenes, thereby obtaining the performance of the sub-pixel edge extraction algorithm to be evaluated in a variety of scenes, avoiding the problem in the prior art that the evaluation results cannot reflect its application performance in real scenes; making this method more universal and with practical application value.
[0068] The foregoing description of the specific exemplary embodiments of the present invention is presented for the purpose of illustration and description. The foregoing description is not intended to be exhaustive, nor is it intended to limit the present invention to the precise form disclosed, and it is apparent that many changes and variations are possible in light of the above teachings. The exemplary embodiments are selected and described to explain the specific principles of the present invention and its practical application, so that other technicians in the field can realize and utilize the various exemplary embodiments of the present invention and its different selected forms and modified forms. The scope of the present invention is intended to be limited by the appended claims and their equivalents.
Claims
1. A method for evaluating the accuracy of a sub-pixel edge detection algorithm, characterized in that: The evaluation method comprises the following steps: S1. Use a straight line equation or a curve equation to simulate an edge, and record it as edge line A; preset the minimum grayscale value on both sides of edge line A as G1 and the maximum grayscale value as G2; establish an image coordinate system, use i as the row mark and j as the column mark, and record one side of edge line A as positive and the other side as negative; Remember, d ij = the distance between the center of the pixel in the i-th row and the j-th column and the edge line A; its positive or negative value is determined based on the position of the pixel in the i-th row and the j-th column relative to the edge line A; S2, with d ij The gray value of each pixel is the independent variable, and the gray value of each pixel is the dependent variable. A function model is constructed to obtain the gray value of different pixels in the image and generate a standard test image. The function model is a monotonic function, and the derivative has a unique maximum value; The grayscale values of the different pixel points are between G1 and G2; S3, using the sub-pixel edge detection algorithm to be evaluated to detect the standard test image, and obtaining the coordinates of each point on the edge line A in the measured image coordinate system, which are recorded as detection values; S4. Calculate the deviation between the detection value and the edge line A in the standard test image, and use it as the accuracy of the sub-pixel edge detection algorithm to be evaluated.
2. The evaluation method according to claim 1, characterized in that: The following steps are also included: S5. Adjust the coefficients of the independent variables, G1, and G2 in the function model of step S2, and repeat steps S2 to S4 to obtain the accuracy evaluation results of the sub-pixel edge detection algorithm to be evaluated in different transition band widths and different grayscale upper and lower bounds.
3. The evaluation method according to claim 1 or 2, characterized in that: The function model in step S2 is a Sigmoid function, specifically: Among them, y(d ij ) represents the grayscale value of the pixel in the i-th row and j-th column in the standard test image, and e is a natural constant.
4. The evaluation method according to claim 1 or 2, characterized in that: The function model in step S2 is a hyperbolic tangent function, specifically: Among them, y(d ij ) represents the grayscale value of the pixel in the i-th row and j-th column in the standard test image, and tanh() represents the hyperbolic tangent function operation.
5. The evaluation method according to claim 1 or 2, characterized in that: The function model in S2 is an inverse tangent function; specifically: Among them, y(d ij ) represents the grayscale value of the pixel in the i-th row and j-th column in the standard test image, and arctan() represents the inverse tangent function operation.
6. The evaluation method according to claim 1 or 2, characterized in that: The method of calculating the deviation between the detection value and the edge line A in the standard test image in step S4 is: 1) Calculate the distance between the detection value and the edge line A; 2) Calculate the variance of all distance values obtained in 1) and then calculate the root mean square error.
7. The evaluation method according to claim 1 or 2, characterized in that: The method of calculating the deviation between the detection value and the edge line A in the standard test image in step S4 is as follows: calculating the distance value from the detection value to the edge line A, determining the positive sign and the negative sign based on the position of the detection value relative to the edge line A, and recording the final positive sign, negative sign and distance value as the value B; Based on the value B, any one of the range, the sum of squares of deviations from the mean, the variance, the standard deviation and the coefficient of variation is calculated and taken as the deviation.
Citation Information
Patent Citations
Sub-pixel edge detection method based on Gaussian fitting
CN105894521A
Image edge detection precision evaluation method
CN107424164A
Sub pixel edge based circle center detecting method
CN107516325A
Checkerboard image feature central sub-pixel positioning method
CN108510543A
Method for detecting linear edge sub-pixels in laser tailor-welding image of to-be-welded workpiece
CN109934820A