Sub-pixel edge tracking method and device based on gray moment model and medium
The sub-pixel edge tracking method based on the gray moment model solves the problem of low detection accuracy in traditional methods, realizes sub-pixel edge tracking, and improves the accuracy of industrial vision detection and the accuracy of edge direction selection.
Patent Information
- Application Number
- CN202410784916.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-06-18
AI Technical Summary
Traditional image edge tracking methods rely on pixel-level edges, which makes it difficult to achieve sub-pixel-level detection accuracy and cannot meet the technical requirements of high-precision detection occasions.
The sub-pixel edge tracking method based on the gray moment model is used to filter edge anchor points by calculating the image gradient and setting the initial gradient threshold. The sub-pixel calculation area and mask are used to calculate the distance and angle of the edge to optimize the edge tracking direction selection.
It improves the accuracy of edge tracking to sub-pixel level, improves the accuracy of edge tracking in industrial visual inspection, and achieves more detailed edge direction selection.
Smart Images

Figure CN118674741A
Abstract
Description
Technical Field
[0001] The invention relates to a sub-pixel edge tracking method, equipment 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 detection technology. 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 detection occasions. Summary of the invention
[0003] In view of 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 sub-pixel edge tracking method based on the grayscale moment model of the present invention 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] The initial gradient threshold T1 is set according to the maximum and minimum values of the gradient in the gradient map, and the pixel points in the grayscale map whose gradient is greater than the initial gradient threshold T1 are used as edge anchor points, and all edge anchor points are stored in the stack;
[0006] Use the edge anchor point at the head 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 obtained according to the pixel points of 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 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 in the pixel points in the neighborhood of the currently selected edge anchor point, and 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 to continue 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 pixel points are not 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-order 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 used.
[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 order mask of the sub-pixel calculation area; M 11 M is the first-order, first-order mask of the sub-pixel calculation area; 10 The 1st order 0th order mask of the sub-pixel calculation area; M 01 M is the 0th order 1st mask of the sub-pixel calculation area; 20 The 2nd order 0th order mask of the sub-pixel calculation area; M 02 Computes a 0-order quadratic mask for the subpixel 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 of selecting the next edge tracking point in the pixel points 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 pixel points in the 8-neighborhood of the currently selected edge anchor point, and denote the currently selected edge anchor point as e. The 8-neighborhood pixel points 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, wherein the medium stores computer executable instructions, and 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 level edge tracking accuracy, which is beneficial to the development of industrial detection technology.
[0045] The method of the present invention first calculates the gradient of the image to obtain the gradient map, and then sets the threshold to filter out the edge tracking anchor point. Based on the anchor point, the image is traversed, and the 5*5 neighborhood area of the pixel is selected as the sub-pixel fitting area. The model coefficient is calculated using the mask, the sub-pixel edge position is estimated using the sub-pixel position formula, and the sequence tracking point is selected using the sub-pixel edge tracking angle. Compared with the prior art, the present invention can improve the detection accuracy to the sub-pixel level, and optimize the selection of edge tracking direction using the angle of the grayscale moment model. The method of the present invention improves the 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 origin of the coordinates;
[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 be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. 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 creative work are 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 in conjunction with 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 a grayscale moment model, 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;
[0057] The initial gradient threshold T1 is set according to the maximum and minimum values of the gradient in the gradient map, and the pixel points in the grayscale map whose gradient is greater than the initial gradient threshold T1 are used as edge anchor points, and all edge anchor points are stored in the stack;
[0058] Use the edge anchor point at the head 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 a sub-pixel calculation area, where n is an odd number greater than 1; a corresponding mask is obtained according to the pixel points of 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 according to 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 according to the current sub-pixel position and angle among the pixel points in the neighborhood of the currently selected edge anchor point, and 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 an 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 pixel points are not 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 is acquired by using a color camera and a grayscale image is obtained by weighted averaging pixels of the RGB three channels.
[0064] In this embodiment, the pixel gradient is represented by G, which refers to the change of the 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] In the gradient calculation of this embodiment, multiple pixels in a 3*3 neighborhood are used to calculate the gradient value. When calculating the gradient in the X direction, in addition to using the grayscale value in the X direction, the gradient change value in the Y direction is also weighted. A similar method is also used to calculate the gradient in the Y direction. Compared with the gradient calculation method that only uses one direction, this method uses more neighborhood pixel information and can better reflect the grayscale transformation of the image.
[0070] In this implementation, points whose gradient values are greater than a threshold value T1 are screened out according to 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 for anchor point search. A zero matrix Z (all matrix elements are 0) with the same size as the grayscale image is constructed, and the gradient map is traversed row by row and column by column. If the gradient value of the (x, y) point is greater than the threshold T1, it is recorded as the search edge anchor point, and the pixel at the corresponding position in the Z matrix is recorded 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 coordinates of the edge anchor point are (x0, y0), two pixels above, below, left and right are taken as the sub-pixel calculation area with the anchor point as the center. The area range is 5*5, and the area is taken as the candidate area.
[0076] The edge anchor point reflects the point with the strongest edge feature in the image, and the gradient is the prominent feature of the edge. The point with the largest gradient in the image is set as the anchor point to reflect the edge feature in the image. The highest and lowest gradients of the image are used in the calculation of the threshold, and the point greater than the threshold is set as the gradient anchor point.
[0077] Take the anchor point at the beginning of the stack as the starting point for the search. The anchor points are the edge salient 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 will process them one by one. The first one to be selected is the anchor point at the beginning of the stack. The order of the anchor points in the stack is determined by the order in which they are stored.
[0078] like Figure 2 As shown, the sub-pixel calculation area range is 5*5, and the image sub-pixel candidate area is obtained by selecting an area of fixed length with the edge anchor point as the center. 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 neighborhood where the pixel is located, and a larger area requires a large amount of calculation, and will introduce a greater model deviation for sub-pixel calculation. Based on experience and comprehensive analysis of sub-pixel point features, this implementation method 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 The p-order q-order 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. f(x,y) is an image function, which represents the grayscale value. When calculating the moment model, the image function is considered to be a constant 1 at each pixel.
[0082] In this embodiment, combined with Figure 2 As shown in the figure, the candidate region is convolved with the mask to calculate the image moments of different orders of the candidate region. The six masks calculated based on the pixel points 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 order mask of the sub-pixel calculation area; M 11 M is the first-order, first-order mask of the sub-pixel calculation area; 10 The 1st order 0th order mask of the sub-pixel calculation area; M01 M is the 0th order 1st mask of the sub-pixel calculation area; 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 implementation 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 by the image moment according to the formula.
[0099] Going a step further, combined Figures 3 to 7 As shown in FIG. 1 , among the pixels in the neighborhood of the currently selected edge anchor point, the method for selecting the next edge tracking point according to the current sub-pixel position and angle is as follows:
[0100] Select the pixel points in the 8-neighborhood of the currently selected edge anchor point, select the next edge tracking point according to the direction of the pixel gradient, denote the currently selected edge anchor point as e, then the 8-neighborhood pixel points of e are a, b, c, d, f, g, h, i, and a, b, c, d, e, f, g, h, i form a three-row and three-column matrix. 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 the neighborhood shall not exceed 8. You can choose 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 of the 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, select the next point from the anchor point image and continue searching repeatedly until all anchor points are searched.
[0108] In the edge tracking problem, the selection of tracking direction is the core issue. This implementation uses image moments to calculate the tracking direction of sub-pixel edges, and selects the next point based on the edge angle of each sub-pixel 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, which improves edge accuracy while completing edge direction determination, reducing the amount of calculation.
[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 sub-pixel edge tracking results. In the calculation process, sub-pixel edge points are obtained by sequential tracking calculation. Therefore, unlike the traditional edge calculation method, the points selected in this embodiment are sequential and determined by the adjacency relationship between the points in the image.
[0111] The method of the present invention is a method for detecting the edge of a serialized image with sub-pixel accuracy. It uses a sub-pixel moment model to extract higher-precision edges, obtains the angle of edge tracking through calculation, and uses a good algorithm framework to achieve high-precision image edge tracking.
[0112] The present invention can 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 executable 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 implementation manner.
[0117] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of the present invention. It should therefore be understood that many modifications may be made to the exemplary embodiments and that other arrangements may be devised without departing from the spirit and scope of the present invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in a manner different from that described in the original claims. It should also be understood that the features described in conjunction with a single embodiment may be used in 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; The initial gradient threshold T1 is set according to the maximum and minimum values of the gradient in the gradient map, and the pixel points in the grayscale map whose gradient is greater than the initial gradient threshold T1 are used as edge anchor points, and all edge anchor points are stored in the stack; Use the edge anchor point at the head of the stack as the search starting point to track the sub-pixel edge of the image: 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 obtained according to the pixel points of 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 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, and 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, end the current tracking; 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 pixels that have been tracked will not be tracked repeatedly; 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 represented by G, including the X-direction gradient G x and the Y-direction gradient G y : 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), 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), 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.
3. The sub-pixel edge tracking method based on grayscale moment model according to claim 2, characterized in that: The initial gradient threshold T1 is: T1=T_max-0.2(T_max-T_min), Where T_max is the maximum gradient value and T_min is the minimum gradient value.
4. The sub-pixel edge tracking method based on grayscale moment model according to claim 3, characterized in that: The calculation formula of the mask is: M pq =∫∫x p and q f(x,y)dxdy, M pq The p-order q-order 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 used.
5. The sub-pixel edge tracking method based on grayscale moment model according to claim 4, characterized in that: Six masks M are obtained based on the pixel points in the sub-pixel calculation area. 00 ,M 11 ,M 10 ,M 01 ,M 20 ,M 02 : Among them, M 00 The 0th order and 0th order mask of the sub-pixel calculation area; M 11 Calculate the 1st order and 1st order mask of the sub-pixel area; M 10 The 1st order 0th order mask of the sub-pixel calculation area; M 01 Calculate the 0th order 1st order mask of the sub-pixel 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 subpixel region.
6. The sub-pixel edge tracking method based on grayscale moment model according to claim 5, characterized in that: The sub-pixel angle is denoted as θ: Where m pq For M pq The corresponding regional image moment value.
7. The sub-pixel edge tracking method based on grayscale moment model according to claim 6, characterized in that: The sub-pixel distance is denoted as l: Where m′ pq For m pq The corresponding image moment value of the rotated region; m′ 00 =m 00 , 8. The sub-pixel edge tracking method based on grayscale moment model according to claim 7, characterized in that: The sub-pixel position (x, y) corresponding to the currently selected edge anchor point is: 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.
9. The sub-pixel edge tracking method based on 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: Select the pixel points in the 8-neighborhood of the currently selected edge anchor point, and denote the currently selected edge anchor point as e. The 8-neighborhood pixel points 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) 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; 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; 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; 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.
10. The sub-pixel edge tracking method based on grayscale moment model according to claim 9, characterized in that: The final gradient threshold T2 is set empirically based on 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, characterized in that: 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
A sub-pixel edge detection method and system
CN109741356A
Device and method for obtaining distance information from views
WO2018072858A1
Cited By
Infrared image edge detection method based on three-dimensional laser point cloud data guidance
CN119648728A
