2
$\begingroup$

I am trying to undistort certain pixels in an image (not all of them, that would make the solution too easy...).

A quick intro to image distortion (not undistortion yet!): We assume that all possible undistorted pixels in an image frame have normalized, zero mean coordinates x and y. In the following equations, r is the radius from the center of the image to the pixel defined by:

$r = \sqrt{x^2 + y^2}$

Given this radius, the radius of the distorted pixel ($r'$) given a little bit of radial distortion is

$r'=(1+k_1\cdot r^2 +k_2\cdot r^4)\cdot r$

Now, for the actual problem. It is more likely that one has a distorted image than an undistorted one. Furthermore, that the goal is to undistort a point of interest in the picture so it can be used for triangulation etc.

Therefore the equation to be solved is

$r'=r+k_1\cdot r^3 +k_2\cdot r^5$,

where $k_1$ and $k_2$ are the (only) two distortion parameters that we have obtained by calibrating the camera, and r' is calculated using the distorted pixel coordinates.

Since r is strictly positive, the polynomial is strictly positive in our range of interest. Moreover, the exponents are nicely sequential. Intuitively I'd say that there is a mathematical solution to this that does not involve iterating with a for-loop. This is the way the OpenCV library handles it, but they take into account a lot more distortion parameters than I do.

The condensed version of the question is: Can $r'=r+k_1\cdot r^3 +k_2\cdot r^5$ be solved for $r$, given $r'$, $k_1$ and $k_2$ and the fact that both $r'$ and $r$ are strictly positive?

1 Answers 1

0

It depends what you mean with "solved". If you are willing to go for numerical solutions instead of purely algebraic ones, yes! You are looking for at least one solution of the equation:

$f(x)=k_2 x^5 +k_1 x^3 + x - r'=0$

Since $f(x)$ is an odd-degree polinomial with real coefficients, it has at least one real solution - in fact, a positive solution in the interval $(0,r')$, given that $k_2$, $k_1$, and $1$ are positive and $-r'$ is negative. You can just apply the Newton-Raphson method to find it. It's actually pretty fast!

Once you've found that solution $\alpha$, if you are interested in the others, you can just divide $f(x)$ by $(x-\alpha)$, obtaining a $4^{th}$ degree polynomial that admits an algebraic solution based on the coefficients.

However, an algebraic solution that allows you to avoid the numerical step is unlikely to exist due to the Abel-Ruffini theorem.