# What is the “tangential” distortion of OpenCV actually tangential to?

I'm having a hard time understanding the distortion model of OpenCV. They use "radial" coefficients $k_n$ and "tangential" coefficients $p_n$ among others that I am not interested in.

$$x' = x (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + 2 p_1 x y + p_2(r^2 + 2 x^2) \\ y' = y (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) + p_1 (r^2 + 2 y^2) + 2 p_2 x y$$

To understand this, I separated the two terms into what $\Delta$ offset they produce, here's how that looks for $x$:

$$\begin{array}{rlcccc} x' &= x &+ &\underbrace{x(k_1 r^2 + k_2 r^4 + k_3 r^6)} &+ &\underbrace{2 p_1 x y + p_2(r^2 + 2 x^2)}\\ &= x &+ &\Delta x_{radial} &+ &\Delta x_{tangential} \end{array}$$

Then I plotted those values as a vector field with octave (similar to Matlab).

function radialDistortion (k1, k2, k3)
max = 10;
[x, y] = meshgrid(-max:.5:max);
r2 = x.**2 + y.**2;
k = k1*r2 .+ k2*r2.**2 .+ k3*r2.**3;
quiver(x, y, x.*k, y.*k, 0);
axis("square");
endfunction


Called with

radialDistortion(0.0002, 0, 0)


produces the following

I get it, this is radial to the optical axis, thus being point symmetric to the center (where the optical axis is). This wasn't too difficult.

## Tangential Distortion

function tangentialDistortion (p1, p2)
max = 10;
[x, y] = meshgrid(-max:.5:max);
r = x.**2 + y.**2;
xy = x.*y*2;
quiver(x, y, xy*p1 + (r+2*x.**2)*p2, xy*p2  + (r+2*y.**2)*p1, 0);
axis("square");
endfunction


Called with

 tangentialDistortion(-.0007, .0007)


produces this

How is this "tangential" to anything? To me, it looks like it is correcting for a lens that's tilted (rotated around the bottom-left-to-top-right diagonal) which agrees with the reason for this distortion given in the literature: lens misalignment.

Does that mean it's tangential to the surface of the lens?

In the end, it's some mathematical model that describes some optical phenomenon in order to correct it. But I'd like to understand why this is called "tangential".

If the position of P' is also displaced tangentially relative to CP (along the tangent to the circle of radius CP), the distortion is said to be tangential.

No, it isn't. I modified the above function to show the "tangential" displacement of points that are on a circle.

function tangentialDistortionOnCircle (p1, p2)
r = x.**2 + y.**2;
xy = x.*y*2;
quiver(x, y, xy*p1 + (r+2*x.**2)*p2, xy*p2  + (r+2*y.**2)*p1, 0);
endfunction


Called with these parameters:

tangentialDistortionOnCircle(.007, .007)


gives this result

This doesn't look like a tangential displacement to me at all. If it was, it would look like a swirl around the center. But that's not the case.

Take the position of a point P on the image relative to the geometric image center C. Assume C remains undistorted in the lens produced image, but P is distorted into P'.

If the position of P' is only distorted radially along direction CP, the distortion is said to be radial.

If the position of P' is also displaced tangentially relative to CP (along the tangent to the circle of radius CP), the distortion is said to be tangential.

See for instance "Camera Calibration with Distortion Models and Accuracy Evaluation" (IEEE Transactions On Pattern Analysis And Machine Intelligence), especially Figs.2 & 3 (pg. 968) and Fig.4 (pg.969).

• Given the name "tangential" it makes sense to assume that it's tangential to some circle. But there's no such circle. the tangential displacement is not tangential to a circle, at least not to a circle around the image center. I updated my question with an example plot for points on a circle to illustrate this. – null Aug 18 '16 at 11:10
• "If the position of P' is also displaced tangentially relative to CP (along the tangent to the circle of radius CP), the distortion is said to be tangential": The displacements shown in your new fig. include the radial components. Remove them. What do you get? How does it compare to Fig.4 in the ref. cited? – udrv Aug 18 '16 at 18:00
• The displacements in my new figure (and the one before) show the tangential displacement only without the radial component. OpenCV calls $p_n$ the tangential coefficients and the plot shows the displacement that they are causing. As far as I can tell, if you look at the formula I quoted, there's no way to remove a purely radial component from this. Each coordinate is either quadratic or multiplied with the other coordinate, but radial distortion is a constant factor as can be seen in $\Delta_{radial}$ – null Aug 18 '16 at 20:21
• My bad wording: "The displacements shown in your new fig. include radial components." That is, they do not include radial terms in $k_i$, but obviously retain radial components, whatever the overall name. Remove those components by projecting on $\vec{e}_\phi = (-y/r, x/r)$: if $\Delta \vec{r} = (\Delta x_{tangential}, \Delta y_{tangential})$, then $(\Delta \vec{r} \cdot \vec{e}_\phi) \vec{e}_\phi = (-p_1 xy + p_2y^2, p_1x^2 -p_2 xy)$. You should retrieve something similar to Fig.4 in ref. – udrv Aug 19 '16 at 1:18
• So basically speaking, what they call tangential isn't really tangential? – null Aug 19 '16 at 12:14

The tangential distortion corrects for tilts of the image plane after radial distortion. Imagine subtle manufacturing flaws where the optical elements not aligned with the imaging plane. Tangential coefficients correct for this imperfection. This is why it seems like a rotation of the imaging plane. The net result of both radial and tangential warps should be a pinhole model which you can then apply classic intrinsics parameters to once you locate the principal point.

• Why can't you model such misalignment simply as a homography (which is linear in homogeneous coordinates)? Why use this complicated nonlinear distortion formula? (Let's ignore radial distortion for now and concentrate on the "tangential" distortion). – isarandi Nov 21 '19 at 17:23