Ellipse edge detection method based on normal vector constraint

CN120495327BActive Publication Date: 2026-09-15ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510520534.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2026-09-15
Estimated Expiration
2045-04-24

AI Technical Summary

Technical Problem

以上研究使得椭圆检测的效果有所提升,然而仍然面临着非椭圆目标物误检测、椭圆边缘信息不准确以及耗时长的问题

Benefits of technology

[0047] 1) This invention introduces a fan-shaped mask to perform histogram equalization on the local fan-shaped image of the ellipse, which enhances the gradient of the ellipse edge and makes the edge features more prominent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120495327B_ABST
    Figure CN120495327B_ABST
Patent Text Reader

Abstract

The application discloses an ellipse edge detection method based on normal vector constraint. The method comprises the following steps: firstly, using a binocular camera to collect a target image containing an ellipse, segmenting to obtain a rough ellipse image, and performing fan partition and equalization processing to obtain an equalized ellipse local fan image; then, performing normal vector constraint and local non-maximum suppression processing to obtain candidate arc segments; finally, performing error screening to obtain an optimal arc segment set and fitting the optimal arc segment set into an optimal ellipse, and finally detecting the edge of the ellipse. The method introduces a fan mask and performs histogram equalization, enhances the ellipse edge gradient, and makes the edge features more prominent; the local non-maximum suppression is performed according to the normal vector direction, the edge detection accuracy is improved; a higher selection probability is set for a long arc segment, and then the arc segments with overlapping polar angle ranges are removed, so that the arc segment closest to the edge is screened out, the ellipse fitting accuracy is improved, and the ellipse edge is more accurately detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to an ellipse edge detection method, specifically an ellipse edge detection method based on normal vector constraints. Background Technology

[0002] In recent years, ellipse detection has become a key task in fields such as machine vision and pattern recognition, and is crucial for the development of technologies such as camera calibration, pose detection, target segmentation, and iris recognition. However, existing ellipse detection algorithms generally face a series of problems, including the fitted elliptical contour not completely matching the actual contour, false detection of non-elliptical targets, long detection time, and difficulty in meeting real-time requirements.

[0003] Currently, mainstream ellipse detection methods can be divided into three categories: clustering and voting-based methods, optimization-based methods, and edge-connection-based methods. The Hough transform primarily transforms straight lines and curves represented by equations in space into points in a parameter space. In the accumulator space, local peaks are searched through feature voting to determine the ellipse's parameters. However, since the definition of an ellipse requires five parameters, the Hough transform demands significant computational resources and is extremely time-consuming. Edge-connection-based ellipse detection methods extract arc segment information from image edge detection results and then utilize the geometric properties of the ellipse to achieve ellipse detection. Arc segments contain more information than discrete points and better reflect the ellipse's geometry, thus achieving higher accuracy. Optimization-based ellipse detection methods utilize the least squares method, optimizing the objective function based on the input image to ultimately fit the ellipse. These studies have improved the performance of ellipse detection; however, they still face challenges such as false detection of non-elliptical objects, inaccurate ellipse edge information, and long processing times. Summary of the Invention

[0004] To address the problems existing in the background art, the present invention provides an ellipse edge detection method based on normal vector constraints.

[0005] The technical solution adopted in this invention is:

[0006] The ellipse edge detection method based on normal vector constraints of the present invention is characterized by comprising:

[0007] Step 1) Use a binocular camera to acquire a target image containing an ellipse. After segmentation, a coarse ellipse image is obtained. After fan-shaped partitioning and equalization processing of the coarse ellipse image, several equalized ellipse local fan-shaped images are obtained.

[0008] Step 2) After performing normal vector constraints and local nonmaximum suppression on the local sector images of each equalized ellipse, several candidate arc segments are obtained.

[0009] Step 3) After error screening of each candidate arc segment, the optimal arc segment set is obtained and fitted into the optimal ellipse, and finally the edge of the ellipse is detected.

