Straight line fitting method for image detection in complex interference environment
Through the linear fitting method of image detection in complex interference environments, multiple random sampling and clustering are used to form multiple sets of total points, and each set of total points is fitted multiple straight lines. The model with the largest number of internal points is selected as the optimal model, which solves the problem of insufficient linear fitting accuracy in the existing technology, and achieves higher fitting accuracy and model stability.
Patent Information
- Application Number
- CN202411617545.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-13
AI Technical Summary
The existing linear fitting methods are difficult to effectively improve the fitting accuracy in complex interference environments, and there are problems such as high computational complexity, instability and sensitivity to outliers.
By acquiring images from the environment, contour extraction and interference point deletion, and then performing multiple random sampling and K-Means clustering to form multiple sets of total points, and performing multiple straight line fits to each set of total points, calculating the internal point ratio, selecting the linear model with the largest number of internal points as the optimal model, and performing linear fitting again through the internal point subsampling.
The accuracy of linear fitting is improved, the randomness and computational complexity of the fitting process are reduced, and the stability and robustness of the model are enhanced.
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of straight line fitting for image detection tasks, and in particular to a straight line fitting method for image detection in a complex interference environment. Background Art
[0002] In various detection tasks such as industrial detection / medical image detection / daily life detection, it is necessary to extract the contour of the image, then fit the line through the feature points, and then detect and judge the environment based on the fitted line and the geometric figures formed. At present, the main methods for fitting lines are RANSAC-based line fitting and linear regression line fitting. However, the RANSAC line fitting method finds the most suitable model by repeatedly selecting random subsets of data, fitting the model and evaluating its consistency. The effect depends on the parameter setting. Inappropriate parameters may cause the algorithm to fail to find a suitable model. The computational complexity is too high and can only handle relatively simple models. It is difficult to define a suitable residual threshold for complex models. In addition, due to the random selection of samples involved in the algorithm, the line fitting results are too unstable. The linear regression line fitting method fits the model by minimizing the mean square error between the predicted value and the actual value. However, this method is based on the assumption that the relationship between the variables is linear. If the linear assumption does not hold, the prediction effect of the model will be very poor. In addition, linear regression is very sensitive to outliers, which may seriously affect the parameter estimation and prediction results of the model. When there is a high correlation (collinearity) between the independent variables, the parameter estimation of linear regression may be unstable, affecting the interpretability of the model. Therefore, the accuracy of the final fitting straight line of the two commonly used existing straight line fitting methods is insufficient for complex interference environments. Summary of the invention
[0003] The purpose of the present invention is to provide a straight line fitting method for image detection in a complex interference environment to improve the straight line fitting accuracy.
[0004] The technical solution adopted by the present invention to solve the above technical problems is a straight line fitting method for image detection in a complex interference environment, comprising the following steps: Step 1: Obtain an image from the environment, then perform contour extraction to obtain a set of feature points; Step 2: Calculate the number of other feature points within a preset neighborhood range for each feature point. When the number is less than a preset threshold, the feature point is regarded as an interference point and deleted from the feature point set. Step 3: Perform multiple random sampling on the feature point set after removing the interference points in step 2 to obtain multiple sampling point sets; Step 4: Perform K-Means clustering on the sampling point set, and obtain the total point set corresponding to the straight line to be fitted from multiple sampling point sets; Step 5: Perform multiple straight-line fitting on each total point set by linear regression method, wherein one straight-line fitting uses all feature points of the total point set, and the remaining straight-line fittings randomly select part of the feature points of the total point set to obtain multiple straight-line models; Step 6: Calculate the distance between the feature points in each total point set and the multiple straight line models corresponding to the total point set. When the distance between the feature point and the straight line model is less than the preset residual threshold, the feature point is regarded as an inlier, the number of inliers is counted, and the ratio of the number of inliers to the total number of points is calculated to obtain the inlier ratio of each straight line model. Repeat the above process, calculate the inlier ratio of each straight line model multiple times, reduce the residual threshold value gradually during the iteration process, stop the iteration when the inlier ratio after any iteration decreases, count the final number of inliers of each straight line model, and select the straight line model with the largest number of inliers as the optimal model; Step 7: Perform inlier resampling on the total point set corresponding to the optimal model, and then perform straight line fitting on the resampled inlier point set using a linear regression method to obtain the final fitting straight line.
[0005] Preferably, in step six, the next residual threshold = the current residual threshold × K, where K is an adjustment factor.
[0006] Preferably, K=0.9.
[0007] According to the above technical solution, the beneficial effects of the present invention are: The present invention first removes interference points from the feature point set of the environmental image, then performs multiple random sampling, and then forms multiple total point sets through clustering, and then performs multiple straight-line fitting on each total point set, and ensures that the feature points selected during multiple fittings are different, and then calculates the proportion of inliers in the total point set based on the straight-line model, and finally selects the optimal model based on the number of inliers of all straight-line models. Even if a certain sampling contains an abnormal point, other samplings still have a high probability of generating a better model, and by selecting different feature points for multiple fittings, the effectiveness of the optimal model can be guaranteed, and the accuracy of straight-line fitting is improved. When calculating inliers, by dynamically adjusting the feedback mechanism of the residual threshold, the residual threshold is continuously reduced in multiple iterative calculations, and more points can be allowed to enter the model in the initial stage of iteration to ensure the diversity and robustness of the model, and the threshold is gradually tightened as the model converges, so as to more accurately screen out inliers that meet the model. Finally, by resampling the interior points and fitting the resampled interior points again, potential erroneous interior points are eliminated and the fitting accuracy is further improved. Compared with the existing straight line fitting method, the fitting process is simpler, the randomness of the fitting results is greatly reduced, the stability is greatly improved, and the fitting accuracy is also significantly improved. DETAILED DESCRIPTION
[0008] This embodiment provides a straight line fitting method for image detection in a complex interference environment, comprising the following steps: Step 1: Obtain an image from the environment, then perform contour extraction to obtain a set of feature points.
[0009] Step 2: Calculate the number of other feature points within a preset neighborhood range for each feature point. When the number is less than a preset threshold, the feature point is regarded as an interference point and deleted from the feature point set.
[0010] Step 3: Perform multiple random sampling on the feature point set after removing the interference points in step 2 to obtain multiple sampling point sets.
[0011] Step 4: Perform K-Means clustering on the sampling point set, and obtain the total point set corresponding to the straight line to be fitted from multiple sampling point sets.
[0012] When a straight line needs to be fitted according to the environment image, each sampling point set is clustered to obtain a total point set, and the total number of total point sets is the number of sampling point sets. When n straight lines need to be fitted according to the environment image, each sampling point set is clustered to obtain n total point sets, and the total number of total point sets is n times the number of sampling point sets.
[0013] Step 5: Perform multiple straight-line fitting on each total point set by linear regression method, wherein one straight-line fitting selects all feature points of the total point set, and the remaining straight-line fittings randomly select part of the feature points of the total point set to obtain multiple straight-line models.
[0014] Step 6: Calculate the distance between each feature point in the total point set and the multiple straight line models corresponding to the total point set. When the distance between the feature point and the straight line model is less than the preset residual threshold, the feature point is regarded as an inlier. The number of inliers is counted and the ratio of the number of inliers to the total number of points is calculated to obtain the inlier ratio of each straight line model.
[0015] The above process is repeated to calculate the proportion of inliers for each straight line model multiple times. The residual threshold is gradually reduced during the iteration process. When the proportion of inliers after any iteration decreases, the iteration is stopped, the final number of inliers for each straight line model is counted, and the straight line model with the largest number of inliers is selected as the optimal model.
[0016] The residual threshold and ratio threshold of each iteration can be set according to actual needs. For example, the initial threshold can be large (ϵ=5) and then gradually adjusted: If the proportion of inliers is greater than 70%, adjust the threshold to ϵ=4; If the proportion of inliers is greater than 80%, adjust the threshold to ϵ=3.
[0017] In addition, you can also directly set the next residual threshold = this residual threshold × K, where K is the adjustment factor, usually K=0.9, to ensure that the residual threshold will automatically decrease step by step, thereby filtering out more outliers and improving the fitting accuracy.
[0018] Step 7: Perform inlier resampling on the total point set corresponding to the optimal model, and then perform straight line fitting on the resampled inlier point set using a linear regression method to obtain the final fitting straight line.
[0019] Inlier point resampling can improve the fitting accuracy of the model and further eliminate potential erroneous inliers. Although a relatively good model has been found through the initial fitting, some inliers may still exist due to the inlier judgment criteria (i.e., residual threshold), and some outliers may be misjudged as inliers. These "erroneous inliers" may affect the fitting accuracy of the model, so they need to be screened again. Therefore, by sampling and fitting the selected inliers again, the fitting accuracy can be further improved and the impact of noise can be reduced.
Claims
1. A straight line fitting method for image detection in a complex interference environment, characterized in that: The following steps are involved: Step 1: Obtain an image from the environment, then perform contour extraction to obtain a set of feature points; Step 2: Calculate the number of other feature points within a preset neighborhood range for each feature point. When the number is less than a preset threshold, the feature point is regarded as an interference point and deleted from the feature point set. Step 3: Perform multiple random sampling on the feature point set after removing the interference points in step 2 to obtain multiple sampling point sets; Step 4: Perform K-Means clustering on the sampling point set, and obtain the total point set corresponding to the straight line to be fitted from multiple sampling point sets; Step 5: Perform multiple straight-line fitting on each total point set by linear regression method, wherein one straight-line fitting uses all feature points of the total point set, and the remaining straight-line fittings randomly select part of the feature points of the total point set to obtain multiple straight-line models; Step 6: Calculate the distance between the feature points in each total point set and the multiple straight line models corresponding to the total point set. When the distance between the feature point and the straight line model is less than the preset residual threshold, the feature point is regarded as an inlier, the number of inliers is counted, and the ratio of the number of inliers to the total number of points is calculated to obtain the inlier ratio of each straight line model. Repeat the above process, calculate the inlier ratio of each straight line model multiple times, reduce the residual threshold value gradually during the iteration process, stop the iteration when the inlier ratio after any iteration decreases, count the final number of inliers of each straight line model, and select the straight line model with the largest number of inliers as the optimal model; Step 7: Perform inlier resampling on the total point set corresponding to the optimal model, and then perform straight line fitting on the resampled inlier point set using a linear regression method to obtain the final fitting straight line.
2. The straight line fitting method for image detection in a complex interference environment according to claim 1, characterized in that: In step 6, the next residual threshold = this residual threshold × K, where K is the adjustment factor.
3. The straight line fitting method for image detection in a complex interference environment according to claim 2, characterized in that: K=0.9。
Citation Information
Patent Citations
Anti-jamming sub pixel straight line fitting method
CN108921865A
Straight line fitting method and device based on big data
CN112085759A
Crop navigation line extraction method for plant high-ridge cultivation environment based on machine vision
CN116128816A
Real estate surveying and mapping method
CN118501878A
Growth stage determination system and method
US20160224703A1
Cited By
Image edge detection method and device, electronic equipment and readable storage medium
CN121527444A
Image straight line detection method and device, electronic equipment and readable storage medium
CN121544907A