# Multidimensional fitting of two sets of data

1. Aug 1, 2014

### datameng

Hello, my problem is the following:

A lasers gives out a bunch of data points which are reflected off a metal surface and recorded by a camera attached to the side of the laser. The image the camera receives is however distorted.

In order to calibrate the camera I need to find a function of two variables (f(x,y)) which transforms the distortet(wrong) data points back into their originals so that the camera image can be used for accurate analysis.

I know the location (x and y values) of the original image and their corresponding camera positions (x' and y').

How can I use these to find a transfer function between the two data sets?
I have already used SVD and a 6th order polynom merit function for multidimensional fits I found in "Numerical Recipes", and although I get resonable results, they are not accurate enough.

Any help is greatly appreciated!!

2. Aug 1, 2014

### da_nang

You'll have to correct me if any assumptions are wrong.

You have two sets of $n$ 2D points, $P$ (original) and $Q$ (camera), with the dimensions $2 \times n$. Let's assume there exists a function such that $\vec{q} = \vec{f}(\vec{p})$ with $\vec{p}$ and $\vec{q}$ being individual points from $P$ and $Q$ respectively and has dimension $2 \times 1$.

You then want to find the function $\vec{p} = (\vec{f})^{-1}(\vec{q}) = \vec{g}(\vec{q})$?

Let's assume the inverse function $\vec{g}(\vec{q})$ exists. We can then write it, for each individual point, as $$\left[\begin{array}{c} p_x \\ p_y \end{array} \right] = \left[\begin{array}{c} g_x(q_x, q_y) \\ g_y(q_x, q_y) \end{array} \right]$$
I suppose what you could do then is to interpolate each row, either with polynomials or splines.

3. Aug 1, 2014

### chogg

How many datapoints?