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?