[0010] Step 1) is as follows:

[0011] Step 1.1) After segmenting the target image containing the ellipse using a deep learning-based semantic segmentation method, a coarse ellipse image containing only a single ellipse is obtained. After performing mask dilation and erosion processing on the coarse ellipse image, an ellipse edge ring mask is obtained.

[0012] Step 1.2) Establish a polar coordinate system on the coarse ellipse image, divide the ellipse edge ring mask into n sector masks according to the polar angle, and perform a bitwise AND operation between each sector mask and the coarse ellipse image to obtain n local sector images of the ellipse.

[0013] Step 1.3) After performing histogram equalization on each elliptical local sector image, n equalized elliptical local sector images are obtained.

[0014] Step 2) is as follows:

[0015] Step 2.1) For each equalized elliptical local sector image, obtain the normal vector of each pixel in the equalized elliptical local sector image, and use the Sobel operator to obtain the pixel gradient of each pixel. Perform a dot product of the normal vector and pixel gradient of each pixel and convert it to the range of 0-255 to obtain the gray value of the current pixel.

[0016] Step 2.2) Based on the gray values ​​of each pixel and its eight-connected neighboring pixels, edge extraction is performed using local non-maximum suppression to select several candidate arc segments.

[0017] Step 2.2) is as follows:

[0018] For each pixel, the set of relative coordinates Q of the eight-connected neighboring pixels is obtained as follows:

[0019] Q={(x i -1,y i -1),(x i ,y i -1),(x i +1,y i -1),(x i -1,y i ),

[0020] (x i +1,y i ),(x i -1,y i +1),(xi ,y i +1),(x i +1,y i +1)}

[0021] Where, x i and y i Let x and y represent the x-axis and y-axis coordinates of the i-th pixel in the image coordinate system of the coarse ellipse image, respectively.

[0022] Obtain the set of gray values ​​P for each pixel in the set of relative coordinates Q of the 8-connected neighborhood pixels, where P = {p k |k=1,2,...,8},p k Let Q represent the gray value of the k-th pixel in the set of relative coordinates of the 8-connected neighborhood pixels; then obtain the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the coarse ellipse image.

[0023] The candidate point set S is divided based on the gray value set P of each pixel in the relative coordinate set Q of the 8-connected neighborhood pixels and the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the coarse ellipse image, as follows:

[0024]

[0025] Based on the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the coarse ellipse image, the current pixel is divided into the corresponding candidate point set S. The gray value of the current pixel is compared with the gray values ​​of each candidate point set S. If the gray value of the current pixel is greater than the gray values ​​of each candidate point set S, the gray value of the current pixel is a local maximum and remains unchanged. Otherwise, the gray value of the current pixel is set to zero to remove pixels with too low gray values. Finally, the arc segments formed by the pixels with unchanged gray values ​​are used as candidate arc segments.

[0026] Step 3) is as follows:

[0027] Step 3.1) First, select c candidate arc segments that are longer than the preset length as long arc segments, obtain the average error of each long arc segment to confirm the error constraint, and retain the long arc segments that meet the error constraint as the initial arc segments for preliminary screening.

[0028] Step 3.2) Use the RandomSample Consensus (RANSAC) algorithm based on length constraints to select the optimal set of arc segments for each initial arc segment and fit the optimal ellipse to detect the edge of the ellipse.

[0029] In step 3.1), the average error Err of each long arc segment is... avg as follows:

[0030]

[0031] Among them, Err e d represents the error value of the e-th long arc segment; d represents the total number of pixels in the e-th long arc segment. B x i and B y i Let a and b represent the x-axis and y-axis coordinates of the i-th pixel in the elliptical coordinate system B. The elliptical coordinate system B is established with the minor axis and major axis of the thick ellipse as the x-axis and y-axis, respectively, and the center of the circle as the origin. Let a and b represent the lengths of the major axis and minor axis of the thick ellipse, respectively.

