An Ellipse Detection Method and System Based on the Edge of Anisotropic Structure
By adopting anisotropic Gaussian direction derivative and adaptive ellipse verification methods in the ellipse detection technology, the problems of low detection efficiency and low accuracy in the prior art are solved, and more efficient and accurate ellipse detection is achieved.
Patent Information
- Application Number
- CN202410134055.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-31
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2044-01-31
AI Technical Summary
The existing ellipse detection technology has low detection efficiency and low accuracy, and it is difficult to effectively distinguish structural edges and texture edges, resulting in high missed detection and false detection rates.
The ellipse detection method based on anisotropic structural edges is used to calculate the grayscale changes in multiple directions through the anisotropic Gaussian direction derivative, and the structural gradient map and structural edge map are extracted to reduce the impact of non-structural edges, and false positive results are eliminated through anisotropic adaptive ellipse verification.
The recall and accuracy of ellipse detection are improved, the computational complexity and false positive occurrence rate are reduced, and more efficient and accurate ellipse detection is achieved.
Smart Images

Figure CN117994224B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of ellipse detection, and in particular to an ellipse detection method and system based on anisotropic structural edges. Background Art
[0002] Early ellipse detection algorithms were usually based on the Hough transform method. The basic idea of this algorithm is to represent an ellipse as a point in a five-dimensional parameter space. For each possible ellipse, the algorithm increases the corresponding count in the parameter space, and finally selects the point with the highest count as the detected ellipse. Due to the use of a five-dimensional parameter space, the Hough transform method has extremely high computational complexity and requires a large amount of computing resources. Subsequently, ellipse detection algorithms based on image edges were developed. This method first extracts the edge map of the image, then extracts several smooth elliptical arc segments from the edge map, and then combines the arc segments according to certain geometric rules (combining the arc segments that may come from the same ellipse), and then uses the least squares method to fit each combination to obtain the ellipse parameters. Compared with the Hough transform method, the time complexity of this type of method has been greatly reduced, so it is more widely used.
[0003] Existing ellipse detection algorithms based on image edges usually include the following Figure 1 steps as shown:
[0004] (1) Edge extraction: Edge extraction usually uses Canny edge detection, and then extracts non-bifurcating edges from the edge map through a depth-first algorithm.
[0005] (2) Elliptical arc segment extraction: Disconnect the non-bifurcating edge from inflection points and corner points to obtain several smooth elliptical arc segments, as Figure 2 shown. Figure 2 is a non-bifurcating edge, where C 5 is an inflection point because the rotation direction of the coordinate points reverses from this point (i.e., the included angles α 5 and α 4 have opposite rotation directions), C 9 is a corner point because the included angle α 9 is too large. Disconnect the non-bifurcating edge along these two points to obtain three smooth elliptical arc segments (C 1 -C 2 -C 3 -C 4 -C 5 、C 5 -C 6 -C 7 -C 8 -C 9 、C 9 -C 10 -C 11 -C 12 ).
[0006] (3)Combined elliptical arc segments: Next, the arc segments are combined. If two arc segments come from the same ellipse, they should satisfy the following rule: Connect the endpoints 1, midpoints, and endpoints 2 of the two arc segments in sequence, and the resulting figure should be a convex hexagon, as Figure 3 shown. Figure 3 is an arc segment combination, including two elliptical arc segments Connect their endpoints and midpoints to obtain a convex hexagon, as shown by the dashed line.
[0007] (4)Ellipse fitting: For each arc segment combination, perform least squares fitting on all the coordinate points therein to obtain a candidate ellipse. Its expression is Ax 2 +Bxy+Cy 2 +Dx+Ey+F = 0, where x and y are the abscissa and ordinate of each coordinate point, and A, B, C, D, E, F are the target parameters to be fitted by the least squares method. Finally, transform the expression into where x c is the abscissa of the center point, y c is the ordinate of the center point, a is the length of the major axis, b is the length of the minor axis, and α is the rotation angle of the major axis.
[0008] (5)Ellipse verification: Finally, verify the candidate ellipse, calculate the ratio S of the circumference covered by the image edge. If S is greater than a preset threshold τ, output the candidate ellipse and then perform the fitting of the next arc segment combination. Otherwise, directly perform the fitting of the next arc segment combination. Repeat steps (3 - 5) until all arc segment combinations are fitted and verified.
[0009] The characteristics of the existing anisotropic edge extraction method are to replace the Sobel gradient operator in Canny edge detection with the anisotropic Gaussian directional derivative. First, convolve the input image with multiple Gaussian directional derivative convolution kernels, calculate the intensity of the gray - level change of each pixel in the image along each direction, take the direction with the largest change as the gradient direction, and the corresponding change intensity as the gradient intensity; then perform non - maximum suppression and double - threshold screening on the gradient map to obtain a binary edge map, that is, the edge detection result. Its process is as Figure 4 shown. Figure 4 The left - hand column in Figure 4 represents several main stages of edge detection,
[0010] In summary, the existing ellipse detection technologies have the following disadvantages:
[0011] Disadvantage 1: The detection quality of the ellipse detection algorithm based on image edges highly depends on the quality of the edge map. However, there is currently no edge detection algorithm proposed specifically for ellipse detection. The existing ellipse detection algorithms based on image edges usually use the Canny operator to extract image edges. Since the Canny operator preprocesses the image using isotropic Gaussian filtering, it is very easy to destroy the continuity of the image edges, splitting a complete elliptical arc segment into several small line segments. On the one hand, it will increase the time for combining arc segments, and on the other hand, it will affect the accuracy of ellipse fitting, resulting in a large number of missed detections and false detections.
[0012] Disadvantage 2: The Canny operator does not distinguish between texture and structural edges, while the ellipses to be detected in the image are mostly the contours of the main structures of the target objects, and the texture information is almost redundant. Therefore, the extracted texture edges only increase the meaningless detection time and at the same time interfere with the detection of the target ellipse, affecting the detection accuracy.
[0013] Disadvantage 3: The existing methods do not distinguish whether the detected ellipses come from real edges or noise edges, and use the same method to verify all candidate results, resulting in a large number of false positive ellipses (usually small ellipses) fitted from noise edges being retained in the final output detection results, further reducing the precision. Summary of the Invention
[0014] To this end, the embodiments of the present invention provide an ellipse detection method and system based on anisotropic structural edges to solve the problems of low detection efficiency and low precision in the existing ellipse detection methods in the prior art.
[0015] To solve the above problems, the embodiments of the present invention provide an ellipse detection method based on anisotropic structural edges, and the method includes:
[0016] Step S1: Input a digital image, calculate the gray-scale changes in multiple directions using anisotropic Gaussian directional derivatives, select the direction with the largest change intensity in a specific area as the gradient direction, and the corresponding change intensity as the gradient intensity, and calculate the gradient map of the image;
[0017] Step S2: Calculate the anisotropic structure descriptor, and combine the gradient map and the anisotropic structure descriptor to calculate the structure gradient map of the image;
[0018] Step S3: Calculate the structure edge map of the image based on the structure gradient map;
[0019] Step S4: Extract elliptical arc segments from the structure edge map, combine and fit the elliptical arc segments to generate candidate ellipses;
[0020] Step S5: Use anisotropic adaptive ellipse to verify the candidate ellipse and output the ellipse detection result.
[0021] Preferably, in step S1, use anisotropic Gaussian directional derivative to calculate the gray-scale changes in multiple directions, select the direction with the largest change intensity in a specific area as the gradient direction, and the corresponding change intensity as the gradient intensity, and calculate the gradient map of the image, specifically including:
[0022] Step S11: Use anisotropic Gaussian directional derivative to calculate the gradient direction g θ (x):
[0023]
[0024] where
[0025]
[0026]
[0027]
[0028] In the formula, is the gray-scale change intensity; x is the pixel point; θ is the angle between the image and the x-axis direction; G(x, θ; σ, ρ) is the anisotropic Gaussian directional derivative; σ is to control the smoothness; ρ is the anisotropic factor; R is the rotation matrix; is the function to find the parameters of the function;
[0029] Step S12: Calculate the gradient intensity g m (x):
[0030]
[0031] Step S13: Calculate the vector representation of the gradient at x
[0032]
[0033] Preferably, in step S2, the method for calculating the anisotropic structure descriptor is:
[0034]
[0035] where
[0036]
[0037]
[0038]
[0039] Wherein, x and y are pixel points; D(x) is an anisotropic structure descriptor; N(x) is an anisotropic window centered on x; D 1 (x) is the weighted average of the moduli of the gradients of each pixel within the window; D 2 (x) is the modulus of the weighted average of the gradient vectors of each pixel within the window; W(x) is the sum of the weights within the anisotropic structure descriptor window; ξ controls the size of the actual influence area within the window; φ is an anisotropic factor; ε is an extremely small amount greater than 0; R is a rotation matrix; g θ (x) is the gradient direction at x.
[0040] Preferably, in step S2, the method for calculating the structure gradient map of the image by combining the gradient map and the anisotropic structure descriptor is as follows:
[0041]
[0042] Wherein, represents the structure gradient map; D(x) is the anisotropic structure descriptor; is the vector representation of the gradient at x.
[0043] Preferably, in step S3, the method for calculating the structure edge map of the image based on the structure gradient map is as follows:
[0044] Based on the structure gradient map, non-maximum suppression and double-threshold screening are used to obtain a binary structure edge map.
[0045] Preferably, in step S4, the method for extracting elliptical arc segments from the structure edge map, combining and fitting the elliptical arc segments to generate a candidate ellipse is as follows:
[0046] First, all non-bifurcating edges are extracted from the structure edge map using depth-first search, and the non-bifurcating edges are disconnected at the corner points and inflection points to obtain several smooth elliptical arc segments; then, all arc segments that meet the arc segment combination conditions are combined in pairs and least squares fitting is performed to obtain a candidate ellipse, whose expression is Ax 2 +Bxy+Cy 2 +Dx+Ey+F = 0, where x and y are the abscissa and ordinate of each coordinate point, and A, B, C, D, E, F are the target parameters to be fitted by the least squares method. Finally, the expression is transformed into where x c is the abscissa of the center point, y c is the ordinate of the center point, a is the length of the major axis, b is the length of the minor axis, and α is the rotation angle of the major axis.
[0047] Preferably, in step S5, an anisotropic adaptive ellipse is used to verify the candidate ellipse, and an ellipse detection result is output, specifically including:
[0048] Step S51: Denote a candidate ellipse as E(x c ,y c ,a,b,α), where (x c ,y c ) are the center coordinates, a and b are the lengths of the major and minor semi-axes respectively, and α is the rotation angle of the major semi-axis relative to the x-axis. Uniformly select M sampling points from E. The calculation method of the i-th sampling point P i (x i ,y i ) is:
[0049]
[0050] In the formula, θ i =2πi / M;
[0051] Step S52: Obtain the normal vector n i at the sampling point P i on the candidate ellipse:
[0052] n i =R(π / 2-α)(-a sin θ i ,b cos θ i ) T
[0053] In the formula, R is the rotation matrix;
[0054] Step S53: Calculate the anisotropic verification score S i of the sampling point P i :
[0055]
[0056] In the formula, represents the structure gradient map; S i calculates the product of the similarity between the ellipse normal and the image edge normal at the sampling point P i and the structure gradient intensity. When there is a structure edge at the sampling point P i and its direction is consistent with the ellipse, S i reaches the maximum value;
[0057] Step S54: Calculate the score S of the candidate ellipse E. If and only if the score S is greater than the verification threshold τ, the ellipse candidate E will be retained in the detection result; otherwise, the candidate ellipse E will be removed. The score S of the candidate ellipse E is the average of the anisotropic scores of each sampling point, that is
[0058]
[0059] Preferably, the calculation method of the verification threshold τ is as follows:
[0060]
[0061] In the formula, τ 0 is a basic threshold; W and H are the width and height of the input image respectively; is the relative size of the candidate ellipse E and the input image; β is a scaling factor; tanh is the hyperbolic tangent function.
[0062] An embodiment of the present invention also provides an ellipse detection system based on an anisotropic structure edge, which is used to implement the above-mentioned ellipse detection method based on an anisotropic structure edge, and specifically includes:
[0063] A gradient map calculation module, which is used to input a digital image, calculate the gray-scale changes in multiple directions using anisotropic Gaussian directional derivatives, select the direction with the largest change intensity in a specific area as the gradient direction, and the corresponding change intensity as the gradient intensity, and calculate the gradient map of the image;
[0064] A structure gradient map calculation module, which is used to calculate the anisotropic structure descriptor, and combine the gradient map and the anisotropic structure descriptor to calculate the structure gradient map of the image;
[0065] A structure edge map calculation module, which is used to calculate the structure edge map of the image based on the structure gradient map;
[0066] A candidate ellipse generation module, which is used to extract elliptical arc segments from the structure edge map, combine and fit the elliptical arc segments to generate candidate ellipses;
[0067] A detection module, which is used to verify the candidate ellipse using anisotropic adaptive ellipses and output the ellipse detection result.
[0068] An embodiment of the present invention also provides a computer storage medium, which stores a computer software product. The computer software product includes several instructions for causing a computer device to execute the above-mentioned ellipse detection method based on an anisotropic structure edge.
[0069] From the above technical solutions, it can be seen that the present invention application has the following advantages:
[0070] (1) The present invention uses anisotropic Gaussian directional derivatives to calculate the gray-scale changes in multiple directions, selects the direction with the largest change intensity within a specific region as the gradient direction, and the corresponding change intensity as the gradient intensity. Compared with existing gradient operators (such as Sobel operator, Prewitt operator, Laplacian operator, etc.), it is more sensitive to structural edges, can effectively reduce the missed detection rate of structural edges, ensure the continuity of the detected structural edges, and thus can extract more complete elliptical arc segments, improving the recall rate of ellipse detection.
[0071] (2) The image gradient information reflects the change intensity and change direction of the gray-scale values of each pixel in the image. Existing gradient operators only consider the gray-scale changes in the x and y directions during the calculation process. Since digital images are discrete signals, the gradient direction and gradient intensity obtained by such a calculation method are not accurate. The present invention considers the changes in multiple directions, and the calculation method is more in line with the definition of image gradient, obtaining more accurate gradient information, and thus can more accurately locate the elliptical edges.
[0072] (3) The present invention proposes an anisotropic structure descriptor to describe each edge pixel, which can eliminate the gradient information of non-structural edges to reduce the invalid edges used for ellipse detection, reducing the computational complexity while effectively reducing the occurrence of false positives. In addition, the present invention also proposes an anisotropic adaptive ellipse verification to more accurately eliminate false positive detection results, further reducing the influence of noise edges and improving the precision rate.
[0073] (4) The present invention has the characteristics of high precision rate, high recall rate, and low time complexity compared with existing ellipse detection methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly describe the drawings required in the embodiments. By referring to the drawings, the features and advantages of the present invention will be more clearly understood. The drawings are schematic and should not be construed as any limitation to the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts. Among them:
[0075] Figure 1 is the flowchart of the existing ellipse detection algorithm based on image edges in the background technology;
[0076] Figure 2 is the schematic diagram of the elliptical arc segment extracted in the background technology;
[0077] Figure 3 is the schematic diagram of the combined elliptical arc segments in the background technology;
[0078] Figure 4Flow chart of existing anisotropic edge detection methods in the background art;
[0079] Figure 5 Flow chart of an ellipse detection method based on anisotropic structure edges provided in the embodiment;
[0080] Figure 6 Brief flow chart of an ellipse detection method based on anisotropic structure edges provided in the embodiment;
[0081] Figure 7 Comparison chart of the edge detection effect of the present invention and existing edge detection technologies in the embodiment;
[0082] Figure 8 Comparison chart of the detection effect of the present invention and existing ellipse detection technologies in the embodiment;
[0083] Figure 9 Block diagram of an ellipse detection system based on anisotropic structure edges provided in the embodiment. Detailed implementation manners
[0084] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of protection of the present invention.
[0085] Embodiment 1
[0086] As shown in Figure 5 、 Figure 6 , an ellipse detection method based on anisotropic structure edges is proposed in the embodiment of the present invention, and the method includes:
[0087] Step S1: Input a digital image, calculate the gray-scale changes in multiple directions using anisotropic Gaussian directional derivatives, select the direction with the largest change intensity in a specific area as the gradient direction, and the corresponding change intensity as the gradient intensity, and calculate the gradient map of the image;
[0088] Step S2: Calculate the anisotropic structure descriptor, and combine the gradient map and the anisotropic structure descriptor to calculate the structure gradient map of the image;
[0089] Step S3: Calculate the structure edge map of the image based on the structure gradient map;
[0090] Step S4: Extract elliptical arc segments from the structure edge map, combine and fit the elliptical arc segments to generate candidate ellipses;
[0091] Step S5: Use anisotropic adaptive ellipse to verify the candidate ellipse and output the ellipse detection result.
[0092] As can be seen from the above technical solution, the present invention proposes an ellipse detection method based on anisotropic structural edges. First, by using anisotropic Gaussian directional derivatives to calculate the gray-scale changes in multiple directions, the direction with the largest change intensity in a specific region is selected as the gradient direction, and the corresponding change intensity is used as the gradient intensity. Compared with the existing gradient operators (such as Sobel operator, Prewitt operator, Laplacian operator, etc.), it is more sensitive to structural edges, can effectively reduce the missed detection rate of structural edges, ensure the continuity of the detected structural edges, and thus can extract more complete elliptical arcs and improve the recall rate of ellipse detection. Second, an anisotropic structure descriptor is proposed to describe each edge pixel, which can eliminate the gradient information of non-structural edges to reduce the invalid edges used for ellipse detection, effectively reducing the false positives while reducing the computational complexity. In addition, the present invention also proposes an anisotropic adaptive ellipse verification to more accurately eliminate false positive detection results, further reducing the influence of noise edges and improving the precision. The present invention has the characteristics of high precision, high recall rate, and low time complexity compared with the existing ellipse detection technologies.
[0093] The input of the present invention is a digital image (any common image format such as jpg, bmp, png, etc.), and the output is the parameters of the ellipses existing in the image (center coordinates, major and minor axes, rotation angle).
[0094] In this embodiment, in step S1, a digital image is input, and the anisotropic Gaussian directional derivative is used to calculate the gray-scale changes in multiple directions. The direction with the largest change intensity in a specific region is selected as the gradient direction, and the corresponding change intensity is used as the gradient intensity to calculate the gradient map of the image, which specifically includes:
[0095] Step S11: Use the anisotropic Gaussian directional derivative to calculate the gradient direction g θ (x):
[0096]
[0097] where
[0098]
[0099]
[0100]
[0101] In the formula, is the intensity of gray-scale change; x is the pixel point; θ is the angle between the image and the x-axis direction; G(x, θ; σ, ρ) is the anisotropic Gaussian directional derivative, which is equivalent to calculating the magnitude of the gray-scale change along the θ direction after Gaussian smoothing of the area around x; σ controls the degree of smoothing (σ > 0); ρ is the anisotropic factor, which stretches the smoothed area along the direction perpendicular to θ (ρ > 1); R is the rotation matrix; is a function for finding the parameters of a function.
[0102] Step S12: Calculate the gradient intensity g m (x):
[0103]
[0104] Step S13: Calculate the vector representation of the gradient at x
[0105]
[0106] In this embodiment, 8 anisotropic Gaussian directional derivative convolution kernels are set, σ is set to 3, ρ is set to 2, and the rotation angle of the k-th kernel is kπ / 8, denoted as θ k , then the k-th kernel is G(x, θ k ; 3, 2); the gradient direction at pixel x is The gradient intensity is Obtain the gradient vector
[0107] In this embodiment, in step S2, an anisotropic structure descriptor is calculated, and by combining the gradient map and the anisotropic structure descriptor, the structure gradient map of the image is calculated.
[0108] Specifically, since non-structural edges (such as texture and noise edges) are usually redundant for ellipse detection, non-structural edge extraction should be avoided as much as possible in the edge extraction stage. A major feature of such edges is that their gradient changes rapidly, and adjacent pixels are likely to have different gradient directions, while structural edges are usually smoother with slower gradient changes, and adjacent pixels on structural edges usually have similar gradient intensities and gradient directions.
[0109] According to the above characteristics, the present invention discloses a structure descriptor D(x) for describing whether pixel x is more likely to belong to a structural edge or a non-structural edge. If x belongs to a structural edge, D(x) will obtain a larger value, and vice versa, D(x) will obtain a smaller value. The calculation method is as follows:
[0110]
[0111] where
[0112]
[0113]
[0114]
[0115] Wherein, x and y are pixel points; D(x) is an anisotropic structure descriptor; N(x) is an anisotropic window centered at x; D 1 (x) is the weighted average of the norms of the gradients of each pixel within this window; D 2 (x) is the norm of the weighted average of the gradient vectors of each pixel within this window; W(x) is the sum of the weights within the anisotropic structure descriptor window; ξ controls the size of the actual influence region within this window, and the larger the value of ξ, the larger the influence region. φ is an anisotropic factor used to make the influence region fit the edge direction as closely as possible; φ is an anisotropic factor used to make the influence region fit the edge direction as closely as possible; ε is an extremely small amount greater than 0 used to prevent the denominator from being 0; R is a rotation matrix; g θ (x) is the gradient direction at x.
[0116] Finally, by combining the gradient map and the anisotropic structure descriptor, a structure gradient map can be obtained, denoted as
[0117]
[0118] Wherein, represents the structure gradient map; D(x) is the anisotropic structure descriptor; is the vector representation of the gradient at x.
[0119] In this embodiment, the window N(x) can be set as a square window with a size of 21×21 centered at x; ξ is set to 3, φ is set to 2, which is consistent with the variance and anisotropic factor of the anisotropic directional derivative in gradient calculation, and ε can be set to 0.001.
[0120] In this embodiment, in step S3, based on the structure gradient map, using non-maximum suppression and double-threshold screening in the Canny edge operator, from the structure gradient map a binary structure edge map is extracted.
[0121] In this embodiment, in step S4, using an existing ellipse detection algorithm based on image edges (AAMED, an ellipse detection method based on the arc segment adjacency matrix), ellipse arc segments are extracted from the structure edge map, and the ellipse arc segments are combined and fitted to generate candidate ellipses, specifically including:
[0122] First, use depth - first search to extract all non - bifurcated edges from the structural edge map. Disconnect the non - bifurcated edges at the corner points and inflection points to obtain several smooth elliptical arc segments, as shown in Figure 2 ; then combine all the arc segments that meet the requirements ( Figure 3 shown in) in pairs, and use the least - squares method to fit an ellipse for each pair. Its expression is ax 2 + Bxy + Cy 2 + Dx + Ey + F = 0, where x and y are the abscissa and ordinate of each coordinate point, and A, B, C, D, E, F are the target parameters to be fitted by the least - squares method. Finally, transform the expression into where x c is the abscissa of the center point, y c is the ordinate of the center point, a is the length of the major semi - axis, b is the length of the minor semi - axis, and α is the rotation angle of the major semi - axis. Temporarily save the fitted ellipse into the candidate ellipse set.
[0123] In this embodiment, in step S5, use anisotropic adaptive ellipse to verify the candidate ellipses and output the ellipse detection result, which specifically includes:
[0124] Step S51: Denote a candidate ellipse as E(x c , y c , a, b, α), where (x c , y c ) is the center coordinate, a and b are the lengths of the major and minor semi - axes respectively, and α is the rotation angle of the major semi - axis relative to the x - axis. Uniformly select M sampling points from E. The calculation method of the i - th sampling point P i (x i , y i ) is:
[0125]
[0126] In the formula, θ i = 2πi / M.
[0127] Step S52: Calculate the normal vector n i at the sampling point P i on the candidate ellipse:
[0128] n i = R(π / 2 - α)(-a sin θ i , b cos θ i ) T
[0129] In the formula, R is the rotation matrix.
[0130] Step S53: Calculate the anisotropic verification score S i of the sampling point P i :
[0131]
[0132] In the formula, represents the structural gradient map; S i calculates the product of the similarity between the elliptical normal and the image edge normal at the sampling point P i and the structural gradient intensity. When there is a structural edge at the sampling point P i and its direction is consistent with the ellipse, S i reaches the maximum value.
[0133] Step S54: Calculate the score S of the candidate ellipse E. If and only if the score S is greater than the verification threshold τ, the elliptical candidate E will be retained in the detection result; otherwise, the candidate ellipse E will be removed. The score S of the candidate ellipse E is the average of the anisotropic scores of each sampling point, that is
[0134]
[0135] Since the ellipses fitted by structural edges have a higher score and those fitted by non-structural edges have a lower score, this verification score calculation strategy can effectively remove the ellipses fitted by non-structural edges.
[0136] Furthermore, the hyperbolic tangent function is used to calculate the verification threshold of the candidate ellipse. When the candidate ellipse is very small, it will be constrained by the high threshold τ to exclude as many small ellipses fitted by noise edges as possible. As the size of the candidate ellipse increases, τ will quickly decrease to be close to τ 0 to prevent the missed detection of large ellipses, while maintaining a high recall rate while significantly improving the precision.
[0137] The formula for calculating the verification threshold of the elliptical candidate E is:
[0138]
[0139] In the formula, τ 0 is a base threshold; W and H are the width and height of the input image respectively; is the relative size of the candidate ellipse E and the input image; β is a scaling coefficient; tanh is the hyperbolic tangent function.
[0140] In this embodiment, for each candidate ellipse E, M sampling points are uniformly selected from the candidate ellipse E. M is set to 360. When the perimeter of the candidate ellipse E is less than 360, then M is changed to the perimeter. Calculate the anisotropic verification scores of each sampling point, and then obtain the total verification score S of the candidate ellipse E. Set β to 10, τ 0Set it to 0.6, calculate the adaptive verification threshold τ of the candidate ellipse E, and determine whether S > τ holds. If so, output the candidate ellipse E to the result set; otherwise, remove the candidate ellipse E.
[0141] In summary, compared with the existing ellipse detection technologies, the present invention has the characteristics of high precision, high recall rate, and low time complexity. Table 1 below compares the performance of the present invention with 8 existing technologies on 5 public data sets.
[0142] Table 1
[0143]
[0144] Among them, the detection effects of the present invention and the existing ellipse detection technologies on 5 public data sets (the first column) are compared. The evaluation indicators include precision rate (the first row of each data set), recall rate (the second row), and F-score (the third row). The best results are shown in bold, and the last row is the average of each indicator on the 5 data sets.
[0145] Figure 7 It is a comparison chart of the edge detection effect of the present invention and the existing edge detection technologies. Among them Figure 7 in (a) is the input image; Figure 7 in (b) is the gradient map calculated by the existing anisotropic method; Figure 7 in (c) is the gradient map calculated by the present invention; Figure 7 in (d) is the edge map of the Canny operator; Figure 7 in (e) is the edge map of the existing anisotropic method; Figure 7 in (f) is the edge map of the present invention.
[0146] Figure 8 It is a comparison chart of the detection effect of the present invention and the existing ellipse detection technologies. Among them, Input is the input image, Ground truth is the ellipse that should be detected, the 3rd - 6th columns are the detection results of 4 existing technologies, and the last column is the detection result of the present invention.
[0147] Embodiment 2
[0148] As Figure 9 shown, the present invention provides an ellipse detection system based on an anisotropic structure edge. This system is used to implement the ellipse detection method based on an anisotropic structure edge in the above Embodiment 1, and specifically includes:
[0149] A gradient map calculation module 10, which is used to input a digital image, calculate the gray-scale changes in multiple directions using the anisotropic Gaussian directional derivative, select the direction with the largest change intensity in a specific area as the gradient direction, and the corresponding change intensity as the gradient intensity, and calculate the gradient map of the image;
[0150] The structural gradient map calculation module 20 is configured to calculate anisotropic structure descriptors, and combine the gradient map and the anisotropic structure descriptors to calculate the structural gradient map of the image;
[0151] The structural edge map calculation module 30 is configured to calculate the structural edge map of the image based on the structural gradient map;
[0152] The candidate ellipse generation module 40 is configured to extract elliptical arc segments from the structural edge map, combine and fit the elliptical arc segments to generate candidate ellipses;
[0153] The detection module 50 is configured to verify the candidate ellipses using anisotropic adaptive ellipses and output ellipse detection results.
[0154] An ellipse detection system based on anisotropic structural edges in this embodiment is used to implement the foregoing ellipse detection method based on anisotropic structural edges. Therefore, the specific implementation manners in the ellipse detection system based on anisotropic structural edges can be seen in the embodiment part of the foregoing ellipse detection method based on anisotropic structural edges. For example, the gradient map calculation module 10, the structural gradient map calculation module 20, the structural edge map calculation module 30, the candidate ellipse generation module 40, and the detection module 50 are respectively configured to implement steps S1, S2, S3, S4, and S5 in the foregoing ellipse detection method based on anisotropic structural edges. Therefore, the specific implementation manners can refer to the descriptions of the corresponding individual embodiment parts. To avoid redundancy, they will not be elaborated here.
[0155] Embodiment III
[0156] The embodiment of the present invention also provides a computer storage medium. The computer storage medium stores a computer software product. The computer software product includes several instructions for causing a computer device to execute the foregoing ellipse detection method based on anisotropic structural edges.
[0157] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0158] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing device generate means for realizing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for realizing the functions specified in multiple blocks.
[0159] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that realize the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for realizing the functions specified in multiple blocks. These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for realizing the functions specified in multiple blocks.
[0160] Obviously, the above embodiments are merely examples for clear illustration and are not limitations on the implementation manners. For those of ordinary skill in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to enumerate all implementation manners here. And the obvious changes or modifications derived therefrom are still within the protection scope of the present invention.
Claims
1. An ellipse detection method based on anisotropic structure edge, characterized in that: include: Step S1: Input a digital image, use anisotropic Gaussian directional derivatives to calculate the grayscale changes in multiple directions, select the direction with the largest change intensity in a specific area as the gradient direction, and the corresponding change intensity as the gradient intensity, and calculate the gradient map of the image, specifically including: Step S11: Calculate the gradient direction g at x using anisotropic Gaussian directional derivatives θ (x): in In the formula, is the intensity of grayscale change; x is the pixel point; θ is the angle between the image and the x-axis; G(x,θ; σ,ρ) is the anisotropic Gaussian directional derivative; σ is the control smoothness; ρ is the anisotropy factor; R is the rotation matrix; A function that finds parameters for a function; Step S12: Calculate the gradient strength g at x m (x): Step S13: Calculate the vector representation of the gradient at x Step S2: calculating an anisotropic structure descriptor, combining the gradient map and the anisotropic structure descriptor, and calculating a structure gradient map of the image; Step S3: Based on the structural gradient map, a structural edge map of the image is calculated; Step S4: extracting elliptical arc segments from the structural edge graph, combining and fitting the elliptical arc segments to generate candidate ellipses; Step S5: Use anisotropic adaptive ellipses to verify the candidate ellipses and output ellipse detection results.
2. The ellipse detection method based on anisotropic structure edge according to claim 1, characterized in that: In step S2, the method for calculating the anisotropic structure descriptor is: in Where x and y are pixel points; D(x) is an anisotropic structural descriptor; N(x) is an anisotropic window centered on x; D1(x) is the weighted average of the modulus of the gradient of each pixel in the window; D2(x) is the modulus of the weighted average of the gradient vector of each pixel in the window; W(x) is the sum of the weights in the anisotropic structural descriptor window; ξ is the size of the actual influence area in the window; φ is the anisotropic factor; ε is a very small number greater than 0; R is the rotation matrix; g θ (x) is the gradient direction at x.
3. The ellipse detection method based on anisotropic structure edge according to claim 1, characterized in that: In step S2, the method of calculating the structural gradient map of the image by combining the gradient map and the anisotropic structural descriptor is as follows: In the formula, represents the structural gradient map; D(x) is the anisotropic structural descriptor; is the vector representation of the gradient at x.
4. The ellipse detection method based on anisotropic structure edge according to claim 1, characterized in that: In step S3, based on the structural gradient map, a method for calculating a structural edge map of the image is as follows: Based on the structural gradient map, non-maximum suppression and double threshold screening are used to obtain a binary structural edge map.
5. The ellipse detection method based on anisotropic structure edge according to claim 1, characterized in that: In step S4, elliptical arc segments are extracted from the structural edge graph, and the elliptical arc segments are combined and fitted to generate candidate ellipses in the following method: First, all non-bifurcation edges are extracted from the structural edge graph using depth-first search, and the non-bifurcation edges are disconnected from the corners and inflection points to obtain several smooth elliptical arc segments; then all arc segments that meet the arc segment combination conditions are combined in pairs and fitted by the least squares method to obtain a candidate ellipse, whose expression is Ax 2 +Bxy+Cy 2 +Dx+Ey+F=0, where x and y are the horizontal and vertical coordinates of each coordinate point, A, B, C, D, E, and F are the target parameters to be fitted by the least squares method, and finally the expression is transformed into where x c is the horizontal coordinate of the center point, y c is the ordinate of the center point, a is the length of the major axis, b is the length of the minor axis, and α is the rotation angle of the major axis relative to the x-axis.
6. The ellipse detection method based on anisotropic structure edge according to claim 1, characterized in that: In step S5, the candidate ellipse is verified using an anisotropic adaptive ellipse, and an ellipse detection result is output, which specifically includes: Step S51: record a candidate ellipse as E(x c ,y c ,a,b,α), where (x c ,y c ) is the center coordinate, a and b are the lengths of the major and minor semi-axes respectively, α is the rotation angle of the major semi-axis relative to the x-axis, M sampling points are uniformly selected from E, and the i-th sampling point P i (x i ,y i ) is calculated as: In the formula, θ i =2πi / M; Step S52: Find the sampling point P on the candidate ellipse i The normal vector n at i : n i =R(π / 2-α)(-a sinθ i ,b cos θ i ) T Where R is the rotation matrix; Step S53: Calculate sampling point P i Anisotropy verification score S i : In the formula, Represents the structural gradient map; S i The calculation is the sampling point P i The product of the similarity between the ellipse normal and the image edge normal and the structural gradient strength, when the sampling point P i When there is a structural edge at and its direction is consistent with the ellipse, S i Reach the maximum value; Step S54: Calculate the score S of the candidate ellipse E. If and only if the score S is greater than the verification threshold τ, the ellipse candidate E will be retained in the detection result. Otherwise, the candidate ellipse E will be removed. The score S of the candidate ellipse E is the average of the anisotropy scores of each sampling point, that is, 7. The ellipse detection method based on anisotropic structure edge according to claim 6, characterized in that: The calculation method of the verification threshold τ is: Where τ0 is a basic threshold; W and H are the width and height of the input image respectively; is the relative size of the candidate ellipse E and the input image; β is the scaling factor; tanh is the hyperbolic tangent function.
8. An ellipse detection system based on anisotropic structure edge, characterized in that: The system is used to implement the ellipse detection method based on anisotropic structure edge according to any one of claims 1 to 7, and specifically includes: The gradient map calculation module is used to input a digital image, use anisotropic Gaussian directional derivatives to calculate the grayscale changes in multiple directions, select the direction with the largest change intensity in a specific area as the gradient direction, and the corresponding change intensity as the gradient intensity, and calculate the gradient map of the image; A structural gradient map calculation module is used to calculate an anisotropic structural descriptor, and combine the gradient map and the anisotropic structural descriptor to calculate the structural gradient map of the image; A structural edge map calculation module, used for calculating a structural edge map of an image based on the structural gradient map; A candidate ellipse generation module is used to extract ellipse arc segments from the structural edge map, combine and fit the ellipse arc segments, and generate a candidate ellipse; The detection module is used to verify the candidate ellipse using an anisotropic adaptive ellipse and output an ellipse detection result.
9. A computer storage medium, characterized in that The computer storage medium stores a computer software product, and the computer software product includes several instructions for enabling a computer device to execute the ellipse detection method based on anisotropic structure edges as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Object shooting image ellipse detection algorithm based on Marklaurin theorem constraint
CN113962967A