Barrel Distortion Correction

Background

Barrel distortion occurs when the magnification at the center of the lens is greater than at the edges. Fish eye lenses, which take hemispherical views, produce this type of distortion as a result of a hemispherical scene being projected onto a flat surface.

Most commonly, barrel distortion appears when using zoom lenses. This is even more common for lenses with large zoom ranges, or wide angle zoom lenses.

Two types of distortion you will see are barrel and pincushion. Barrel distortion has a “bulging” effect, while pincushion distortion is a “sucking” effect that distorts images in an inward sense. Barrel distortion is like wrapping your image around a ball. If you look at it straight on, the center will be bulged out. Pincushion is like pressing your image into a bowl. If you look directly into the bowl, the center will look squeezed.

A higher quality lens can be used to correct for distortion; however, this will greatly rise the cost of the image capture system. A cost effective alternative to an expensive lens system is to algorithmically correct for barrel distortion using the presented method.

Barrel distortion is primarily radial in nature, therefore it can be corrected using a relatively simple model compensating for the most of the distortion.

The correcting function M(a,b,c,d,r_corr) is a third order polynomial. It relates the distance of a pixel from the center of the source image (r_src) to the corresponding distance in the corrected image (r_corr):

Equation 1

M = a *r3_corr + b * r2_corr + c * r_corr + d

and

r_src = (a * r3_corr + b * r2_corr + c * r_corr + d) * r_corr

Where r_src and r_corr are specified in units of the min((xDim-1)/2, (yDim-1)/2).

Parameters in equation 1 are as follows:

Correcting using a affects only the outermost pixels of the image, while b correction is more uniform. Using negative values for a, b, and c shifts distant points away from the center. This counteracts barrel distortion, and forms the basis for the above corrections.

Using positive values for a, b, and c shifts distant points towards the center. This counteracts pincushion distortion which is opposite to barrel distortion. See Figure 2.

Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d values scales the image by that amount. See Figure 2.

Correcting pincushion and/or barrel distortion

Finally, you may correct pincushion and barrel distortions simultaneously in the same image: if the outer regions exhibit barrel distortion, and the inner parts pincushion, 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.

Image types

The algorithm can be applied to RGB and gray 2D images.

Barrel Distortion Correction dialog box

The Barrel/Pincushion Distortion Correction dialog box

Applying barrel distortion correction algorithm

The corrected image appears in a new image frame.