[0032] Based on the average error Err of each long arc segment avg The confirmed error constraints are as follows:

[0033] Err max >Err e >Err min

[0034] Err max =Err avg +Th Err

[0035] Err min =Err avg -Th Err

[0036] Among them, Err max and Err min These represent the upper and lower limits of error, Th, respectively. Err This indicates the error threshold.

[0037] Step 3.2) is as follows:

[0038] Step 3.2.1) For each initial arc segment, first calculate the polar angle of the pixels at the two endpoints of the initial arc segment and obtain the maximum value of the first polar angle θ of the initial arc segment. max and the minimum value of the first polar angle θ min If θ is not satisfied max -θ min If the value is greater than 180, no processing is performed; otherwise, the judgment continues to obtain the polar angle of each pixel in the current initial arc segment, thereby obtaining the maximum value of the second polar angle θ'. max The minimum value of the second polar angle θ' min If θ is not satisfied min >θ' min And θ max <θ' maxIf the initial arc segment is not processed, no processing is performed; otherwise, the initial arc segment is divided into two initial sub-arc segments, and the polar angle θ of each pixel in the first initial sub-arc segment is determined. i Satisfy θ' min <θ i <θ min The polar angle θ of each pixel in the second initial sub-arc segment i Satisfying θ max <θ i <θ' max Each undivided initial arc segment and each initial sub-arc segment are taken as the first arc segment.

[0039] Step 3.2.2) Arrange each first arc segment according to the minimum value of the first polar angle θ. min Sort by size from smallest to largest, if it satisfies Then the j-th and (j+1)-th first arc segments are grouped into the same first arc segment group. and These represent the maximum value of the first polar angle of the j-th first arc segment and the minimum value of the first polar angle of the (j+1)-th first arc segment, respectively. The first arc segment group contains one or more first arc segments.

[0040] Step 3.2.3) Based on the length of each first arc segment in each first arc segment group, use the Random Sample Consensus (RANSAC) algorithm based on length constraints to select several first arc segments. If there are multiple first arc segments belonging to the same first arc segment group among the selected first arc segments, then randomly retain one of the first arc segments. Finally, each selected first arc segment is used as a second arc segment, thereby constructing the second arc segment set R.

[0041] Step 3.2.4) Fit the first ellipse using the second arc segment set R, and calculate the average error Err of each second arc segment relative to the first ellipse. avg The screening error value is greater than the average error Err avg The second arc segment is used to fit the second ellipse, and the same steps as the first ellipse are repeated until the g-th iteration. If the current average error is less than the minimum average error during the g-th iteration, then the currently retained second arc segment is constructed as the optimal arc segment set. Otherwise, the iteration stops after the preset number of iterations, and the currently retained second arc segment is constructed as the optimal arc segment set. Otherwise, steps 2) to 3) are repeated.

[0042] Step 3.2.5) Fit the optimal ellipse based on the optimal arc segment set. The ellipse parameters of the optimal ellipse can be confirmed, including the center coordinates, tilt angle and ab axis. Finally, the edge of the ellipse is detected.

[0043] The electronic device of the present invention includes: a memory and a processor coupled to each other, wherein the memory stores program data, and the processor invokes the program data to execute the method described above.

[0044] The present invention provides a computer-readable storage medium having program data stored thereon, which, when executed by a processor, implements the method described above.

[0045] This invention uses a deep learning-based semantic segmentation method to obtain a coarse ellipse, then cuts the ellipse image into several sectors and performs histogram equalization to enhance edge gradients. The normal vector of the coarse ellipse at each pixel is calculated, and its dot product with the image gradient is taken. Combining this with the ellipse's normal vector information, local non-maximum suppression is performed to obtain candidate arc segments. Preliminary screening is performed based on the arc segment length and its error relative to the coarse ellipse. The RANSAC algorithm based on length constraints is then used to fit the ellipse, obtaining the optimal set of arc segments and the final ellipse parameters, offering advantages of speed and high accuracy.

