Sub-pixel edge tracking method, device and medium based on gray moment model

By adopting a sub-pixel edge tracking method based on a gray-scale moment model, the problem of insufficient accuracy of traditional edge tracking methods is solved, and sub-pixel-level edge detection is achieved, thereby improving the accuracy of industrial inspection.

CN118674741BActive Publication Date: 2025-10-21ZHEJIANG UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410784916.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2025-10-21
Estimated Expiration
2044-06-18

AI Technical Summary

Technical Problem

Traditional edge tracking methods rely on pixel-level edges, making it difficult to achieve sub-pixel-level detection accuracy and failing to meet the technical requirements of high-precision detection.

Method used

A subpixel edge tracking method based on the gray-scale moment model is adopted. By calculating the gradient map of the gray-scale image, setting an initial gradient threshold to filter edge anchor points, and performing convolution calculation using the subpixel calculation region and mask, the subpixel distance and angle are determined, and the next edge tracking point is selected until all edge anchor points have been traversed.

Benefits of technology

It improves the accuracy of edge tracking to the sub-pixel level, optimizes the selection of tracking direction, and enhances the accuracy of industrial inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118674741B_ABST
    Figure CN118674741B_ABST
Patent Text Reader

Abstract

The present application aims at the problem that the existing image edge detection relies on pixel-level edge and has low detection accuracy, and provides a sub-pixel edge tracking method, device and medium based on gray moment model. The method comprises the following steps: obtaining a gray image of a target to be detected and calculating a gradient image; determining edge anchor points based on an initial gradient threshold T1; tracking sub-pixel edges of the image for all edge anchor points; selecting a sub-pixel calculation region, and performing convolution calculation combined with a mask to obtain region image moment values; calculating sub-pixel distances and angles of the edge anchor points to determine sub-pixel positions; selecting a next edge tracking point in the pixel points in the neighborhood centering on the currently selected edge anchor point, and if the gradient of the next edge tracking point is greater than a preset final gradient threshold T2, the next edge tracking point is taken as an edge anchor point for continuous tracking; until the traversal of all edge anchor points is completed, all edge tracking points are obtained; and all edge tracking points are sorted as sub-pixel edge tracking results. The present application is used for sub-pixel level tracking of image edges.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a sub-pixel edge tracking method, device and medium based on a grayscale moment model, and belongs to the technical field of image edge tracking. Background Art

[0002] In the field of industrial image processing, achieving high-precision image edge tracking is of great significance for visual measurement and inspection technologies. Traditional edge tracking methods are mostly based on pixel-level edges, which makes it difficult to achieve sub-pixel detection accuracy, which cannot meet the technical requirements of high-precision inspection applications. Summary of the Invention

[0003] In order to solve the problem that existing image edge detection relies on pixel-level edges and has low detection accuracy, the present invention provides a sub-pixel edge tracking method, device and medium based on a grayscale moment model.

[0004] The present invention provides a sub-pixel edge tracking method based on a grayscale moment model, which obtains a grayscale image of a target to be detected, and uses an image gradient calculation formula to calculate the gradients of all pixels in the grayscale image to obtain a gradient image.

[0005] Set the initial gradient threshold T1 according to the maximum and minimum gradient values ​​in the gradient map, and use the pixel points in the grayscale map whose gradient is greater than the initial gradient threshold T1 as edge anchor points, and store all edge anchor points in the stack;

[0006] Use the edge anchor point at the beginning of the stack as the search starting point to track the sub-pixel edge of the image:

[0007] A neighborhood of size n*n centered on the edge anchor point selected in the grayscale image is used as a sub-pixel calculation area, where n is an odd number greater than 1; a corresponding mask is calculated based on the pixel points in the sub-pixel calculation area; a convolution calculation is performed on the sub-pixel calculation area and the mask to obtain a regional image moment value; the sub-pixel distance and angle corresponding to the selected edge anchor point are calculated based on the regional image moment value, and the sub-pixel position corresponding to the currently selected edge anchor point is determined; then, with the currently selected edge anchor point as the center, the next edge tracking point is selected from the pixel points in the neighborhood of the currently selected edge anchor point according to the current sub-pixel position and angle; if the gradient of the edge tracking point is greater than the preset final gradient threshold T2, the edge tracking point is used as the next edge anchor point for continued tracking; otherwise, the current tracking is terminated;

