Suppose I have a 240x180 camera with the following distortion co-efficients,

$$k_1 = -0.138592767408$$ $$k_2=0.0933736664192$$ $$k_3=0.0$$ $$p_1=k_4=-0.000335586987532$$ $$p_2=k_5=0.000173720158228$$

The camera center is given to be

$$u_0 = 129.924663379$$ $$v_0 = 99.1864303447$$

And the distortion formulae are

$$r^2=(u-u_0)^2+(v-v_0)^2$$

\begin{align} \begin{bmatrix} u_d\\ v_d \end{bmatrix} = & (1+k_1r^2+k_2r^4+k_3r^6) \begin{bmatrix} u-u_0\\ v-v_0 \end{bmatrix} + \\ & \begin{bmatrix} 2k_4(u-u_0)(v-v_0)+k_5(r^2+2(u-u_0)^2)\\ k_4(r^2+2(v-v_0)^2+2k_5(u-u_0)(v-v_0) \end{bmatrix} + \begin{bmatrix} u_0\\ v_0 \end{bmatrix} \end{align}

In the above formulae, $$p_1=k_4$$ and $$p_2=k_5$$, $$u$$ and $$v$$ are the undistorted co-ordinates and $$u_d$$, $$v_d$$ the corresponding distorted ones.

My understanding of the undistorted co-ordinates is that it is a mapping of every undistorted co-ordinate to a distorted one. Therefore, the ranges of both undistorted and distorted co-ordinates should be between (0-240, 0-180). However, going by the above formula, I get extremely high numbers for distorted co-ordinates if I input undistorted co-ordinates in the range(0-240, 0-180) which goes against this understanding. Have I done something wrong here?

• On Robotics we are fortunate enough to have MathJax support enabled, allowing you to easily create subscripts, superscripts, fractions, square roots, greek letters and more. This allows you to add both inline and block element mathematical expressions in robotics questions and answers. For a quick tutorial, take a look at How can I format mathematical expressions here, using MathJax? – Mark Booth Oct 16 '18 at 13:11

A quick sanity check indicates that there's something badly wrong with your distortion coefficients, they are just too big. Take a value of r=100 which is possible towards the edge of your image, $$k_1 r^2 \approx 1300$$ which is a massive shift. The $$k_2 r^4$$ term is of the order of millions.