[0046] The beneficial effects of this invention are:

[0047] 1) This invention introduces a fan-shaped mask to perform histogram equalization on the local fan-shaped image of the ellipse, which enhances the gradient of the ellipse edge and makes the edge features more prominent.

[0048] 2) This invention calculates the dot product of the gradient of each pixel in the elliptical sector image with the elliptical normal vector, and performs local non-maximum suppression based on the direction of the normal vector, thereby improving the accuracy of edge detection.

[0049] 3) This invention uses the RANSAC algorithm based on length constraints to fit the ellipse, sets a higher selection probability for long arc segments, and then removes arc segments with overlapping polar angle ranges from the selected arc segment set, thereby filtering out the arc segments closest to the edge and improving the accuracy of ellipse fitting. Attached Figure Description

[0050] Figure 1 This is a flowchart of the method of the present invention;

[0051] Figure 2 This is a schematic diagram of the sector-shaped mask of the present invention;

[0052] Figure 3 This is a schematic diagram illustrating the calculation of the dot product between the pixel gradient and the ellipse normal vector in this invention.

[0053] Figure 4 This is a schematic diagram of the local nonmaximum suppression of the present invention. Detailed Implementation

[0054] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0055] like Figure 1 As shown, the elliptical edge detection method based on normal vector constraints of the present invention includes:

[0056] Step 1) Use a stereo camera to acquire a target image containing an ellipse. After segmentation, a coarse ellipse image is obtained. After sector partitioning and equalization processing of the coarse ellipse image, several equalized ellipse local sector images are obtained, as follows:

[0057] Step 1.1) After segmenting the target image containing ellipses using a deep learning-based semantic segmentation method, a coarse ellipse image containing only a single ellipse is obtained. After performing mask dilation and erosion processing on the coarse ellipse image, an annular mask of the ellipse edge is obtained. The target image containing ellipses contains one or more ellipses. For example, in a target image containing several sinkholes, the annular region of the inner wall of the sinkhole is the ellipse region. After segmentation, several individual coarse ellipses are obtained, that is, each sinkhole is segmented separately. The deep learning-based semantic segmentation method can specifically use U-Net, DeepLab model, etc., and each coarse ellipse is operated on to detect the ellipse edge.

[0058] Step 1.2) Establish a polar coordinate system on the coarse ellipse image, such as... Figure 2 As shown, the mask is divided according to the polar angle to form n sector masks. That is, the elliptical edge ring mask is divided into n sector masks according to the polar angle. After performing a bitwise AND operation between each sector mask and the coarse elliptical image, n elliptical local sector images are obtained.

[0059] The polar angles of the segmented sector mask are as follows:

[0060]

[0061] Where, θ i x represents the polar angle of the i-th pixel; i and y i Ox and Oy represent the x-axis and y-axis coordinates of the i-th pixel in the image coordinate system of the coarse ellipse image, respectively; Ox and Oy represent the x-axis and y-axis coordinates of the center of the coarse ellipse in the image coordinate system of the coarse ellipse image, respectively.

[0062] The polar angle is 360*(j+1)>θ i Pixels within the range *n>360*j are included in the j-th sector mask.

[0063] Step 1.3) After performing histogram equalization on each elliptical local sector image, n equalized elliptical local sector images are obtained.

[0064] Step 2) After applying normal vector constraints and local nonmaximum suppression to the local sector images of each equalized ellipse, several candidate arc segments are obtained, as follows:

[0065] Step 2.1) For each equalized elliptical local sector image, obtain the normal vector of each pixel in the equalized elliptical local sector image, and use the Sobel operator to obtain the pixel gradient of each pixel, such as... Figure 3 As shown, the grayscale value of the current pixel is obtained by taking the dot product of the normal vector and the pixel gradient of each pixel and converting it to the range of 0-255.