[0008] Then continue to track the edge tracking point of the next edge anchor point in the stack until all edge anchor points are traversed and all edge tracking points are obtained; during the tracking process, the tracked pixels will not be tracked repeatedly;

[0009] Arrange all edge tracking points as sub-pixel edge tracking results.

[0010] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, the pixel gradient is represented by G, including the X-direction gradient G x and the Y-direction gradient G y :

[0011]

[0012] G x =3f(x+1,y-1)+10f(x+1,y)+3f(x+1,y+1)-3f(x-1,y-1)-10f(x-1,y)-3f(x-1,y+1),

[0013] G y =3f(x-1,y-1)+10f(x,y-1)+3f(x+1,y-1)-3f(x-1,y+1)-10f(x,y+1)-2f(x+1,y+1),

[0014] Where x represents the X-direction coordinate of the pixel in the grayscale image, y represents the Y-direction coordinate of the pixel in the grayscale image; and f is the grayscale value.

[0015] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, the initial gradient threshold T1 is:

[0016] T1=T_max-0.2(T_max-T_min),

[0017] Where T_max is the maximum gradient value and T_min is the minimum gradient value.

[0018] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, the calculation formula of the mask is:

[0019] M pq =∫∫x p y q f(x,y)dxdy,

[0020] M pq The p-order q-fold mask of the sub-pixel calculation area is used, where p is the order of the mask and q is the number of times the mask is applied.

[0021] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, six masks M are obtained according to the pixel points of the sub-pixel calculation area. 00 ,M 11 ,M 10 ,M 01 ,M 20 ,M 02 :

[0022] Among them, M 00The 0th order and 0th degree mask of the sub-pixel calculation area; M 11 The first-order and first-order mask of the sub-pixel calculation area; M 10 The 1st order 0th order mask of the sub-pixel calculation area; M 01 is the 0th order 1st mask of the sub-pixel calculation area; M 20 The 2nd order 0th order mask of the sub-pixel calculation area; M 02 Computes a 0-order quadratic mask for the sub-pixel region.

[0023] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, the sub-pixel angle is expressed as θ:

[0024]

[0025] Where m pq For M pq The corresponding regional image moment value.

[0026] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, the sub-pixel distance is expressed as l:

[0027]

[0028] Where m′ pq For m pq The corresponding image moment value of the rotated region;

[0029] m′ 00 =m 00 ,

[0030]

[0031] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, the sub-pixel position (x, y) corresponding to the currently selected edge anchor point is:

[0032]

[0033] Where x0 is the X-axis coordinate of the currently selected edge anchor point, y0 is the Y-axis coordinate of the currently selected edge anchor point, and N is the size of the sub-pixel calculation area.

[0034] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, the method for selecting the next edge tracking point among the pixels in the neighborhood of the currently selected edge anchor point according to the current sub-pixel position and angle is as follows:

[0035] Select the pixels in the 8-neighborhood of the currently selected edge anchor point, and denote the currently selected edge anchor point as e. The 8-neighborhood pixels of e are a, b, c, d, f, g, h, and i, and a, b, c, d, e, f, g, h, and i form a three-row and three-column matrix.

[0036] 1) The sub-pixel distance l is greater than 0 and like Then select the next edge tracking point as d; if Then select the next edge tracking point as a;

[0037] 2) The sub-pixel distance l is greater than 0 and like Then select the next edge tracking point as i; if Then select the next edge tracking point as f;

[0038] 3) The sub-pixel distance l is less than 0 and like Then select the next edge tracking point as b; if Then select the next edge tracking point as c;

[0039] 4) The sub-pixel distance l is less than 0 and like Then select the next edge tracking point as h; if Then the next edge tracking point is selected as g.

