Efficient adaptive contour extraction method based on density perception
Through the improved farthest point sampling strategy and the DBSCAN algorithm optimized for adaptive parameter, the problems of noise point interference and point density unevenness in feature point set processing are solved, and efficient and accurate extraction of the target contour is achieved.
Patent Information
- Application Number
- CN202411905541.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-25
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art has problems of noise point interference and point density unevenness in feature point set processing, resulting in incomplete and inaccurate contour extraction.
Using an efficient adaptive contour extraction method based on density perception, the uniform coverage of feature point sets and accurate extraction of target contours is achieved through improved farthest point sampling strategy and adaptive parameter optimization DBSCAN algorithm.
It effectively avoids oversampling of dense areas and omissions of sparse areas, reduces dependence on initial points, and improves the accuracy and robustness of contour extraction.
Smart Images

Figure CN119888248A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision and data analysis, and specifically relates to an efficient adaptive contour extraction method based on density perception, which aims to effectively filter internal interference points from a feature point set and accurately extract the outer contour of a target to improve the accuracy and robustness of feature extraction and target segmentation. Background Art
[0002] In feature point set processing tasks, such as image segmentation and edge detection, accurately extracting the outer contour of the target is the key to achieving efficient feature extraction and target segmentation. However, feature point sets usually have the following two problems in practical applications:
[0003] 1) Noise interference: The feature point set usually contains randomly distributed noise points and internal non-target points. The existence of these points will interfere with the contour extraction process and reduce the accuracy and robustness of the extraction results; 2) Uneven point density: The distribution of feature points is usually uneven, and there may be dense areas and sparse areas. This distribution characteristic causes traditional methods to oversample in dense areas and undersample in sparse areas, resulting in incomplete contour extraction results.
[0004] The traditional farthest point sampling algorithm is a common point set sampling method. Its core goal is to achieve uniform coverage of the point set by iteratively selecting the point farthest from the current sampling set. However, this method has the following limitations:
[0005] 1) Dependence on the initial point: The sampling result is highly dependent on the selection of the initial point. Improper selection of the initial point will cause the sampling point to deviate from the target contour; 2) Preference for dense areas: In a non-uniformly distributed two-dimensional point set, the traditional farthest point sampling algorithm tends to oversample in dense areas and ignore points in sparse areas, resulting in incomplete contour extraction.
[0006] On the other hand, the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm is a density-based clustering algorithm that is widely used in noise filtering and boundary extraction in point sets. However, its performance is subject to some limitations in practical applications. Due to the sensitivity of parameter selection, the selection of two key parameters of DBSCAN (neighborhood radius Eps and minimum number of points MinPts) has a significant impact on the clustering effect. Traditional methods usually require manual adjustment of parameters and are difficult to adapt to scenarios with different point density distributions.
[0007] To solve the above problems, it is necessary to introduce methods with density perception and adaptive optimization capabilities to improve the robustness and completeness in noise filtering and contour extraction of non-uniform point sets. Summary of the invention
[0008] The purpose of the present invention is to provide an efficient adaptive contour extraction method based on density perception. The method achieves uniform coverage of the feature point set through an improved farthest point sampling strategy, effectively avoids oversampling of dense areas and omission of sparse areas, and reduces the dependence on the initial point; combined with the DBSCAN algorithm with adaptive parameter optimization, the method automatically determines the appropriate clustering parameters to ensure accurate extraction of the outermost contour of the target.
[0009] To achieve the above object, the technical solution adopted by the present invention is: An efficient adaptive contour extraction method based on density perception, the efficient adaptive contour extraction method based on density perception comprising: (1) Take the two-dimensional feature point set of the target object in the image and calculate the local density value of each point in the two-dimensional feature point set; (2) Calculate the density weighted value of each point in the two-dimensional feature point set based on the local density value; (3) Based on the density weighted value of each point, the farthest point sampling strategy is used to obtain a sampling point set from the two-dimensional feature point set, including: (31) Select four edge points of the target object in the two-dimensional feature point set, and for each edge point, use the edge point as the first point in the initial sampling set; (32) Calculate the weighted distance matrix of points in the two-dimensional feature point set except the initial sampling set as follows: In the formula, Indicates Points The weighted distance of Indicate point With point The Euclidean distance between represents the newly added points in the initial sampling set, Indicate point The density-weighted value of (33) Among the points in the two-dimensional feature point set other than the initial sampling set, the point with the longest weighted distance is selected according to the weighted distance matrix as the newly added point in the initial sampling set; (34) updating the initial sampling set and returning to step (32) until the number of points in the initial sampling set reaches a threshold, outputting four groups of initial sampling sets for the four edge points respectively, and obtaining the final sampling point set based on the four groups of initial sampling sets; (4) Generate a kernel density estimation curve graph based on the sampling point set; (5) Based on the sampling point set and the kernel density estimation curve graph, a density clustering algorithm is used to obtain an edge contour group, wherein the edge contour group includes multiple contour point sets, and the neighborhood radius in the density clustering algorithm increases according to the step size; (6) Based on the obtained edge contour group, compare the area sizes formed by each contour point set, and select the contour point set with the largest area as the contour point set of the target object finally extracted.
[0010] Several optional methods are also provided below, but they are not intended to be additional limitations on the above-mentioned overall solution, but are merely further supplements or preferences. Under the premise that there are no technical or logical contradictions, each optional method can be combined with the above-mentioned overall solution separately, and multiple optional methods can also be combined.
[0011] Preferably, calculating the local density value of each point in the two-dimensional feature point set includes: In the formula, Indicates Points The local density value of Represents the total number of points in the two-dimensional feature point set, represents the bandwidth parameter, represents the kernel function used by the kernel density estimation method, Indicates Points With Points The Euclidean distance between .
[0012] Preferably, the bandwidth parameter The calculation process is as follows: In the formula, is the standard deviation of the points in the two-dimensional feature point set, Represents the standard deviation of the horizontal coordinates of the points in the two-dimensional feature point set, Represents the standard deviation of the ordinate of the points in the two-dimensional feature point set, Indicates Points The horizontal axis of Indicates Points The vertical coordinate of Represents the mean of the horizontal coordinates of the points in the two-dimensional feature point set, Represents the mean of the ordinates of the points in the two-dimensional feature point set.
[0013] Preferably, the step of calculating the density weighted value of each point in the two-dimensional feature point set according to the local density value comprises: First, the local density values of all points in the two-dimensional feature point set are normalized to the interval [0,1]: In the formula, represents the normalized local density value, represents the local density value before normalization, represents the minimum local density value, represents the maximum local density value, is the smoothing term; Then calculate the density weighted value of each point in the two-dimensional feature point set: In the formula, Indicates Points The density weighted value of Represents a nonlinear scaling factor.
[0014] Preferably, generating a kernel density estimation curve graph according to the sampling point set includes: Select a reference point and calculate the Euclidean distance between each point in the sampling point set and the reference point to obtain a set of distance arrays ; Calculate distance array The density estimation value of each distance in , the kernel density estimation formula is: In the formula, Indicates Distance The local density value of Represents a distance array The total number of middle distances, represents the bandwidth parameter, represents the kernel function used by the kernel density estimation method, Indicates distance, ; Bandwidth parameters The calculation is as follows: In the formula, Represents a distance array The standard deviation of the median distance, Represents a distance array The average value of the middle distance; Based on local density values and distance The corresponding relationship generates a kernel density estimation curve graph.
[0015] Preferably, the density clustering algorithm adopts the DBSCAN algorithm, and selects the horizontal axis value corresponding to the minimum scale after the vertical axis in the kernel density estimation curve is equally spaced. The minimum scale value after the horizontal axis is divided equally As neighborhood radius The value range of , and set the minimum number of points in the ε-neighborhood is 2.
[0016] As a preference, set the neighborhood radius The step size is .
[0017] The present invention provides an efficient adaptive contour extraction method based on density perception, which achieves uniform coverage of feature point sets through an improved farthest point sampling strategy, effectively avoids oversampling of dense areas and omission of sparse areas, and reduces dependence on initial points. At the same time, the DBSCAN algorithm with adaptive parameter optimization is combined to determine appropriate clustering parameters, ensure accurate extraction of the outermost contour of the target, and improve contour extraction efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A flowchart of an efficient adaptive contour extraction method based on density perception of the present invention; Figure 2 A schematic diagram of selecting four initial points in the improved farthest point sampling strategy of the present invention; Figure 3 This is a schematic diagram of the iterative process of the farthest point sampling strategy improved by the present invention; Figure 4 It is a kernel density estimation curve diagram of distance-density of the present invention; Figure 5 Schematic diagram of the original two-dimensional feature point set of the safety buckle of the present invention; Figure 6 It is a schematic diagram of the sampling point set of the safety buckle after being processed by the improved farthest point sampling strategy of the present invention; Figure 7It is a schematic diagram of the edge contour group of the safety buckle after being processed by the DBSCAN algorithm with adaptive parameter optimization of the present invention. DETAILED DESCRIPTION
[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0021] like Figure 1 As shown, this embodiment provides an efficient adaptive contour extraction method based on density perception, comprising the following steps: S1, the two-dimensional feature point set of the target object in the preset image , for the two-dimensional feature point set Each point , is a set of two-dimensional feature points The total number of midpoints, whose local density value is calculated.
[0022] point The local density value of is calculated using the kernel density estimation method, and the formula is: In the formula, Indicates Points The local density value of Represents the total number of points in the two-dimensional feature point set, Indicates Points With Points The Euclidean distance between Understood as the current target point, Understood as a two-dimensional feature point set The point in represents the bandwidth parameter. In this embodiment, the bandwidth parameter is determined by using Silverman's rule method, which is defined as: In the formula, is a set of two-dimensional feature points The standard deviation of the midpoint is defined as: In the formula, , They are The horizontal and vertical coordinates of the point, , They are two-dimensional feature point sets The midpoint is horizontal, the mean of the vertical coordinates, and They are two-dimensional feature point sets The midpoint is horizontal and the standard deviation is vertical.
[0023] represents the kernel function used by the kernel density estimation method. This embodiment uses a Gaussian kernel, which is defined as: in, is the kernel function Input.
[0024] S2: Construct a two-dimensional feature point set based on the local density values of each point obtained in step S1 The specific steps are as follows: S21, firstly, the two-dimensional feature point set The local density values of all points in are normalized to the interval [0,1] to facilitate subsequent operations: In the formula, represents the normalized local density value, represents the local density value before normalization, represents the minimum local density value, represents the maximum local density value, is a smoothing term to prevent the numerator and the mother from being zero. .
[0025] S22, then obtain a two-dimensional feature point set The weights (weighted density values) of all points in , thus forming a two-dimensional feature point set Weighted graph of , where the weight of each point is determined by its density value The reciprocal of the power is: In the formula, Indicates Points The density weighted value of The nonlinear scaling factor is used to adjust the weight distribution of sparse areas and dense areas, as shown in Table 1 below. In this embodiment, .
[0026] Table 1 The impact of values on sparse and dense areas #timg# Value range Sparse area weight Dense Area Weight Overall Impact (-#timg#,-1) great Very small Extremely strengthen sparse areas and ignore dense areas (-1,0) Smaller Slightly smaller Ignore its impact (0,1) Larger Slightly smaller Emphasize sparse areas and reduce the impact of dense areas (1,+#timg#) great Larger Extremely strengthen sparse areas and reduce the impact of dense areas S3, using the improved farthest point sampling strategy to exclude the two-dimensional feature point set The scattered and disordered internal interference points in the middle generate a sampling point set that is evenly distributed and can better preserve the contour shape of the point set. , the specific steps are as follows: S31, in order to reduce the impact of the initial point selection of the traditional farthest point sampling strategy on the results, such as Figure 2 As shown, this embodiment selects a two-dimensional feature point set The top, bottom, leftmost and rightmost edge points are used as the initial points: In the formula, is the uppermost boundary point, is the lowest boundary point, is the leftmost boundary point, is the rightmost boundary point, Represents traversing a two-dimensional feature point set Take the point with the smallest y coordinate , Represents traversing a two-dimensional feature point set Take the point with the largest y coordinate , Represents traversing a two-dimensional feature point set Take the point with the smallest x coordinate , Represents traversing a two-dimensional feature point set Take the point with the largest x coordinate .
[0027] S32: Perform independent farthest point sampling iterations for the four edge points in step S21. The difference from the traditional farthest point sampling strategy is that the density weighted values corresponding to each point obtained in step S12 are added. , the specific steps are as follows: S321, Select , , and Any point in the , the number of points in the preset initial sampling set must reach , the initial sampling set , weighted distance matrix As shown below: S322, from point set (Two-dimensional feature point set Except for the initial sampling set Select the second point according to the weighted distance criterion : S323: Update initial sampling set , As the initial sampling set New points added in this iteration: S324, for each unsampled point , update the weighted distance matrix : Update point When calculating the weighted distance, take the weighted distance calculated last time , and the new weighted distance calculated based on the newly added points The minimum value in Updated weighted distance.
[0028] S325, iterate and repeat the selection process until the initial sampling set The size reaches the target number of sampling points ; S3251, each iteration, based on the points other than the sampling point set in the two-dimensional feature point set, select the point with the longest weighted distance according to the weighted distance matrix As the newly added points in this iteration sampling point set: S3252, update the initial sampling set , As the initial sampling set New points added in this iteration: S3253, Update weighted distance matrix : like Figure 3 As shown, the first step is to select the leftmost point ① as the first sampling point for illustration; the second step is to calculate the weighted distance matrix of all unsampled points and the first sampling point in turn, and take the point ② with the largest weighted distance as the second sampling point; the third step is to calculate the weighted distance matrix of all unsampled points and the second sampling point in turn, retain the shortest weighted distance, update the weighted distance matrix obtained in the second step, and then obtain the point ③ with the largest weighted distance from the weighted distance matrix as the next sampling point, for example Figure 3 If the weighted distance d1 is less than d2, then d1 is retained; if the weighted distance d4 is less than d3, then d4 is retained; then if the weighted distance d1 is less than d4, point ③ is used as the next sampling point; repeat the third step until the target number of sampling points is iterated.
[0029] S326. Finally, four groups of initial sampling sets are obtained. , , and , For As the initial sampling set obtained by the first point iteration, For As the initial sampling set obtained by the first point iteration, For As the initial sampling set obtained by the first point iteration, For The initial sampling set obtained as the first point iteration.
[0030] S33, obtaining the final sampling point set according to the four groups of initial sampling sets in step S226 , the specific steps are as follows: S331, obtaining the common point set (intersection) of the four groups of initial sampling sets in step S226 : S332, obtain the non-common point sets (difference sets) of the four initial sampling sets : S333, for each point in the non-common point set , in the common point set Find the point The two closest points are denoted as .calculate The Euclidean distance is ,calculate To Segment Distance .like Less than , then the point Insert into the sampling point set Otherwise, discard the point and continue to determine the non-common point set The next point in the non-common point set The traversal of the points in is completed;
[0031] S334, the common point set All points in are inserted into the sampling point set In the final set of sampling points to obtain.
[0032] S4, similar to the kernel density estimation method in step S1, the final sampling point set is obtained in step S334 , calculate the kernel density estimation curve of the point set, the specific steps are as follows: S41. Select the final set of sampling points of( , ) as a reference point, calculate The Euclidean distance between each point and the reference point is used to obtain an array of distances. ,in , The final sampling point set The midpoint is horizontal and the mean is vertical.
[0033] S42: Different from the density calculation method of the point in step S1, the distance array is calculated here. The kernel density estimation formula for each distance in is: In the formula, Indicates Distance The local density value of Represents a distance array The total number of middle distances, represents the bandwidth parameter, represents the kernel function used by the kernel density estimation method, Indicates distance, ; and the bandwidth parameter The calculation is as follows: In the formula, Represents a distance array The standard deviation of the median distance, Represents a distance array The average value of the middle distance; S43, the density value obtained in step S42 and distance The corresponding relationship generates a kernel density estimation curve graph.
[0034] S5. Based on the final sampling point set and the kernel density estimation curve, a density clustering algorithm is used to obtain an edge contour group, which includes multiple contour point sets. The neighborhood radius in the density clustering algorithm is adaptively iteratively optimized according to the step size.
[0035] For the final sampling point set in step S334 , using the improved adaptive parameter DBSCAN density clustering algorithm to obtain edge contour groups , For the A set of contour points, is the number of contours, , automatically determine the appropriate clustering parameters in the DBSCAN algorithm with adaptive parameter optimization , to ensure accurate extraction of the outermost contour of the target. The specific steps are as follows:
[0036] S51, analyzing the kernel density estimation curve graph in step S43, It indicates the horizontal axis value corresponding to the smallest scale after the vertical axis is divided into equal intervals. It is the minimum scale value after the horizontal axis is divided into equal intervals. Figure 4 As shown, in this embodiment About 41, is about 50. This embodiment is to detect the structure of the closed-loop contour, so the minimum number of points in the ε-neighborhood is Set to 2.
[0037] S52, initialize neighborhood radius for .
[0038] S53, the current and As a parameter, Execute the DBSCAN density clustering algorithm to obtain the processed contour point set : S54, calculate the current point set The silhouette coefficient of the current silhouette coefficient is stored Value. is the step size, , using the silhouette coefficient as a basis, and returning to continue executing step S53, iterating to Finish.
[0039] S55, select the maximum value of the silhouette coefficient corresponding to , recorded as the global optimal .
[0040] S56, according to the global optimal and , execute the DBSCAN density clustering algorithm to obtain the final contour point set, recorded as the edge contour group : S6: edge contour group obtained according to step S56 , compare each contour point set The area size is formed, and the point set with the largest area is selected as the contour point set of the target object finally extracted.
[0041] In an example operation, select the two-dimensional feature point set of the safety buckle in the preset image like Figure 5 As shown, the farthest point sampling strategy is used to select the two-dimensional feature point set Get the sampling point set as Figure 6 As shown, the edge contour group obtained by the adaptive parameter DBSCAN density clustering algorithm Include Figure 7 Contour No. 1 and contour No. 2 are selected, and finally contour No. 2 with the largest area is selected as the contour point set of the target object finally extracted.
[0042] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0043] The above-mentioned embodiments only express several implementation modes of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.
Claims
1. An efficient adaptive contour extraction method based on density perception, characterized in that: The efficient adaptive contour extraction method based on density perception comprises: (1) Take the two-dimensional feature point set of the target object in the image and calculate the local density value of each point in the two-dimensional feature point set; (2) Calculate the density weighted value of each point in the two-dimensional feature point set based on the local density value; (3) Based on the density weighted value of each point, the farthest point sampling strategy is used to obtain a sampling point set from the two-dimensional feature point set, including: (31) Select four edge points of the target object in the two-dimensional feature point set, and for each edge point, use the edge point as the first point in the initial sampling set; (32) Calculate the weighted distance matrix of points in the two-dimensional feature point set except the initial sampling set as follows: In the formula, Indicates Points The weighted distance of Indicate point With point The Euclidean distance between represents the newly added points in the initial sampling set, Indicate point The density-weighted value of (33) Among the points in the two-dimensional feature point set other than the initial sampling set, the point with the longest weighted distance is selected according to the weighted distance matrix as the newly added point in the initial sampling set; (34) updating the initial sampling set and returning to step (32) until the number of points in the initial sampling set reaches a threshold, outputting four sets of initial sampling sets for the four edge points respectively, and obtaining the final sampling point set based on the four sets of initial sampling sets; (4) Generate a kernel density estimation curve graph based on the sampling point set; (5) Based on the sampling point set and the kernel density estimation curve graph, a density clustering algorithm is used to obtain an edge contour group, wherein the edge contour group includes multiple contour point sets, and the neighborhood radius in the density clustering algorithm increases according to the step size; (6) Based on the obtained edge contour group, compare the area sizes formed by each contour point set, and select the contour point set with the largest area as the contour point set of the target object finally extracted.
2. The efficient adaptive contour extraction method based on density perception according to claim 1 is characterized in that: The calculating the local density value of each point in the two-dimensional feature point set includes: In the formula, Indicates Points The local density value of Represents the total number of points in the two-dimensional feature point set, represents the bandwidth parameter, represents the kernel function used by the kernel density estimation method, Indicates Points With Points The Euclidean distance between .
3. The efficient adaptive contour extraction method based on density perception according to claim 2 is characterized in that: The bandwidth parameter The calculation process is as follows: In the formula, is the standard deviation of the points in the two-dimensional feature point set, Represents the standard deviation of the horizontal coordinates of the points in the two-dimensional feature point set, Represents the standard deviation of the ordinates of the points in the two-dimensional feature point set, Indicates Points The horizontal axis of Indicates Points The vertical coordinate of Represents the mean of the horizontal coordinates of the points in the two-dimensional feature point set, Represents the mean of the ordinates of the points in the two-dimensional feature point set.
4. The efficient adaptive contour extraction method based on density perception according to claim 1 is characterized in that: The step of calculating the density weighted value of each point in the two-dimensional feature point set according to the local density value includes: First, the local density values of all points in the two-dimensional feature point set are normalized to the interval [0,1]: In the formula, represents the normalized local density value, represents the local density value before normalization, represents the minimum local density value, represents the maximum local density value, is the smoothing term; Then calculate the density weighted value of each point in the two-dimensional feature point set: In the formula, Indicates Points The density weighted value of Represents a nonlinear scaling factor.
5. The efficient adaptive contour extraction method based on density perception according to claim 1 is characterized in that: The step of generating a kernel density estimation curve graph according to the sampling point set includes: Select a reference point and calculate the Euclidean distance between each point in the sampling point set and the reference point to obtain a set of distance arrays ; Calculate distance array The density estimation value of each distance in , the kernel density estimation formula is: In the formula, Indicates Distance The local density value of Represents a distance array The total number of middle distances, represents the bandwidth parameter, represents the kernel function used by the kernel density estimation method, Indicates distance, ; Bandwidth parameters The calculation is as follows: In the formula, Represents a distance array The standard deviation of the median distance, Represents a distance array The average value of the middle distance; Based on local density values and distance The corresponding relationship generates a kernel density estimation curve graph.
6. The efficient adaptive contour extraction method based on density perception according to claim 1 is characterized in that: The density clustering algorithm adopts the DBSCAN algorithm, and selects the horizontal coordinate value corresponding to the minimum scale after the vertical coordinate is equally spaced in the kernel density estimation curve graph. The minimum scale value after the horizontal axis is divided equally As neighborhood radius The value range of , and set the minimum number of points in the ε-neighborhood is 2.
7. The efficient adaptive contour extraction method based on density perception according to claim 6 is characterized in that: Set the neighborhood radius The step size is .