[0066] The calculation of the normal vector of a pixel is as follows:

[0067] First, establish an elliptical coordinate system B with the minor and major axes of the thick ellipse as the x-axis and y-axis, respectively, and the center of the ellipse as the origin. Then, define the coordinate transformation matrix from the elliptical coordinate system B to the image coordinate system A. as follows:

[0068]

[0069] in, This indicates the angle of inclination of the thick ellipse.

[0070] Transform the coordinates of pixel i in image coordinate system A to elliptical coordinate system B as follows:

[0071]

[0072] in, The coordinate transformation matrix represents the transformation from image coordinate system A to elliptical coordinate system B; B x i and B y i Let x and y represent the x-axis and y-axis coordinates of the i-th pixel in the elliptical coordinate system B, respectively. A x i and A y i Let x and y be the coordinates of the i-th pixel in the image coordinate system A, respectively. A Ox and A Oy represents the x-axis and y-axis coordinates of the center of the thick ellipse in the image coordinate system A, respectively.

[0073] Then the slope k of the normal line of the ellipse passing through pixel i i as follows:

[0074]

[0075] Where a and b represent the lengths of the major and minor axes of the thick ellipse, respectively.

[0076] Then the elliptical normal vector of pixel i in elliptical coordinate system B B n i as follows:

[0077]

[0078] The elliptical normal vector in elliptical coordinate system B is transformed to image coordinate system A as follows:

[0079]

[0080] in, A n i Let be the ellipse normal vector of pixel i in image coordinate system A.

[0081] Step 2.2) Based on the grayscale values ​​of each pixel and its eight-connected neighboring pixels, edge extraction is performed using local non-maximum suppression to select several candidate arc segments, as follows:

[0082] For each pixel, the set of relative coordinates Q of the eight-connected neighboring pixels is obtained as follows:

[0083] Q={(x i -1,y i -1),(x i ,y i -1),(x i +1,y i -1),(x i -1,y i ),

[0084] (x i +1,y i ),(x i -1,y i +1),(x i ,y i +1),(x i +1,y i +1)}

[0085] Where, x i and y i Let x and y represent the x-axis and y-axis coordinates of the i-th pixel in the image coordinate system of the coarse ellipse image, respectively.

[0086] Obtain the set of gray values ​​P for each pixel in the set of relative coordinates Q of the 8-connected neighborhood pixels, where P = {p k |k=1,2,...,8},p k Let Q represent the grayscale value of the k-th pixel in the set of relative coordinates of the 8-connected neighborhood pixels; then obtain the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the coarse ellipse image, where α = arctan(k). i )+90.

[0087] The candidate point set S is divided based on the gray value set P of each pixel in the relative coordinate set Q of the 8-connected neighborhood pixels and the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the coarse ellipse image, as follows:

[0088]

[0089] Based on the angle α between the normal of the current pixel and the x-axis of the image coordinate system of the coarse ellipse image, the current pixel is assigned to a corresponding candidate point set S. The gray value of the current pixel is compared with the gray values ​​in the candidate point set S. If the gray value of the current pixel is greater than any of the gray values ​​in the candidate point set S, the gray value of the current pixel is a local maximum and remains unchanged; otherwise, the gray value of the current pixel is set to zero to remove pixels with excessively low gray values. The arc segments formed by the pixels whose gray values ​​remain unchanged are then used as candidate arc segments. Figure 4 As shown.

[0090] Step 3) After error filtering of each candidate arc segment, the optimal arc segment set is obtained and fitted to the optimal ellipse. Finally, the edge of the ellipse is detected, as follows:

[0091] Step 3.1) First, select c candidate arc segments that are longer than a preset length as long arc segments. Obtain the average error of each long arc segment to confirm the error constraint. Retain the long arc segments that meet the error constraint as the initial arc segments for preliminary screening. The average error Err of each long arc segment. avg as follows:

[0092]

[0093] Among them, Err e d represents the error value of the e-th long arc segment; d represents the total number of pixels in the e-th long arc segment. B x i and B y i Let a and b represent the x-axis and y-axis coordinates of the i-th pixel in the elliptical coordinate system B. The elliptical coordinate system B is established with the minor axis and major axis of the thick ellipse as the x-axis and y-axis, respectively, and the center of the circle as the origin. Let a and b represent the lengths of the major axis and minor axis of the thick ellipse, respectively.

[0094] Based on the average error Err of each long arc segment avg The confirmed error constraints are as follows:

[0095] Err max >Err e >Err min

[0096] Err max =Err avg +ThErr

[0097] Err min =Err avg -Th Err

[0098] Among them, Err max and Err min These represent the upper and lower limits of error, Th, respectively. Err This indicates the error threshold.

[0099] Step 3.2) The optimal set of arc segments is selected from each initial arc segment using the RANSAC algorithm based on length constraints, and the optimal ellipse is fitted to detect the edge of the ellipse, as follows:

[0100] Step 3.2.1) For each initial arc segment, first calculate the polar angle of the pixels at the two endpoints of the initial arc segment and obtain the maximum value of the first polar angle θ of the initial arc segment. max and the minimum value of the first polar angle θ min If θ is not satisfied max -θ min If the value is greater than 180, no processing is performed; otherwise, the judgment continues to obtain the polar angle of each pixel in the current initial arc segment, thereby obtaining the maximum value of the second polar angle θ'. max The minimum value of the second polar angle θ' min If θ is not satisfied min >θ' min And θ max <θ' max If the initial arc segment is not processed, no processing is performed; otherwise, the initial arc segment is divided into two initial sub-arc segments, and the polar angle θ of each pixel in the first initial sub-arc segment is determined. i Satisfy θ' min <θ i <θ min The polar angle θ of each pixel in the second initial sub-arc segment i Satisfying θ max <θ i <θ' max Each undivided initial arc segment and each initial sub-arc segment are taken as the first arc segment.

[0101] Step 3.2.2) Arrange each first arc segment according to the minimum value of the first polar angle θ. min Sort by size from smallest to largest, if it satisfies Then the j-th and (j+1)-th first arc segments are grouped into the same first arc segment group. and These represent the maximum value of the first polar angle of the j-th first arc segment and the minimum value of the first polar angle of the (j+1)-th first arc segment, respectively. The first arc segment group contains one or more first arc segments.

[0102] Step 3.2.3) Based on the length of each first arc segment in each first arc segment group, use the Random Sample Consensus (RANSAC) algorithm based on length constraints to select several first arc segments. If there are multiple first arc segments belonging to the same first arc segment group among the selected first arc segments, then randomly retain one of the first arc segments. Finally, each selected first arc segment is used as a second arc segment, thereby constructing the second arc segment set R.

[0103] The length (in pixels) of each first arc segment is denoted as l. j The total length of all arc segments is denoted as l. total In the RANSAC fitting algorithm based on length constraints, the probability p of each first arc segment being selected is... j For p j =l j / l total According to probability p j Select a set of first arc segments. If there are multiple p in the same set... j If an arc segment is selected, one will be randomly retained.

[0104] Step 3.2.4) Fit the first ellipse using the second arc segment set R, and calculate the average error Err of each second arc segment relative to the first ellipse. avg The screening error value is greater than the average error Err avg The second arc segment is used to fit the second ellipse, and the same steps as the first ellipse are repeated until the g-th iteration. If the current average error is less than the minimum average error during the g-th iteration, then the currently retained second arc segment is constructed as the optimal arc segment set. Otherwise, the iteration stops after the preset number of iterations, and the currently retained second arc segment is constructed as the optimal arc segment set. Otherwise, steps 2) to 3) are repeated.