[0040] According to the sub-pixel edge tracking method based on the grayscale moment model of the present invention, the final gradient threshold T2 is set based on experience according to the grayscale image.

[0041] The present invention also provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor.

[0042] When the processor executes the computer program, the steps of any one of the methods are implemented.

[0043] The present invention also provides a medium storing computer-executable instructions, wherein the computer-executable instructions are used to enable a computer to execute any one of the methods.

[0044] Beneficial effects of the present invention: The method of the present invention utilizes a sub-pixel moment model to improve the accuracy of edge tracking and optimize the selection of tracking direction, thereby achieving sub-pixel edge tracking accuracy, which contributes to the development of industrial detection technology.

[0045] The method of the present invention first calculates the gradient of the image to obtain a gradient map, then sets a threshold to filter edge tracking anchor points. Based on the anchor points, the image is traversed, and a 5*5 neighborhood of each pixel is selected as the sub-pixel fitting area. The model coefficients are calculated using a mask, and the sub-pixel edge position is estimated using a sub-pixel position formula. The sub-pixel edge tracking angle is used to select sequential tracking points. Compared with the existing technology, the present invention can improve detection accuracy to the sub-pixel level and optimize the edge tracking direction using the angle of the grayscale moment model. The method of the present invention improves edge tracking accuracy in industrial visual inspection. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 is a flow chart of the sub-pixel edge tracking method based on the grayscale moment model of the present invention;

[0047] Figure 2 It is a schematic diagram of the sub-pixel calculation area;

[0048] Figure 3 This is a schematic diagram of the 8-neighborhood search direction of the currently selected edge anchor point;

[0049] Figure 4 This is a schematic diagram of the first case of selecting the next edge tracking point; O in the figure is the coordinate origin;

[0050] Figure 5 This is a schematic diagram of the second case of selecting the next edge tracking point;

[0051] Figure 6 This is a schematic diagram of the third case of selecting the next edge tracking point;

[0052] Figure 7 This is a schematic diagram of the fourth case of selecting the next edge tracking point. DETAILED DESCRIPTION

[0053] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.

[0054] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0055] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but they are not intended to limit the present invention.

[0056] Specific implementation method 1. Combination Figure 1 and Figure 2As shown, the present invention provides a sub-pixel edge tracking method based on the grayscale moment model, which obtains a grayscale image of the target to be detected, and uses the image gradient calculation formula to calculate the gradients of all pixels in the grayscale image to obtain a gradient image;

[0057] Set the initial gradient threshold T1 according to the maximum and minimum gradient values ​​in the gradient map, and use the pixel points in the grayscale map whose gradient is greater than the initial gradient threshold T1 as edge anchor points, and store all edge anchor points in the stack;

[0058] Use the edge anchor point at the beginning of the stack as the search starting point to track the sub-pixel edge of the image:

[0059] A neighborhood of size n*n centered on the edge anchor point selected in the grayscale image is used as the sub-pixel calculation area, where n is an odd number greater than 1; a corresponding mask is obtained based on the pixel points in the sub-pixel calculation area; a convolution calculation is performed on the sub-pixel calculation area and the mask to obtain a regional image moment value; the sub-pixel distance and angle corresponding to the selected edge anchor point are calculated based on the regional image moment value, and the sub-pixel position corresponding to the currently selected edge anchor point is determined; at the same time, the current edge anchor point is marked as a tracked point; then, with the currently selected edge anchor point as the center, the next edge tracking point is selected from the pixel points in the neighborhood of the currently selected edge anchor point according to the current sub-pixel position and angle; if the gradient of the edge tracking point is greater than the preset final gradient threshold T2, the edge tracking point is used as the next edge anchor point for continued tracking; otherwise, the current tracking is terminated; the conditions for terminating the current tracking include: the target point has been marked as tracked; the gradient of the current point does not meet the threshold T2 constraint; the search encounters the image boundary;

