Correcting Barrel Distortion
Helmut Dersch
Technical University Furtwangen
Updated July 14th 1999

The following examples demonstrate the use of my Photoshop/Gimp plug-in Panorama Tools to correct lens distortions. The most common and annoying lens error is barrel distortion, which occurs in many cheap wide angle lenses, especially in digital cameras or when using wide angle adapters. Straight lines are bent away from the center of the image: A rectangle looks like a barrel.  Correction of these distortions is performed by shifting each pixel radially. The displacement is calculated using a polynomial function, whose coefficients are specific to the particular lens. Once these coefficients have been determined, they can be reused for each image: In practice the images should be batch-converted to correct these errors. Panorama Tools employs a high-quality sampling algorithm with negligible image degradation, so no new errors are introduced during this process.

The following examples (left image) shows an image made with the Nikon Coolpix 950 using the wide angle lens (24mm equivalent, image courtasy Barry Hyman). In architectural images like this one, barrel distortions are particular noticeable. The corrected image to the right shows straight lines as we are used to.

 To perform these corrections you need an installation of Panorama Tools. Open your image, select 'Panorama Tools' and 'Correct'. Click 'Radial Shift' and enter these options: a=0; b=0; c=-0.075; d=1.1. Use the same values for all colors. Please note that the correct values may be different for your lens, even if you also have the Nikon CoolPix. They were determined using the tiny images above, and should be refined on larger images.

The next example shows a scanned image made with a Zoom lens and 35mm equipment (Vivitar 28-80mm, Olympus OM1). These lenses often exhibit barrel distortions in the wide angle settings, although it usually is significantly smaller than in the example above. Still, it can be quite annoying when making enlargements. To show the effect on the screen, I have enlarged a part (right edge of the building) and inserted a straight line. Clearly, a slight curvature can be observed. (Left image below). If you can't see it on the screen (it is scaled down inside the browser), I recommend to download it and display it in a graphic viewer. The right image is an enlargement of the corrected image, using the parameters: a=0;b=0;c=-0.02;d=1.02.  The correction always has to be performed on the entire image. Correcting just a portion does not work.



How to determine suitable Parameters:

The correcting function is a third order polynomial. It relates the distance of a pixel from the center of the source image (rsrc) to the corresponding distance in the corrected image (rdest) :

rsrc = ( a * rdest3 + b * rdest2 + c * rdest + d ) * rdest
The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center. This counteracts barrel distortion, and is the basis for the above corrections. Using positive values shifts distant points towards the center. This counteracts pincussion distortions. Correcting using 'a' affects only the outermost pixels of the image,  while 'b' correction is more uniform. Finally, you may correct pincussion and barrel distortions in the same image: If the outer regions exhibit barrel distortions, and the inner parts pincussion, you should use negative 'a' and positive 'b' values. If you do not want to scale the image, you should set d so that a +b + c + d = 1.

In most cases, you will get quite satisfactory results by using just one parameter, like the 'b'-parameter in the above examples. These examples may also serve as a guide to how large these values should be, ie around 0.1 if the distortion is quite visible, or around 0.01 if it is very small. Simply optimize this starting value until you like your image.

Some additional Notes:


Copyright ©; H. Dersch 1999