[0105] Step 3.2.5) Fit the optimal ellipse based on the optimal arc segment set. The ellipse parameters of the optimal ellipse can be confirmed, including the center coordinates, tilt angle and ab axis. Finally, the edge of the ellipse is detected.

[0106] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this 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, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented using various computer languages. This application is described with flowcharts of methods, systems, and computer program products according to embodiments of this application.

[0107] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, this invention is intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0108] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if these modifications and variations of this application fall within the scope of the equivalent technology of this invention, this application also intends to include these modifications and variations.

Claims

1. A normal vector constraint based ellipse edge detection method, characterized in that, include: Step 1) Use a binocular camera to acquire a target image containing an ellipse, segment it to obtain a coarse ellipse image, and then perform sector partitioning and equalization processing on the coarse ellipse image to obtain several equalized ellipse local sector images. Step 2) After performing normal vector constraints and local nonmaximum suppression on the local sector images of each equalized ellipse, several candidate arc segments are obtained. Step 3) After error screening of each candidate arc segment, the optimal arc segment set is obtained and fitted into an optimal ellipse, and the edge of the ellipse is finally detected ; Step 3) is as follows: Step 3.1) First, select c candidate arc segments that are longer than the preset length as long arc segments, obtain the average error of each long arc segment to confirm the error constraint, and retain the long arc segments that meet the error constraint as the initial arc segments for preliminary screening. Step 3.2) Use the RANSAC algorithm based on length constraints to select the optimal set of arc segments for each initial arc segment and fit the optimal ellipse to detect the edge of the ellipse.

2. The normal vector constraint based ellipse edge detection method according to claim 1, wherein: Step 1) is as follows: Step 1.1) After segmenting the target image containing the ellipse using a deep learning-based semantic segmentation method, a coarse ellipse image containing only a single ellipse is obtained. After performing mask dilation and erosion processing on the coarse ellipse image, an ellipse edge ring mask is obtained. Step 1.2) Establish a polar coordinate system on the coarse ellipse image, divide the ellipse edge ring mask into n sector masks according to the polar angle, and perform an AND operation between each sector mask and the coarse ellipse image to obtain n ellipse local sector images. Step 1.3) After performing histogram equalization on each elliptical local sector image, n equalized elliptical local sector images are obtained.

3. The normal vector constraint based ellipse edge detection method of claim 1, wherein: Step 2) is as follows: Step 2.1) For each equalized elliptical local sector image, obtain the normal vector of each pixel in the equalized elliptical local sector image, and use the Sobel operator to obtain the pixel gradient of each pixel. Perform a dot product of the normal vector and pixel gradient of each pixel and convert it to the range of 0-255 to obtain the gray value of the current pixel. Step 2.2) Based on the gray values ​​of each pixel and its eight-connected neighboring pixels, edge extraction is performed using local non-maximum suppression to select several candidate arc segments.

4. The ellipse edge detection method based on normal vector constraints according to claim 3, characterized in that: Step 2.2) is as follows: For each pixel, obtain the set of relative coordinates of its eight-connected neighboring pixels. as follows: in, and These represent the x-axis and y-axis coordinates of the i-th pixel in the image coordinate system of the coarse ellipse image, respectively; Obtain the set of relative coordinates of pixels in an 8-connected neighborhood. The set of grayscale values ​​of each pixel in , , Represents the set of relative coordinates of pixels in an 8-connected neighborhood. The grayscale value of the k-th pixel in the image is obtained; then the angle between the normal of the current pixel and the x-axis of the image coordinate system of the coarse ellipse image is obtained. ; Based on the set of relative coordinates of the eight-connected neighbor pixels The set of grayscale values ​​of each pixel in The angle between the normal of the current pixel and the x-axis of the image coordinate system of the thick ellipse. Divide the candidate point set as follows: Based on the angle between the normal of the current pixel and the x-axis of the image coordinate system of the coarse ellipse image. Assign the current pixel to the corresponding candidate point set. And combine the grayscale value of the current pixel with the candidate point set The gray values ​​of the current pixel are compared with those of the candidate pixel set. If the grayscale value of a pixel is determined by the given values, then the grayscale value of the current pixel is the local maximum and remains unchanged. Otherwise, the grayscale value of the current pixel is set to zero. Finally, the arc segments formed by the pixels whose grayscale values ​​remain unchanged are used as candidate arc segments.