[0060] Then continue to track the edge tracking point of the next edge anchor point in the stack until all edge anchor points are traversed and all edge tracking points are obtained; during the tracking process, the tracked pixels will not be tracked repeatedly;

[0061] Arrange all edge tracking points as sub-pixel edge tracking results.

[0062] As an example, a 5*5 neighborhood centered at the selected edge anchor point may be selected as the sub-pixel calculation area.

[0063] In this embodiment, the grayscale image is a target grayscale image acquired by using a high-resolution grayscale camera, or an image acquired by using a color camera and performing weighted averaging of RGB three-channel pixels.

[0064] In this embodiment, the pixel gradient is represented by G, which refers to the change in image grayscale per unit pixel along a certain direction, including the X-direction gradient G x and the Y-direction gradient G y :

[0065]

[0066] G x =3f(x+1,y-1)+10f(x+1,y)+3f(x+1,y+1)-3f(x-1,y-1)-10f(x-1,y)-3f(x-1,y+1),

[0067] G y =3f(x-1,y-1)+10f(x,y-1)+3f(x+1,y-1)-3f(x-1,y+1)-10f(x,y+1)-2f(x+1,y+1),

[0068] Where x represents the X-direction coordinate of the pixel in the grayscale image, y represents the Y-direction coordinate of the pixel in the grayscale image; and f is the grayscale value.

[0069] This implementation uses multiple pixels within a 3x3 neighborhood to calculate the gradient value. When calculating the X-direction gradient, in addition to the grayscale value in the X direction, the Y-direction gradient change value is also weighted. A similar method is used to calculate the Y-direction gradient. Compared to gradient calculation methods that only use a single direction, this method uses more neighborhood pixel information and can better reflect the grayscale transformation of the image.

[0070] In this embodiment, points with gradient values ​​greater than a threshold value T1 are screened out based on the gradient map, and these points are regarded as edge anchor points.

[0071] The initial gradient threshold T1 is set based on the gradient map and used for anchor point search. A zero matrix Z (all zeros) of the same size as the grayscale image is constructed. The gradient map is then traversed row by row and column by column. If the gradient value at a point (x, y) exceeds the threshold T1, it is marked as the search edge anchor point, and the pixel at the corresponding position in the Z matrix is ​​marked as 1.

[0072] The initial gradient threshold T1 is:

[0073] T1=T_max-0.2(T_max-T_min),

[0074] Where T_max is the maximum gradient value and T_min is the minimum gradient value.

[0075] If the edge anchor point coordinates are (x0, y0), then two pixels above, below, left and right of the anchor point are taken as the sub-pixel calculation area, and the area range is 5*5. This area is the candidate area.

[0076] The edge anchor points reflect the points with the strongest edge attributes in the image, while the gradient is the most prominent characteristic of the edge. Points with the largest gradients in the image are set as anchor points to reflect the edge characteristics. The threshold is calculated using the highest and lowest gradients in the image, and points above the threshold are set as gradient anchor points.

[0077] The first anchor point in the stack is extracted and used as the starting point for the search. These anchor points serve as salient edge points in the image, and subsequent edge tracking is based on these anchor points. There are many anchor points in the stack, and the algorithm processes them sequentially, selecting the anchor point at the beginning of the stack first. The order of the anchor points in the stack is determined by their storage order.

[0078] like Figure 2 As shown, the sub-pixel calculation area is 5*5. The image sub-pixel candidate area is obtained by selecting a fixed-length area centered on the edge anchor point. The size of the fixed area is generally an odd number, such as 3*3, 5*5, 7*7, etc. However, a smaller calculation area cannot fully reflect the sub-pixel characteristics of the pixel's neighborhood. A larger area requires more computation and introduces greater model bias for sub-pixel calculation. Based on experience and a comprehensive analysis of sub-pixel features, this implementation selects a 5*5 area.

[0079] Furthermore, the calculation formula of the mask is:

[0080] M pq =∫∫x p y q f(x,y)dxdy,

