Distortion

Overview

In photography there can be distortion either due to the camera itself, or due to objects between the camera and the subject, such as a window. In order to know if a detail in a photo, such as a line being curve, is real it's helpful to know what distortion is likely. For example, consider his photo from the horizon page, from flight 1970 from Austin to Baltimore at 2018-12-25 6:50:45 CST. It was early enough to capture the sunrise:

From the red (straight line) and green (center of the photo) markings the horizon appears to be curved, but is it really curved, or is it distortion? Here's the original image without the red and green markings. The horizon is 25 pixels higher in he center than at the edges, a value that will be compare to other photos.

For each photo it's possible to see a larger version by clicking.

Camera

It's possible to see if a camera adds distortion by taking a picture of a test grid. There are many ways of creating a test grid, but I wrote a small Python program named drawgrid.py, which can be found in the image-utils project. The following photos are of this grid image produced by drawgrid.py. The grid image was displayed full screen via Firefox on a MacBook Pro and then photographed with a Pixel 2 XL, which is the camera used for most of the photos on this page.

This photo was taken with the camera right side up (original image here):

There appears to be very little distortion, perhaps not even a pixel, at the center of the image. To test for the possibility that the screen was warped in the same way and amount as the camera was distorted I took another photo with the camera upside down (original image here):

Again, there is a negligible amount of distortion (at least in terms of how curved the center line is, which is relevant to this page). Since the Pixel 2 XL orients the image without noting the original camera orientation in the EXIF data the orientation should be noted manually.

For comparison some pictures taken with a Nikon P900. This photo was taken with the camera right side up (original image here):

And upside down (original image here):

Since cameras have lenses it's important to note that distortion is minimized when viewing along the axis of the lens. Here's picture of the grid through such a lens on a pair of glasses (original image here):

Notice how straight the line is. However, if the glasses are slanted approximately 33° then it looks like this (original image here):

Both cameras seem to do reasonably well at the center of the image, which corresponds to light passing through the axis of the lens.

Blender

3D modeling programs like Blender can be used to better understand how lenses work. Here's a blender file that I created and an image that it requires:

It's possible to rotate the camera about the Z-axis so that it's pointed to one of the four glass items around the permitted. Here's a cylindrically curved piece of glass with constant thickness, which is on the right side:

And here's a spherically curved piece of glass with constant thickness, which is at the bottom:

It's possible to move either the glass items around, or the camera, and see the effect on the horizon. In all cases distortion to the horizon can be reduced by moving the line of sight closer to the axis of the lens.

Plane Window

It's possible to photograph the horizon from a airplane (see the first photo on this page), but in order to be certain that the curvature in the horizon is real, and not due to the window, the photos need to be analyzed carefully.

Here's a photo of the edge of the runway from flight 4552 from Houston to Austin at 2018-12-28 09:22:11 CST:

It's close to straight - the center is off by just 5 pixels. Since the window is angled up 12° and since the edge of the runway is 15° below the center of the image the crack is 27° below the window's optical axis. Since we expect there to be less distortion as we get closer to the window's axis the horizon should have less that 5 pixels of distortion.

Here's a photo of a crack on the runway also from flight 2126 from Houston to Austin at 2018-12-28 10:14:25 CST:

In this case the horizontal crack does deviates from the red line by 8 pixels, but it's even farther from the horizon, and therefore subject to greater distortion. Still the 8 pixels seen is still much less than the 25 seen in in photo of the horizon at the top of this page.

At X=1400 the deviation is only 4 pixels and at X=2700 it's 3 pixels. If it is a smooth circular or parabolic curve (they are both close for the range in question) then it should deviate 7 pixels at X=1400 and X=2700. It's a different kind of and much smaller curve. Here's the original image without the red and green markings.

The vertical crack seems to have about half the deviation, but it's less relevant.

What if due to either pressure change or due to the stress of flying the plane window is distorted differently at high altitude so that it causes the horizon to appear curved, but only when flying? One way of exploring this is to take pictures both at high altitude, and on the ground, and compare after carefully aligning them.

Since the distortion may be different in different parts of the window, and since we want the distortion to be constant, it's helpful if both the camera and the subject are in the same place for each photo. Fortunately the upper part of the window can be used as a guide:

It's a Pixel 2 XL, which was used to take every picture on this page other than this one.

I used the grid feature for the camera app for my Pixel XL in so that I could get the engine close to framed the same way each photo. Here's the plane engine on the ground from flight 4552 from Houston to Austin at 2018:12:28 09:22:11:

All photos of the plane engine are from the same flight. Here's the plane engine flying:

In order to see if one of the images has distortion that the other does not they the can be aligned using the perspective tool in the GIMP (an open source photo manipulation program). Here's a brief tutorial on the perspective tool. The perspective tool can be used transform an image of a plane from one vantage point to another, as shown in the tutorial. It can also be used to transform an image of a three dimensional object taken by the camera in one orientation to another orientation, which is whit is relevant to this page. The camera rotated slightly from one photo to the next.

The perspective tool maintains straight lines (if a line is straight it will continue to be straight after using the tool). In fact if a projection of a plane is mapped to another projection of a plane where straight lines are maintained the perspective tool can do the transformation.

Here's a result of copying a rectangular region that contains the flying engine from the photo above, and then pasting it onto the ground image, and then using the perspective tool to manipulate the copied region so that it matches the ground image:

The above lines up nicely with the original ground image, each point being within 5 pixels or so. But what if there is distortion with altitude, and what if it would align even better if that distortion could be removed?

GIMP has the has a "curve bend" distortion tool that can be used to bend a photo based on a curve specified by the user. The curve can be saved in a points files. I've created one points file that will cause the horizon to be curved when it is straight, and the opposite points file that will remove curvature from a curved horizon. Here's the later applied to the curved horizon photo:

Here's the original image without the red and green markings. Clicking on the image reveals a white strip on the top part of the image due to the middle of the image being pushed down, and then replaced with the background color (white). Likewise with white strips in the lower corners.

If the curve in the horizon is really due to distortion that is caused by altitude then applying the same points file to the flying engine to remove that distortion should make it match the ground engine even better. Here's the flying engine with the same curve removing points file applied:

And here's the result of performing the same exercise with the perspective tool. It seems to be a sightly worse match in the way you'd expect (the center of the flying engine image being too low in the center):

Here's the perspective matrix used in case you want to compare notes.

Conclusion

It's possible that plane windows curve a small amount, but not nearly enough to explain the curvature in horizon. Also, there is no good reason to believe that the distortion depends on altitude.