5. The ellipse edge detection method based on normal vector constraints according to claim 1, characterized in that: In step 3.1), the average error of each long arc segment as follows: in, This represents the error value of the e-th long arc segment; This represents the total number of pixels in the e-th long arc segment; and These represent the positions of the i-th pixel in the elliptical coordinate system. x-axis and y-axis coordinates on an elliptical coordinate system Let the minor axis and major axis of the thick ellipse be respectively shaft and The axis is established with the center of the circle as the origin. and These represent the lengths of the major and minor axes of the thick ellipse, respectively. Based on the average error of each long arc segment The confirmed error constraints are as follows: in, and These represent the upper and lower limits of the error, respectively. This indicates the error threshold.

6. The ellipse edge detection method based on normal vector constraints according to claim 1, characterized in that: Step 3.2) is as follows: Step 3.2.1) For each initial arc segment, first calculate the polar angle of the pixels at the two endpoints of the initial arc segment and obtain the maximum value of the first polar angle of the initial arc segment. and the minimum value of the first polar angle If not satisfied If the result is positive, no processing is performed; otherwise, the judgment continues to obtain the polar angle of each pixel in the current initial arc segment, thereby obtaining the maximum value of the second polar angle. Minimum value of the second polar angle If not satisfied and If the initial arc segment is not processed, no processing is performed; otherwise, the initial arc segment is divided into two initial sub-arc segments, and the polar angle of each pixel in the first initial sub-arc segment is determined. satisfy The polar angle of each pixel in the second initial sub-arc segment satisfy Each undivided initial arc segment and each initial sub-arc segment are taken as the first arc segment; Step 3.2.2) Arrange each first arc segment according to the minimum value of the first polar angle. Sort by size from smallest to largest, if it satisfies Then the first The and the first Each first arc segment is divided into the same group of first arc segments. and They represent the first The maximum value of the first polar angle of the first arc segment and the first... The minimum value of the first polar angle of the first arc segment; the group of first arc segments contains one or more first arc segments. Step 3.2.3) Based on the length of each first arc segment in each first arc segment group, use the Random Sample Consensus (RANSAC) algorithm based on length constraints to select several first arc segments. If there are multiple first arc segments belonging to the same first arc segment group among the selected first arc segments, then randomly retain one of the first arc segments. Finally, each selected first arc segment is used as a second arc segment, thereby constructing the second arc segment set R. Step 3.2.4) Fit the first ellipse using the second arc segment set R, and calculate the average error of each second arc segment relative to the first ellipse. The screening error value is greater than the average error value. The second arc segment is used to fit the second ellipse, and the same steps as the first ellipse are repeated until the g-th iteration. If the current average error is less than the minimum average error during the g-th iteration, the currently retained second arc segment is constructed as the optimal arc segment set. Otherwise, the iteration is stopped after the preset number of iterations, and the currently retained second arc segment is constructed as the optimal arc segment set. Step 3.2.5) Fit the optimal ellipse based on the optimal arc segment set, and finally detect the edge of the ellipse.

7. An electronic device, characterized in that, include: A memory and a processor are coupled to each other, wherein the memory stores program data, and the processor invokes the program data to perform the method as described in any one of claims 1-6.

8. A computer-readable storage medium storing program data thereon, characterized in that, When the program data is executed by the processor, it implements the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Tooth-shaped structure assembling and measuring method based on monocular vision

    CN113405451A

  • Binocular recognition visual detection method for intelligent manufacturing production line

    CN117764983A