IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Modules demonstrating how to estimate line 2d parameters from a cloud of points containing outliers. More...

Modules demonstrating how to estimate line 2d parameters from a cloud of points containing outliers.

Line2dRobustEstimation.png

For more informations about parametric estimation features, please see Parametric estimation.

We start by importing all necessary libraries:

import PyIPSDK

Searched 2d line is defined using polar coordinates : $\theta = \frac{2\pi}{3}$ and $\rho=5$.

We then define input data points as points on previous line with perturbated ordinate :

\[ P_i = \{x_i, y_i\} \mid y_i=(rho-cos(theta)*x_i)/sin(theta) + N(0, 1) \]

with :

Coordinates of two points have been manually modified to introduce outliers

# we define a 2d line by its polar coordinates
# rho = 5 and theta = 2pi/3 (roughly 2.094)
# We then use following sampled points :
# each point is defined has [x; y=(rho-cos(theta)*x)/sin(theta) + N(0, 1)]
# where N(0,1) is a random centered normal noise with unit standard deviation
# Coordinates of two points have been modified to introduce outliers
ptColl = [
[-10, 1.35403297463199],
[-9, 0.467545836976205],
[-8, -0.46107136900246],
[-7, 2.88401452309772],
[-6, 1.35410194806754],
[-5, 3.42764603498653],
[-4, 2.73323167279303],
[-3, 4.22309730303385],
[-2, 10], # outlier !
[-1, 5.65520168353248],
[0, 5.91414922631518],
[1, 5.86675394243645],
[2, 0], # outlier !
[3, 7.82681999731427],
[4, 6.99551190321505],
[5, 8.93195534818365],
[6, 9.75159614279396],
[7, 11.116355092464],
[8, 10.3324851051409],
[9, 11.8861915791043],
[10, 10.5877158470975],
]

We then compute robust least square line estimation using following syntax :

# we can then simply compute robust least square line
cfg = PyIPSDK.EstimationConfig()
cfg.initLMS(0.40)
line, res = PyIPSDK.line2dEstimation(ptColl, cfg)

In this case we use Least Mean of Squares (LMS) robust algorithm for computation with an expected outlier ratio set to $0.4$.

At last we display estimation results

# display results
print("Estimated line :")
print("----------------")
print(line)
print("")
print("Estimation detailed results")
print(res)

See the full source listing