# Overview

The problem is perhaps a very easy one for a trained mathematician. As I am not a mathematician, but instead a researcher in general problem solving, I am reaching out to those who know more than I in an effort to solve a problem. The mathematics are known to me in a simpler form of the solution and it all relates to a set of operations used in optics: radial lens distortion. I have a function: $y=f(x)$. I need the inverse function such that: $x=f'(y)$.

# The Data

A few websites give a good review of the equations in a simpler form:

1. paulbourke.net/miscellaneous/lenscorrection/
2. en.wikipedia.org/wiki/Distortion_%28optics%29
3. www.imagemagick.org/Usage/lens/correcting_lens_distortions.pdf
• See Page 3
4. This post asks the same question, but with less contextual data

### Definition of Terms

• $\vec\alpha$
• non-normalized vector from $\displaystyle Pixel\_current_{x,y}$ to $\displaystyle Pixel\_center_{x,y}$
• $\beta$
• length of $\vec\alpha$
• $k_i$
• The $i$-th coefficient of the distortion parameter series
• $P_{(x,y)}$
• Undistorted Pixel Location
• $Q_{(x,y)}$
• Distorted Pixel Location

### List of Known Functions

The radial distortion function is in the form of:

• FUNCTION 1 :: $P_{(x,y)} = Q_{(x,y)} \times ( \displaystyle 1 + \displaystyle\sum_{i=1}^\infty(k_i × \beta^{2i} ))$

Most implementations contain only the first two distortion terms, and thus looks like:

• FUNCTION 2 :: $P_{(x,y)} = Q_{(x,y)} \times (1 + k_1\beta^2)$

I've found a working inverse function for FUNCTION 2:

• FUNCTION 3 :: $Q_{(x,y)} = \displaystyle \frac {P_{(x,y)}} {1 - k_1 \times \displaystyle \left\| \frac{\vec\alpha}{1 - k_1 \times \left\|\vec\alpha\right\|^2} \right\|^2}$

FUNCTION 3 works beautifully as long as I don't need a second distortion coefficient, or the second term of the original Taylor series.

# The Request

## 1.

What I’m looking for is a reciprocal function that accounts for the first two terms of the Taylor series, the inverse of:

• FUNCTION 4 :: $P_{(x,y)} = Q_{(x,y)} \times \left( 1 + k_1 \times \left\|\vec\alpha\right\|^2 + k_2 \times \left\|\vec\alpha\right\|^4 \right)$

## 2.

I need a version of the formula that I can write into computer code using a list of operators defined on this page; in addition to standard operators like: $+ - \times \div \left( \right)$, etc. So, every step needs to be broken down into single instructions. Again, my math-fu is limited.

• I don't understand... Isn't it simply $$Q_{(x,y)} = P_{(x,y)}\times\left(1+\sum\limits_{i=1}^\infty k_i\times \|\alpha\|^{2i}\right)^{-1}?$$ What am I missing? Does $\times$ not mean normal multiplication? – Eff Jun 2 '15 at 18:17
• It's possible that the inversion would do the trick, I'll have to check it out mathematically, but if I read your notes right then the formula itself would look something like (I'm also making a correction that may be necessary): $$\frac {P_{(x,y)}}{\left(1+\sum\limits_{i=1}^\infty k_i\times \|\alpha\|^{2i}\right)^{-1}}$$ – Andrew Jun 2 '15 at 18:23
• Also, does your inversion methodology match the FUNCTION 3 defined in the original question? I don't have the math skills to verify this. – Andrew Jun 2 '15 at 18:26
• The formula I wrote is the same you wrote if you removed the power $-1$. I don't think I understand what exactly you are asking, and the reason is this: function 3 should, according to me, be $$Q_{(x,y)} = \frac{P_{(x,y)}}{1+k_1\times\|\alpha\|^2}.$$ Maybe I also don't understand your notation. Am I correct in saying that $\alpha, P, Q$ are vectors and $k_i$ are real numbers and $\times$ means normal multiplication? – Eff Jun 2 '15 at 18:36
• $\alpha$ is a vector, $P$ and $Q$ are 2D positions (akin to vectors in data type but are not directions with strengths) and the rest of your assumptions are the same. – Andrew Jun 2 '15 at 18:39