# A Linear Fitting Algorithm Based on Modified Random Sample Consensus
## 1 Introduction  
The linear fitting algorithm has wide applications in the edge detection of industrial components. The image processing of industrial parts often contains an important step to fit or locate linear edges. For example, auto-driving requires mapping capabilities in unknown environments, where linear fitting can substantially reduce data volume while enhancing efficiency and accuracy [1]. In lane detection and path planning, linear fitting algorithms are among the simplest yet most effective methods [2, 3, 4]. Moreover, linear fitting is also significant in data analysis and predictive modeling. By fitting a straight line, a predictive model can be constructed to forecast or interpret data trends [5, 6]. Handwritten digit recognition also benefits significantly from the role of linear fitting, as discussed in references [7, 8, 9]. A novel handwritten feature is developed using piecewise interpolation to identify the best-fit line within each window, forming a model to determine optimal operational window feature dimensions. Common linear fitting algorithms include three primary methods: Weighted Least Squares (WLS) [10, 11], Maximum Likelihood Estimation (MLE) [12], and Random Sample Consensus (RANSAC) [13, 14]. The accurate estimation of component posture in micro-assembly requires the use of linear fitting methods. After obtaining edge information through Canny edge detection, an improved least squares method is proposed to fit the linear edges of minor components. A threshold can be utilized to mitigate the influence of outliers in the point cloud during the process. Ref. [5] introduces an Iteratively Reweighted Least Squares linear fitting algorithm, which demonstrates high fitting accuracy when the number of noise points is low. However, when there are many noise points, the algorithm fails to produce a high-precision linear edge fitting due to significant initial fitting deviations. Ref. [15] proposes a hardened correction method based on iterative linear fitting within an industrial Computed Tomography imaging framework. This work combines the proposed linear fitting technique with Hermite function models to derive and analyze suitable blade data parameters. Ultimately, the fitting curves obtained using the proposed method are analyzed and compared with traditional polynomial fitting methods for the calibration of turbine blade projection data aimed at reconstructing tomographic images of different sets. The line fitting algorithm can also be used to directly obtain the spatial structure of the target from the image. Ref. [16] proposes a local spatial structure-RANSAC algorithm that is used in calculating homography matrices during the image matching process. It introduces information from image pairs directly into the RANSAC estimator and extracts spatial structural connections between points from it. Ref. [17] fills the gap by comprehensively reviewing related studies on detecting and describing two-dimensional image line segments to provide researchers with an overall picture and deep understanding. Ref. [18] proposes a scheme of lane line recognition under complex environment. However, due to surface contaminants or issues related to the manufacturing process, linear edges may exhibit noise such as smearing and burrs, causing edge points to deviate from the ideal line and significantly affecting the results of image processing [15; 19]. Before performing linear fitting, it is essential to preprocess the data by identifying and removing these outliers. The locality-sensitive property of Locality-Sensitive Hashing (LSH) can be utilized to detect and eliminate such anomalous points [20]. It makes full use of points that frequently appear together with the query points to improve the diversity of candidates, so that it can use fewer hash tables to obtain more valuable candidates for k-nearest neighbors algorithm. Ref. [21] proposes a large-scale group decision-making model based on a locality-sensitive hash function.