You are on page 1of 5

# Straight Line Fitting

## Straight Line Fitting

Consider the problem where a set of points are given and it is require that we nd the line that ts these points .

Input data

The equation of straight line is given by y = mx + c Thus given set of points (x, y) it is reqired that we nd the unknowns are m and c.

## Straight Line Fitting

we require two equations to obtain a unique solution for these two quantities. For each point (x, y) we obtain a equation.The solution to set of equations will only exist if all the points lie on the straight line. However if all the points do not lie on the same line . One approach is to nd a line that ts these points according to some predened criteria. One such criteria is to nd a solution that minimizes the error between the observed data points and estimated straight line. Let y be the error in estimation.Then the mean squared error in given by
N

=
i=1

(y i y i )2

N

## 2(y i mxi c)xi

i=1 N

i=1

2(y i mxi c) = 0

Y = Xm and X T Y mX T X = 0 M = [m c]T

## The set of equations can be expressed in matrix form as.

Y = Xm + c

where m and c are scalars and Y is N x1 matrix of y coordinates and X is N X1 matrix of x co-orrdinates. The solution to this is given by
M = (X X T )1 (X T Y )

## Straight Line Fitting

But the least squares t is aected by outliers error = 30 with the given data .Now after adding a single outlier the error is 315 increase in error is about 10 times we will now look and RANSAC algorithm to t a line. Also a large set of outliers are introduced. The input to algorithm is a set of observed values,a parameterized model that can be used to t points to a model,and condence parameters. The algorithm interatively selects a random subset of points from the observed data . These points are assumed to be inliers . Model parameters are estimated from these points. If these points are inliers ,any point which t to estimated model is also a inlier. If many inlier points are detected then estimation is a reasonably good. A new model is estimated from all the inlier points and parameters of model are stored. A error measure is calculated as to how well the model ts the data. This process is carried

## Straight Line Fitting out iteratively till terminating condition is encountered.

At each iteration we check if error measure has improved and replace the current parameters with improved parameters. The considence parameter is the distance error threshold. The parameterized model is equation of straight line or we can use the least square tting model etc.

## Straight Line Fitting using RANSAC algorithm

The RANSAC algorithm can be used to tackle outilers in any parameterized model estimation process. We will later look at tting points to ellipse and circles using the standard approaches as well as RANSAC.