[0081] M pq Compute a p-order, q-order mask for the sub-pixel region, where p is the mask order and q is the mask degree. f(x, y) is an image function representing the grayscale value. When computing the moment model, the image function is treated as a constant of 1 at each pixel.

[0082] In this embodiment, combined with Figure 2 As shown, the candidate region is convolved with the mask to calculate the image moments of different orders of the candidate region. The six masks obtained by calculating the pixels of the sub-pixel calculation area are M 00 ,M 11 ,M 10 ,M 01 ,M 20 ,M 02 :

[0083] Among them, M 00 The 0th order and 0th degree mask of the sub-pixel calculation area; M 11 The first-order and first-order mask of the sub-pixel calculation area; M 10 The 1st order 0th order mask of the sub-pixel calculation area; M01 is the 0th order 1st mask of the sub-pixel calculation area; M 20 The 2nd order 0th order mask of the sub-pixel calculation area; M 02 The 0th-order quadratic mask of the sub-pixel calculation area is used. When the neighborhood size of the edge anchor point is 5*5, the mask volume value is as follows:

[0084]

[0085]

[0086] The moment mask value required to calculate the sub-pixel model is related to the size of the calculation area. The mask value in this embodiment is only applicable to the 5*5 pixel neighborhood and not to other neighborhoods. For example, the mask of the 3*3 neighborhood cannot simply use the middle value of 5*5, and the value of the 7*7 mask is not simply expanded on the basis of the 5*5 mask value. The corresponding neighborhood values ​​need to be recalculated. The mask and the image sub-pixel area are calculated using convolution to obtain the different order image moments m corresponding to each pixel point. 00 ,m 01 ,m 10 ,m 11 ,m 02 ,m 20 .

[0087] Going further, the sub-pixel angle refers to the angle between the edge direction and the center of the current point in the moment model.

[0088] The sub-pixel angle is denoted as θ:

[0089]

[0090] Where m pq For M pq The corresponding regional image moment value.

[0091] The sub-pixel distance is denoted as l:

[0092]

[0093] Where m′ pq For m pq The corresponding image moment value of the rotated region;

[0094] m0′0=m 00 ,

[0095]

[0096] The sub-pixel position (x, y) corresponding to the currently selected edge anchor point is:

[0097]

[0098] Where x0 is the X-axis coordinate of the currently selected edge anchor point, y0 is the Y-axis coordinate of the currently selected edge anchor point, and N is the size of the sub-pixel calculation area. In this embodiment, N = 5. The sub-pixel point position is calculated based on the pixel-level point, and the specific value is calculated using the image moment formula.

[0099] Going further, combined Figures 3 to 7 As shown in , among the pixels in the neighborhood of the currently selected edge anchor point, the method for selecting the next edge tracking point based on the current sub-pixel position and angle is:

[0100] Select the pixel points in the 8-neighborhood of the currently selected edge anchor point, and select the next edge tracking point according to the direction of the pixel gradient. The currently selected edge anchor point is represented as e, and the 8-neighborhood pixel points of e are a, b, c, d, f, g, h, i. A three-row and three-column matrix is ​​formed by a, b, c, d, e, f, g, h, i. The rule for position search is:

[0101] 1) Combination Figure 4 As shown, the sub-pixel distance l is greater than 0 and like Then select the next edge tracking point as d; if Then select the next edge tracking point as a;

[0102] 2) Combination Figure 5 As shown, the sub-pixel distance l is greater than 0 and like Then select the next edge tracking point as i; if Then select the next edge tracking point as f;

[0103] 3) Combination Figure 6 As shown, the sub-pixel distance l is less than 0 and like Then select the next edge tracking point as b; if Then select the next edge tracking point as c;

[0104] 4) Combination Figure 7 As shown, the sub-pixel distance l is less than 0 and like Then select the next edge tracking point as h; if Then the next edge tracking point is selected as g.

[0105] The number of pixels in a neighborhood should not exceed 8. You can choose it according to actual needs.

