Image ellipse detection method and system based on contrast guidance
By introducing contrast-guided enhancement algorithm and adaptive thresholds into the ellipse detection algorithm, the problems of poor arc segment continuity, consistent calculation methods for different arc segment search domains and fixed ellipse verification thresholds are solved, and more efficient and more accurate ellipse detection is achieved.
Patent Information
- Application Number
- CN202410134050.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-31
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-01-31
AI Technical Summary
In the existing ellipse detection algorithm, the arc segment has poor continuity, resulting in a decrease in detection efficiency and accuracy; the arc segments with different contrast ratios use the same search domain calculation method, which reduces the algorithm efficiency; a fixed filter threshold is used in ellipse verification, resulting in the incorrect deletion of non-significant ellipse.
The continuity of arc segments is enhanced by contrast-guided enhancement algorithms, introducing contrast information to calculate the search domain of each arc segment, and using adaptive thresholds to remove candidate ellipses with low confidence in ellipse verification.
It improves the efficiency and accuracy of ellipse detection, reduces false alarms, and improves the accuracy of detection results.
Smart Images

Figure CN117994223B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image ellipse detection, and in particular to an image ellipse detection method and system based on contrast guidance. Background Art
[0002] Image ellipse detection is a technology that detects all elliptical objects in an image through a pattern recognition algorithm. It can detect single or multiple elliptical objects contained in an image. This technology can be used in many fields, such as cell recognition, pose estimation, camera calibration, and virtual reality technology. In these fields, the accuracy of ellipse detection in images is crucial.
[0003] At present, there are three main methods in the research of image ellipse detection, namely, the method based on Hough transform, machine learning and edge connection. The method based on Hough transform is to map the edge points in the image to the 5D parameter space of the ellipse (c x ,c y ,a,b,θ), where (c x ,c y ) represents the coordinates of the center point of the ellipse, (a, b) represents the length of the major and minor axes of the ellipse respectively, and θ represents the rotation angle of the major axis of the ellipse relative to the x-axis. And find the extreme point in the parameter space, and the extreme point in the parameter space is represented as an elliptical target in the image space. This method is simple in technology, but has high computational complexity and low accuracy, and is not suitable for scenes with high accuracy and real-time requirements. The machine learning-based method uses deep learning technology to give the network model the ability to detect elliptical targets in the image. However, this method is highly dependent on the training data set. At present, it is mainly used in specific elliptical target detection tasks (such as faces, fruits, and cells). Due to its poor versatility, it cannot detect multi-category elliptical targets in the input image. In contrast, edge connection-based methods have become the main research direction of image ellipse detection in recent years due to their good versatility, high detection accuracy and low computational complexity. Generally speaking, edge connection-based methods first extract edge points in the input image and connect adjacent edge points to form elliptical arc segments. These arc segments are then paired and combined with each other to find arc segments belonging to the same ellipse, and then the required ellipse detection results are calculated based on the combined arc segment group.
[0004] like Figure 1As shown in Figure 1, a typical edge-connected ellipse detection method mainly includes the following five steps: (1) edge extraction; (2) arc generation; (3) arc combination; (4) ellipse fitting and (5) ellipse verification. Existing methods for improving ellipse detection all focus on improving the latter three steps. However, the quality of arc generation directly affects all subsequent steps and thus affects the final detection results. For example, existing algorithms will combine multiple fragmented arcs in a broken arc for multiple times, which will not only affect the final detection results, but also reduce the detection efficiency.
[0005] Common edge connection-based algorithms include Prasad, CNED, Lu, AAMED, and CMED. Among them, Prasad proposed a regional search method for arc segment combination, which takes into account the geometric information of the ellipse and can effectively combine arc segments. Specifically, for an arc segment A (formed by connecting adjacent edge points in the image, where the edge points are usually extracted using the Canny algorithm), its search domain is determined by the tangent line on the first and last points of the arc segment and the line connecting the first and last points. Figure 2 As shown in s and p e are the start and end points of arc segment A, respectively, and R is the search domain of arc segment A. Because most ellipses in an image may be blocked, if only one arc segment is used to fit the ellipse, the accuracy will be reduced. Therefore, it is necessary to combine arc segments that may belong to the same ellipse to generate a better ellipse. If two arc segments are within each other's search domain, then the two arc segments can be combined into an arc segment group, and then this arc segment combination is used to generate an ellipse candidate. Figure 3 As shown in , arc segment A and arc segment B can form an arc segment group, while arc segment A and arc segment C cannot be combined because arc segment A is not in the search domain of arc segment C.
[0006] In summary, existing edge connection-based algorithms have the following disadvantages:
[0007] Disadvantage 1: The existing edge connection-based algorithms directly connect the edge points extracted from the image to generate arc segments. Since the extraction of edge points is easily affected by image discretization and noise, the arc segments in the existing algorithms often have fragmentation problems. If such severely fragmented arc segments are directly combined to generate ellipses, the number of arc segment combinations will increase, thus affecting the detection efficiency and reducing the detection accuracy.
[0008] Disadvantage 2: Existing edge connection-based algorithms determine the search domain only based on the geometric characteristics of the arc segments. In this way, significant arc segments (i.e. arc segments with strong contrast in the image) and insignificant arc segments will have the same search domain range, which will greatly increase the operating efficiency of the algorithm and generate many false detections.
[0009] Disadvantage 3: The existing edge connection-based algorithms only verify the ellipse based on the distribution of ellipse edge points around the candidate ellipse without considering the significance of the ellipse. Therefore, it is easy to filter out insignificant ellipses incorrectly. Summary of the invention
[0010] To this end, an embodiment of the present invention provides an image ellipse detection method and system based on contrast guidance, which is used to solve the following existing technologies: the arc segments used by the existing ellipse detection algorithm have the problem of poor continuity, which will lead to a decrease in the efficiency and detection accuracy of the detection algorithm; the existing ellipse detection algorithm uses the same search domain calculation method for arc segments with different contrasts, which will greatly reduce the efficiency of the algorithm; the existing ellipse detection algorithm uses a fixed screening threshold to remove low-confidence candidate ellipses in ellipse verification, which will cause non-significant ellipses to be easily deleted by mistake.
[0011] In order to solve the above problem, an embodiment of the present invention provides an image ellipse detection method based on contrast guidance, the method comprising:
[0012] Step S1: Input an RGB image, convert the RGB image into a grayscale image, extract edge points based on the grayscale image, and calculate the gradient amplitude and horizontal angle of each pixel;
[0013] Step S2: Starting from the edge point with the largest current gradient amplitude, adjacent edge points in the image are connected to form multiple edge point sets, and multiple end-to-end connected straight line segments, i.e., the required arc segments, are fitted for each edge point set;
[0014] Step S3: Calculate the result of contrast diffusion for each arc segment respectively, and fuse the arc segments that intersect after diffusion to form an enhanced arc segment;
[0015] Step S4: Calculate the search domain of each arc segment according to the diffused arc segment contrast, combine two arc segments that are both within each other's search domain, and fit the candidate ellipse parameters;
[0016] Step S5: Calculate the confidence of each candidate ellipse based on the density and uniformity of the edge points, remove the candidate ellipses with low confidence by using an adaptive threshold based on image contrast, and output the final ellipse detection result.
[0017] Preferably, in step S1, the method of extracting edge points according to the grayscale image and calculating the gradient amplitude and horizontal angle of each pixel point is:
[0018] The Canny operator is used to extract edge points, and the Sobel operator is used to calculate the gradient amplitude and horizontal angle of each pixel in the grayscale image.
[0019] Preferably, in step S2, a plurality of end-to-end connected straight line segments, i.e., required arc segments, are fitted for each edge point set, specifically including:
[0020] A polygonal approximation algorithm is used to fit multiple end-to-end connected straight line segments for each edge point set. In order to prevent the connected edge point set from bifurcation, the straight line segments are disconnected at the turning point according to the angle between the two preceding and following straight line segments. The multiple non-crossed straight line segment groups fitted by each edge point set are the required arc segments.
[0021] Preferably, in step S3, the result of contrast diffusion of each arc segment is calculated respectively, and the arc segments that have intersections after diffusion are merged to form enhanced arc segments, which specifically includes:
[0022] For each arc segment, the contrast of the edge points extracted by Canny on the arc segment is filtered by Gaussian kernel, and the edge points are re-identified according to formula (1) for the filtered result, and the enhanced arc segment is generated based on the re-identified edge points; for the edge pixel extracted by the Canny operator, if there are less than 3 newly identified edge points in its 8-connected neighbors, it is re-considered as a non-edge point; if the two arc segments after diffusion have an intersecting part, the two arc segments are merged into one arc segment; where formula (1) is:
[0023]
[0024] Where x is a non-edge pixel around the edge pixel, g m (x) represents the gradient strength at point x, g o (x) represents the horizontal angle at point x, e represents the edge point closest to x, where τ g and τ o are two preset thresholds.
[0025] Preferably, in step S4, the search domain of each arc segment is calculated according to the diffused arc segment contrast, two arc segments within each other's search domain are combined, and candidate ellipse parameters are fitted, which specifically includes:
[0026] The search domain of each arc segment is calculated according to the contrast of the diffused arc segment, and the search domain is determined based on the contrast of the arc segment and its geometric features. First, a range is determined based on the reverse extension line of the first and last line segments of the arc segment and the line connecting the first and last endpoints. Then, according to formula (2), the reverse extension line of the first and last segments is rotated toward the arc segment by a certain angle to expand the original search domain. When two arc segments meet the combination condition, the combination condition is that the two arc segments are located in each other's search area, a candidate ellipse is fitted by least squares based on all edge points on the two arc segments. Formula (2) is:
[0027]
[0028] In the formula, |A| represents the number of edge points contained in arc segment A, g m (x) represents the gradient strength at point x.
[0029] Preferably, in step S5, the confidence of each candidate ellipse is calculated based on the density and uniformity of the edge points, and the candidate ellipses with low confidence are removed by an adaptive threshold based on image contrast, and the final detection result is output, which specifically includes:
[0030] Step S51: For a candidate ellipse E, extract edge pixels whose normal distance of its contour is less than 2, and express the extracted S edge point set as
[0031] Step S52: The density index of the ellipse E is defined as:
[0032]
[0033] In the formula, is the perimeter of the candidate ellipse E;
[0034] Step S53: Divide the candidate ellipse E into 360 accumulator bins in the polar coordinate system {B k}, where the kth accumulator bin B k Corresponding to the angular ranges ((k-1)°, k°] of k=1, 2, ..., 360 respectively, the number of bins having at least one ellipse edge pixel based on the accumulator bins increases as:
[0035]
[0036] Where δ(·) is the Dirac delta function, Yes i Normal vector of vertical projection on candidate ellipse E; According to this formula, calculate the uniformity index U of candidate ellipse E:
[0037]
[0038] Where H(·) represents the Heaviside step function;
[0039] Step S54: Based on the density and uniformity index of edge pixels, the confidence of the candidate ellipse E is calculated by the following formula:
[0040]
[0041] Where α is the weighting factor, which is preset to 0.4;
[0042] Step S55: Set the confidence level higher than τ v The candidate ellipse E is taken as the final ellipse detection result, where τ v is an adaptive threshold based on image contrast.
[0043] Preferably, the adaptive threshold τ based on image contrast v It is expressed as:
[0044]
[0045] Among them, g m (E) represents the average contrast of the edge points on the candidate ellipse E, g max Indicates the maximum contrast value in the input image.
[0046] The embodiment of the present invention further provides an image ellipse detection system based on contrast guidance, which is used to implement the above-mentioned image ellipse detection method based on contrast guidance, and specifically includes:
[0047] The edge extraction module is used to input an RGB image, convert the RGB image into a grayscale image, extract edge points based on the grayscale image, and calculate the gradient amplitude and horizontal angle of each pixel point;
[0048] The arc segment extraction module is used to connect adjacent edge points in the image to form multiple edge point sets starting from the edge point with the largest current gradient amplitude, and fit multiple end-to-end connected straight line segments, i.e., the required arc segments, for each edge point set;
[0049] The arc segment enhancement module is used to calculate the result of contrast diffusion for each arc segment and fuse the arc segments that intersect after diffusion to form an enhanced arc segment.
[0050] An arc segment combination module is used to calculate the search domain of each arc segment according to the arc segment contrast after diffusion, combine two arc segments that are both within each other's search domain, and fit the candidate ellipse parameters;
[0051] The ellipse verification module is used to calculate the confidence of each candidate ellipse based on the density and uniformity of the edge points, remove low-confidence ellipses through an adaptive threshold based on image contrast, and output the final ellipse detection result.
[0052] An embodiment of the present invention also provides an electronic device, which includes a processor, a memory and a bus system, wherein the processor and the memory are connected through the bus system, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to implement the above-mentioned contrast-guided image ellipse detection method.
[0053] An embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium stores a computer software product, wherein the computer software product includes several instructions for enabling a computer device to execute the above-mentioned image ellipse detection method based on contrast guidance.
[0054] It can be seen from the above technical solutions that the present invention has the following beneficial effects:
[0055] (1) The present invention improves the continuity of arc segments through a contrast-guided enhancement algorithm, thereby improving the efficiency and accuracy of ellipse detection.
[0056] (2) The present invention improves detection efficiency by introducing contrast information into the arc segment combination to calculate the search domain of each arc segment.
[0057] (3) The present invention correctly verifies the quality of candidate ellipses by introducing contrast information into ellipse verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the implementation cases of the present invention or the technical solutions in the prior art, the following is a brief description of the drawings required for use 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 understood as limiting the present invention in any way. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0059] Figure 1 is a flow chart of an existing ellipse detection method in the background technology;
[0060] Figure 2 Schematic diagram of the search domain of arc segment A in the background technology;
[0061] Figure 3 It is a schematic diagram of an arc segment group in the background technology;
[0062] Figure 4 It is a flow chart of a method for detecting an image ellipse based on contrast guidance provided in an embodiment;
[0063] Figure 5 This is a visualization diagram of the arc segment search domain in the embodiment;
[0064] Figure 6 It is a threshold setting diagram in the embodiment;
[0065] Figure 7 A visualization diagram of edge-guided arc segment diffusion in an embodiment;
[0066] Figure 8 This is a subjective observation and evaluation diagram in the embodiment;
[0067] Fig. 9 It is a block diagram of an image ellipse detection system based on contrast guidance provided in an embodiment. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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.
[0069] Embodiment 1
[0070] like Figure 4 As shown, an embodiment of the present invention proposes an image ellipse detection method based on contrast guidance, the method comprising:
[0071] Step S1: Input an RGB image, convert the RGB image into a grayscale image, extract edge points based on the grayscale image, and calculate the gradient amplitude and horizontal angle of each pixel;
[0072] Step S2: Starting from the edge point with the largest current gradient amplitude, adjacent edge points in the image are connected to form multiple edge point sets, and multiple end-to-end connected straight line segments, i.e., the required arc segments, are fitted for each edge point set;
[0073] Step S3: Calculate the result of contrast diffusion for each arc segment respectively, and fuse the arc segments that intersect after diffusion to form an enhanced arc segment;
[0074] Step S4: Calculate the search domain of each arc segment according to the diffused arc segment contrast, combine two arc segments that are both within each other's search domain, and fit the candidate ellipse parameters;
[0075] Step S5: Calculate the confidence of each candidate ellipse based on the density and uniformity of the edge points, remove the candidate ellipses with low confidence by using an adaptive threshold based on image contrast, and output the final ellipse detection result.
[0076] From the above technical scheme, it can be known that the present invention is a method for detecting an image ellipse based on contrast guidance, first converting an RGB image into a grayscale image, extracting edge points according to the grayscale image and calculating the gradient amplitude and horizontal direction angle of each pixel point; secondly, connecting adjacent edge points in the image to form multiple edge point sets, fitting multiple end-to-end straight line segments, i.e., the required arc segments, to each edge point set; then enhancing the arc segments extracted from the image based on the image contrast of the upper edge points to improve the continuity of the arc segments, thereby improving the efficiency and accuracy of ellipse detection; then introducing contrast information in the arc segment combination to calculate the search domain of each arc segment to improve the detection efficiency; finally, introducing contrast information in the ellipse verification process to correctly verify the quality of the candidate ellipse. The present invention improves the detection efficiency and detection accuracy.
[0077] In this embodiment, in step S1, an RGB image is input, the RGB image is converted into a grayscale image, edge points are extracted according to the grayscale image, and the gradient amplitude and horizontal direction angle of each pixel are calculated.
[0078] Specifically, given an input RGB image Where H and W represent the length and width of the input image respectively. First, use the rbg2gray() function in MATLAB to convert it to grayscale. If the input image itself is a grayscale image, this step is not required. The Sobel operator is used to calculate the gradient magnitude and horizontal angle direction of each pixel in I. Here, the horizontal angle direction of the pixel is the direction of the gradient direction at that point rotated 90° counterclockwise. The Canny operator is used to extract edge points. Here, the filter window is set to 5×5 and the Gaussian kernel variance is set to 0.6.
[0079] In this embodiment, in step S2, starting from the edge point with the largest current gradient amplitude, adjacent edge points in the image are connected to form multiple edge point sets, and multiple end-to-end connected straight line segments, i.e., the required arc segments, are fitted for each edge point set.
[0080] Specifically, starting from the edge point with the largest gradient amplitude, add this point and its adjacent (within the 8-neighborhood) edge points to the same set. Whenever a new edge point is added, the edge points adjacent to the newly added point will be searched. When no new edge points can be added to the current set, a new set is generated starting from the point with the largest gradient among the remaining edge points. Directly calculating the tangents of the first and last endpoints of an arc segment is very complicated and the accuracy is not high. Here, a polygonal approximation algorithm (Douglas-Poiker algorithm) is used to fit multiple end-to-end connected straight line segments for each edge point set. In order to prevent the connected edge point set from bifurcation, it is disconnected at the inflection point according to the angle between the two previous and next straight line segments. The multiple groups of non-crossed straight line segments fitted by each edge point set are the required arc segments. As shown in Figure 5 As shown in the figure, there are three arcs, namely A1, A2 and A3.
[0081] In this embodiment, in step S3, the result of contrast diffusion of each arc segment is calculated respectively, and the arc segments that have intersections after diffusion are fused to form an enhanced arc segment.
[0082] Specifically, the basic idea of contrast guidance is to identify a given edge (an edge point) as an edge region from a large receptive field (a range surrounding the edge point). To achieve this goal, for each arc segment, the edge pixels contained in it are diffused by a convolution filtering method. For a given arc segment represented as A, the enhanced arc segment is obtained by convolving the edge pixels contained in A with a Gaussian kernel. The variance of the Gaussian kernel used here is set to 2, and the filter window size is set to 7. After diffusion, for a non-edge pixel x = (x, y) around the edge pixel extracted by the Canny operator, if it satisfies
[0083]
[0084] In the formula, g m (x) represents the gradient strength at point x, g o (x) represents the horizontal angle at point x, e represents the edge point closest to x, where τ g and τ o There are two preset thresholds. The setting process is as follows Figure 6 Furthermore, for an edge pixel extracted by the Canny operator, if there are less than 3 edge pixels in its 8-neighborhood, it will be re-considered as a non-edge pixel. Figure 7 The visualization of edge diffusion is shown in . Figure 7 (a) is the detected arc segment. Figure 7(b) is the arc segment after diffusion enhancement. The edge points are visualized according to their contrast. If the two arc segments after diffusion have an intersecting part, the two arc segments are merged into one arc segment. Through this step, the fragmented arc segment affected by image discretization and noise can be enhanced into a well-continuous arc segment.
[0085] In this embodiment, in step S4, the result of contrast diffusion of each arc segment is calculated respectively, and the arc segments that have intersections after diffusion are fused to form an enhanced arc segment.
[0086] Specifically, considering that there may be occlusion of the ellipse in the image, the present invention combines two arc segments to fit and generate a candidate ellipse. In fact, the arc segments generated in most images do not contribute to establishing a valid arc segment combination, because the two arc segments are likely to come from different ellipses or curves. Therefore, it is crucial to make a decision as early as possible before fitting the ellipse. In the present invention, we believe that if two arc segments can be paired, they should be located in each other's search area. Figure 5 As shown in , arcs A1 and A2 can be combined because they are in each other's search domain. A1 and A3 in the figure cannot be combined because A1 is not in the search domain of A3, even though A3 is in the search domain of A1.
[0087] Furthermore, the search domain of each arc segment is calculated according to the contrast of the diffused arc segment, and the search domain is determined based on the contrast of the arc segment and its geometric features. First, a range is determined based on the reverse extension line of the first and last segments of the arc segment and the line connecting the first and last endpoints. Then, according to formula (2), the reverse extension line of the first and last segments is rotated toward the arc segment by a certain angle to expand the original search domain. When two arc segments meet the combination condition, the combination condition is that the two arc segments are located in each other's search area, then a candidate ellipse is fitted by least squares based on all edge points on the two arc segments. Formula (2) is:
[0088]
[0089] In the formula, |A| represents the number of edge points contained in arc segment A, g m (x) represents the gradient strength at point x.
[0090] In this embodiment, in step S5, the confidence of each candidate ellipse is calculated based on the density and uniformity of the edge points, and the candidate ellipses with low confidence are removed by an adaptive threshold based on image contrast, and the final ellipse detection result is output.
[0091] The candidate ellipses detected by the above steps cover almost all possible ellipses in the image, while retaining almost no repetition. In the present invention, in order to further ensure the quality of the detected ellipses, we perform ellipse candidate verification, which takes into account the density and uniformity clues of the edge points on the candidate ellipses.
[0092] Specifically, step S5 includes:
[0093] Step S51: For a candidate ellipse E, extract edge pixels whose normal distance of its contour is less than 2, and express the extracted S edge point set as
[0094] Step S52: The density index of the ellipse E is defined as:
[0095]
[0096] In the formula, is the perimeter of the candidate ellipse E; that is, an ellipse candidate with more edge pixels around the outline of the candidate ellipse E is more likely to be a correct detection.
[0097] Step S53: In order to calculate the uniformity index of the ellipse candidate E, the candidate ellipse E is divided into 360 accumulator bins {B k}, where the kth accumulator bin B k Corresponding to the angular ranges ((k-1)°, k°] of k=1, 2, ..., 360 respectively, the number of bins having at least one ellipse edge pixel based on the accumulator bins increases as:
[0098]
[0099] Where δ(·) is the Dirac delta function, Yes i Normal vector of vertical projection on candidate ellipse E; According to this formula, calculate the uniformity index U of candidate ellipse E:
[0100]
[0101] Where H(·) represents the Heaviside step function.
[0102] Step S54: Based on the density and uniformity index of edge pixels, the confidence of the candidate ellipse E is calculated by the following formula:
[0103]
[0104] Where α is a weighting factor and is preset to 0.4.
[0105] Step S55: Set the confidence level higher than τ v The candidate ellipse E is taken as the final ellipse detection result, where τ v is an adaptive threshold based on image contrast.
[0106] Furthermore, the above adaptive threshold τ based on image contrast v It is expressed as:
[0107]
[0108] Among them, g m (E) represents the average contrast of the edge points on the candidate ellipse E, g max Represents the maximum contrast in the input image. Through this formula, we require a larger confidence level for ellipses with strong contrast and a smaller confidence level for ellipses with weak contrast.
[0109] Table 1 shows a numerical comparison of the detection performance of the detection method of the present invention and the CNED method, Lu method, AAMED method, EllDet method, Liu method and CMED method, and the detection performance includes the evaluation results of the APR (average of the precision and recall) and F-value (harmonic mean of the precision and recall, F-measure) of the experiments of each method. It can be seen that the performance of the method proposed in the present invention on all data sets exceeds that of the existing algorithms.
[0110] Table 1
[0111]
[0112]
[0113] Table 1 presents a comparison of different ellipse detection methods in terms of APR (first entry) and F-measure (second entry). In each comparison case, the highest score is highlighted in bold.
[0114] Figure 8 The subjective evaluation results of the present invention and the existing algorithms are given in . It can be seen that the other six methods can detect ellipses in most images; however, they also produce a large number of false positives, resulting in very low precision and accuracy values. The method proposed in the present invention effectively reduces false positives by integrating image contrast features, and is superior to the other six methods in terms of precision and accuracy.
[0115] Embodiment 2
[0116] like Fig. 9As shown, the present invention provides an image ellipse detection system based on contrast guidance, which is used to implement the image ellipse detection method based on contrast guidance of the above embodiment 1, and specifically includes:
[0117] The edge extraction module 10 is used to input an RGB image, convert the RGB image into a grayscale image, extract edge points according to the grayscale image, and calculate the gradient amplitude and horizontal angle of each pixel point;
[0118] The arc segment extraction module 20 is used to connect adjacent edge points in the image to form multiple edge point sets starting from the edge point with the largest current gradient amplitude, and fit multiple end-to-end connected straight line segments, i.e., the required arc segments, for each edge point set;
[0119] The arc segment enhancement module 30 is used to calculate the result of each arc segment based on contrast diffusion, and merge the arc segments that have intersections after diffusion to form an enhanced arc segment;
[0120] An arc segment combination module 40, for calculating the search domain of each arc segment according to the diffused arc segment contrast, combining two arc segments within each other's search domain, and fitting candidate ellipse parameters;
[0121] The ellipse verification module 50 is used to calculate the confidence of each candidate ellipse based on the density and uniformity of the edge points, remove ellipses with low confidence by using an adaptive threshold based on image contrast, and output the final ellipse detection result.
[0122] A contrast-guided image ellipse detection system of the present embodiment is used to implement the aforementioned contrast-guided image ellipse detection method. Therefore, the specific implementation method of the contrast-guided image ellipse detection system can be seen in the embodiment part of the contrast-guided image ellipse detection method mentioned above. For example, the edge extraction module 10, the arc segment extraction module 20, the arc segment enhancement module 30, the arc segment combination module 40, and the ellipse verification module 50 are respectively used to implement steps S1, S2, S3, S4, and S5 in the aforementioned contrast-guided image ellipse detection method. Therefore, its specific implementation method can refer to the description of the corresponding embodiments of each part. In order to avoid redundancy, it will not be repeated here.
[0123] Embodiment 3
[0124] An embodiment of the present invention also provides an electronic device, which includes a processor, a memory and a bus system, wherein the processor and the memory are connected through the bus system, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to implement the above-mentioned contrast-guided image ellipse detection method.
[0125] Embodiment 4
[0126] An embodiment of the present invention further provides a computer storage medium, wherein the computer storage medium stores a computer software product, wherein the computer software product includes several instructions for enabling a computer device to execute the above-mentioned image ellipse detection method based on contrast guidance.
[0127] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0128] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0129] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0130] Obviously, the above embodiments are merely examples for clear explanation and are not intended to limit the implementation methods. For those skilled 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 list all the implementation methods here. The obvious changes or modifications derived from these are still within the protection scope of the invention.
Claims
1. A contrast-guided image ellipse detection method, characterized in that: include: Step S1: Input an RGB image, convert the RGB image into a grayscale image, extract edge points based on the grayscale image, and calculate the gradient amplitude and horizontal angle of each pixel; Step S2: Starting from the edge point with the largest current gradient amplitude, adjacent edge points in the image are connected to form multiple edge point sets, and multiple end-to-end connected straight line segments, i.e., the required arc segments, are fitted for each edge point set; Step S3: Calculate the result of contrast diffusion for each arc segment respectively, and fuse the arc segments that intersect after diffusion to form an enhanced arc segment, specifically including: For each arc segment, the contrast of the edge points extracted by Canny on the arc segment is filtered by Gaussian kernel, and the edge points are re-identified according to formula (1) for the filtered result, and the enhanced arc segment is generated based on the re-identified edge points; for the edge pixel extracted by Canny operator, if there are less than 3 newly identified edge points among its 8-connected neighbors, it is re-considered as a non-edge point; if the two arc segments after diffusion have an intersecting part, the two arc segments are merged into one arc segment; Where λ is a non-edge pixel around the edge pixel, g m (x) represents the gradient strength at point x, g o (x) represents the horizontal angle at point x, e represents the edge point closest to x, τ g and τ o are two preset thresholds; Step S4: Calculate the search domain of each arc segment according to the diffused arc segment contrast, combine two arc segments that are both within each other's search domain, and fit the candidate ellipse parameters; Step S5: Calculate the confidence of each candidate ellipse based on the density and uniformity of the edge points, remove the candidate ellipses with low confidence by using an adaptive threshold based on image contrast, and output the final ellipse detection result.
2. The image ellipse detection method based on contrast guidance according to claim 1, characterized in that: In step S1, it specifically includes: The Canny operator is used to extract edge points, and the Sobel operator is used to calculate the gradient amplitude and horizontal angle of each pixel in the grayscale image.
3. The image ellipse detection method based on contrast guidance according to claim 1, characterized in that: In step S2, it specifically includes: A polygonal approximation algorithm is used to fit multiple end-to-end connected straight line segments for each edge point set. In order to prevent the connected edge point set from bifurcation, the straight line segments are disconnected at the turning point according to the angle between the two preceding and following straight line segments. The multiple non-crossed straight line segment groups fitted by each edge point set are the required arc segments.
4. The image ellipse detection method based on contrast guidance according to claim 1, characterized in that: In step S4, it specifically includes: The search domain of each arc segment is calculated according to the contrast of the diffused arc segment, and the search domain is determined based on the contrast of the arc segment and its geometric features. First, a range is determined according to the reverse extension line of the first and last line segments of the arc segment and the line connecting the first and last endpoints. Then, according to formula (2), the reverse extension line of the first and last segments is rotated toward the arc segment by a certain angle to expand the original search domain. When two arc segments meet the combination condition, and the combination condition is that the two arc segments are located in each other's search area, a candidate ellipse is fitted by least squares based on all edge points on the two arc segments. In the formula, |A| represents the number of edge points contained in arc segment A, g m (x) represents the gradient strength at point x.
5. The image ellipse detection method based on contrast guidance according to claim 1, characterized in that: In step S5, it specifically includes: Step S51: For a candidate ellipse E, extract edge pixels whose normal distance of its contour is less than 2, and express the extracted S edge point set as Step S52: The density index of the ellipse E is defined as: In the formula, is the perimeter of the candidate ellipse E; Step S53: Divide the candidate ellipse E into 360 accumulator bins in the polar coordinate system {B k }, where the kth accumulator bin B k Corresponding to the angular ranges ((k-1)°, k°] of k=1, 2, ..., 360 respectively, the number of bins having at least one ellipse edge pixel based on the accumulator bins increases as: Where δ(·) is the Dirac delta function, Yes i Normal vector of vertical projection on candidate ellipse E; According to this formula, calculate the uniformity index U of candidate ellipse E: Where H(·) represents the Heaviside step function; Step S54: Based on the density and uniformity index of edge pixels, the confidence of the candidate ellipse E is calculated by the following formula: Where α is the weighting factor, which is preset to 0.4; Step S55: Set the confidence level higher than τ v The candidate ellipse E is taken as the final ellipse detection result, where τ v is an adaptive threshold based on image contrast.
6. The image ellipse detection method based on contrast guidance according to claim 1, characterized in that: The adaptive threshold τ based on image contrast v It is expressed as: Among them, g m (E) represents the average contrast of the edge points on the candidate ellipse E, g max Indicates the maximum contrast value in the input image.
7. An image ellipse detection system based on contrast guidance, characterized in that: The system is used to implement the image ellipse detection method based on contrast guidance according to any one of claims 1 to 6, specifically comprising: The edge extraction module is used to input an RGB image, convert the RGB image into a grayscale image, extract edge points based on the grayscale image, and calculate the gradient amplitude and horizontal angle of each pixel point; The arc segment extraction module is used to connect adjacent edge points in the image to form multiple edge point sets starting from the edge point with the largest current gradient amplitude, and fit multiple end-to-end connected straight line segments, i.e., the required arc segments, for each edge point set; The arc segment enhancement module is used to calculate the result of contrast diffusion for each arc segment and fuse the arc segments that intersect after diffusion to form an enhanced arc segment. An arc segment combination module is used to calculate the search domain of each arc segment according to the arc segment contrast after diffusion, combine two arc segments that are both within each other's search domain, and fit the candidate ellipse parameters; The ellipse verification module is used to calculate the confidence of each candidate ellipse based on the density and uniformity of the edge points, remove low-confidence ellipses through an adaptive threshold based on image contrast, and output the final ellipse detection result.
8. An electronic device, characterized in that: The electronic device includes a processor, a memory and a bus system, the processor and the memory are connected through the bus system, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to implement the contrast-guided image ellipse detection method described in any one of claims 1 to 6.
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 image ellipse detection method based on contrast guidance as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for detecting linear segment in image and related equipment
CN110288624A
Object shooting image ellipse detection algorithm based on Marklaurin theorem constraint
CN113962967A