[0106] In this embodiment, the final gradient threshold T2 is set empirically based on the grayscale image. In this embodiment, the termination condition for edge tracking point search is that the edge pixel gradient is less than T2, or the current point has been marked as tracked, or the search encounters an image boundary.

[0107] After traversing along an anchor point, the next point is selected from the anchor point image and the search is repeated until all anchor points are searched.

[0108] In edge tracking, selecting the tracking direction is a core issue. This implementation uses image moments to calculate the tracking direction of sub-pixel edges. The next point is selected based on the sub-pixel edge angle of each point, providing a more granular tracking direction selection method. The advantage of this method is that it combines sub-pixel calculation with tracking direction selection, improving edge accuracy while simultaneously determining edge direction and reducing computational complexity.

[0109] After the traversal of one anchor point is completed, the next point is selected from the anchor point image to continue the search until all anchor point searches are completed. The search process along an anchor point includes four steps: selecting the initial point, selecting the tracking direction, determining whether it is an edge point, and sub-pixel calculation. After the search process based on the current anchor point is completed, the search for the next anchor point is carried out. Points that have been sub-pixel calculated during the search process will be marked as tracked and will no longer participate in further processing. It is worth noting that if the current anchor point has been sub-pixel tracked, the search based on this anchor point will no longer be performed. The termination conditions for the end of the current anchor point search include: the current point has been marked as tracked; the current point gradient does not meet the threshold T2 constraint; the search encounters the image boundary.

[0110] Finally, all sub-pixel edge tracking points are sorted to obtain the sub-pixel edge tracking results. During the calculation process, sub-pixel edge points are obtained through sequential tracking. Therefore, unlike traditional edge calculation methods, the points selected in this implementation are sequential and determined by the adjacency relationship between points in the image.

[0111] The method of the present invention is a method for detecting edges in serialized images with sub-pixel accuracy. By using a sub-pixel moment model to extract edges with higher precision and calculating the angle of edge tracking, high-precision image edge tracking is achieved using a well-developed algorithm framework.

[0112] The present invention may use other types of moment models to calculate edge positions and directions during the sub-pixel calculation process.

[0113] Exemplary computing devices of the present invention:

[0114] The device includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, the steps of any method in the specific implementation manner are implemented.

[0115] Exemplary media of the present invention:

[0116] The medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute any method described in any specific embodiment.

[0117] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely illustrative of the principles and applications of the invention. It should be understood that many modifications may be made to the illustrative embodiments, and that other arrangements may be devised, without departing from the spirit and scope of the invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in ways other than those described in the original claims. It should also be understood that features described in conjunction with individual embodiments may be used in conjunction with other described embodiments.

Claims

1. A sub-pixel edge tracking method based on a grayscale moment model, characterized in that: Obtain a grayscale image of the target to be detected, and use the image gradient calculation formula to calculate the gradients of all pixels in the grayscale image to obtain a gradient image; Set the initial gradient threshold according to the maximum and minimum gradient values ​​in the gradient map , the pixel gradient in the grayscale image is greater than the initial gradient threshold The pixel points are used as edge anchor points, and all edge anchor points are stored in the stack; Use the edge anchor point at the beginning of the stack as the search starting point to track the sub-pixel edge of the image: The selected edge anchor point in the grayscale image will be the center The neighborhood of the size of n is used as the sub-pixel calculation area, where n is an odd number greater than 1; the corresponding mask is calculated according to the pixel points of the sub-pixel calculation area; the sub-pixel calculation area and the mask are convolved to obtain the regional image moment value; the sub-pixel distance and angle corresponding to the selected edge anchor point are calculated according to the regional image moment value, and the sub-pixel position corresponding to the currently selected edge anchor point is determined; then, with the currently selected edge anchor point as the center, the next edge tracking point is selected according to the current sub-pixel position and angle among the pixel points in the neighborhood of the currently selected edge anchor point. If the gradient of the edge tracking point is greater than the preset final gradient threshold , then the edge tracking point is used as the next edge anchor point to continue tracking; otherwise, the current tracking is terminated; Continue tracking the edge tracking point of the next edge anchor in the stack until all edge anchor points are traversed and all edge tracking points are obtained; During the tracking process, pixels that have been tracked will not be tracked again; Arrange all edge tracking points as sub-pixel edge tracking results.

2. The sub-pixel edge tracking method based on the grayscale moment model according to claim 1, characterized in that: The pixel gradient is expressed as , including the X-direction gradient and Y-direction gradient : , , , In the formula Represents the X-direction coordinate of the pixel in the grayscale image, Represents the Y coordinate of the pixel in the grayscale image; is the grayscale value.

3. The sub-pixel edge tracking method based on the grayscale moment model according to claim 2, characterized in that: The initial gradient threshold for: , In the formula is the maximum gradient value, is the minimum value of the gradient.

4. The sub-pixel edge tracking method based on the grayscale moment model according to claim 3, characterized in that: The calculation formula of the mask is: , The p-order q-fold mask of the sub-pixel calculation area is used, where p is the order of the mask and q is the number of times the mask is applied.

5. The sub-pixel edge tracking method based on the grayscale moment model according to claim 4, characterized in that: Six masks are obtained based on the pixel points in the sub-pixel calculation area. : in Calculate the 0th order and 0th degree mask of the sub-pixel area; Calculate the 1st order 1st order mask of the sub-pixel area; Calculate the 1st order 0th degree mask of the sub-pixel area; Calculate the 0th order 1st order mask of the sub-pixel area; Calculate the 2nd order 0th degree mask of the sub-pixel area; Computes a 0-order quadratic mask for the sub-pixel region.

6. The sub-pixel edge tracking method based on the grayscale moment model according to claim 5, characterized in that: The sub-pixel angle is expressed as : , In the formula For The corresponding regional image moment value, For The corresponding regional image moment value.

7. The sub-pixel edge tracking method based on the grayscale moment model according to claim 6, characterized in that: The sub-pixel distance is expressed as : , In the formula For The corresponding image moment value of the rotated region, For The corresponding regional image moment value, For The corresponding image moment value of the rotated region, For The corresponding regional image moment value, For The corresponding image moment value of the rotated region; , , 。 8. The sub-pixel edge tracking method based on the grayscale moment model according to claim 7, characterized in that: The sub-pixel position corresponding to the currently selected edge anchor point for: , In the formula is the X-axis coordinate of the currently selected edge anchor point, is the Y-axis coordinate of the currently selected edge anchor point, The size of the region for sub-pixel calculations.

9. The sub-pixel edge tracking method based on the grayscale moment model according to claim 8, characterized in that: Among the pixels in the neighborhood of the currently selected edge anchor point, the method for selecting the next edge tracking point based on the current sub-pixel position and angle is as follows: Select the pixels in the 8-neighborhood of the currently selected edge anchor point, and denote the currently selected edge anchor point as e. The 8-neighborhood pixels of e are a, b, c, d, f, g, h, and i, and a, b, c, d, e, f, g, h, and i form a three-row and three-column matrix. 1) Sub-pixel distance Greater than 0 and :like , then select the next edge tracking point as d; if , then select the next edge tracking point as a; 2) Sub-pixel distance Greater than 0 and :like , then select the next edge tracking point as i; if , then select the next edge tracking point as f; 3) Sub-pixel distance Less than 0 and :like , then select the next edge tracking point as b; if , then select the next edge tracking point as c; 4) Sub-pixel distance Less than 0 and :like , then select the next edge tracking point as h; if , then the next edge tracking point is selected as g.

10. The sub-pixel edge tracking method based on grayscale moment model according to claim 9, characterized in that: Final gradient threshold Set based on experience according to the grayscale image.

11. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 10 are implemented.

12. A medium, characterized in that The medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute any one of the methods of claims 1 to 10.

Citation Information

Patent Citations

  • Improved Zernike moment edge detection method

    CN102637300A

  • Rapid sub pixel edge detection and locating method based on machine vision

    CN104268857A