Correcting lens distortion with Photoshop.

Correcting Lens Distortion

Photo Retouching Tutorials

Correcting Lens Distortion | Adding Motion Blur | Radial Blur | Adding Bokeh | Lighting Correction | Color Correction

All Tutorial Text & Images - Copyright © 2011 KHI, Inc.

Keystoning Lens Distortion Correction

The term "keystoning" (aka "keystone effect") refers to a form of lens distortion that is a phenomenon associated with wide-angle lenses, and is caused by the effects of three-dimensional angle of view. This is caused by having the camera tilted slightly upward or downward rather than level to the horizon. This tutorial is designed to instruct on the use of Photoshop's 'Free Transform' tool (CS and older), or the Photoshop CS2 CS5 'Remove Distortion Tool' (D) dialogue box to correct lens distortion in photos taken with a wide-angle lens. Keystone distortion should not be confused with "barrel distortion" which is another form of spherical lens distortion that is inherent to wide-angle lenses, causing the extreme outer-edges of the photo to bow.

The problem with correcting lens distortion in Photoshop is that you are using a two-dimensional solution for a three-dimensional problem. Each time you make a correction to a specific axis such as the vertical lines within a photograph, you worsen the effect on its horizontal axis lines. The keystone effect gives the subject a 'falling over backwards' appearance that is a natural consequence of the basic laws of perspective, but perspective is rarely diminishing to a single vanishing point. The perspective in a photograph is typically converging in 2-point perspective, or 3-point perspective, making it difficult to correct.

Although the automated 'Lens Correction' filter's algorithm used by Photoshop CS2 and CS5 will correct barrel distortion and keystoning, care should be used to assure that you are not fixing one problem by exaggerating another.

Lens Distortion in Wide Angle Photography

Lens distortion, barrel distortion, or a keystone effect is inherent in all wide angle photography - film and digital, especially with lower-quality wide angle lenses in the 35mm and under category. Lens distortion is especially noticeable in architectural photography, where you have a lot of parallel and perpendicular lines.

Perspective Lens Distortion in Photos

Generally, the wider the field of view, the more the lens distortion. Wide-angle zoom lenses will generally suffer more from this phenomenon than a prime lens would, and only super-expensive ultra-wide-angle zoom lenses such as the new Nikon 14-24mm f 2.8G, Nikon 24-70mm f 2.8G, or Canon EF 16-35mm f/2.8L II USM will reduce the amount of distortion to acceptable levels. Nikon makes a 35mm f/2.8 PC or "Perspective Control" lens, but this lens is VERY limited in the amount of correction it can achieve.

Each wide-angle prime lens or wide-angle zoom lens has its own unique distortion signature that requires varying types of correction and repair.

Manually Removing Lens Keystone Distortion

In the absence of any significant "barrel distortion," the keystone effect is a relatively easy to fix "first-order" linear-distortion. By using Photoshop's Free Transform Tool, You can easily correct vertical lines that converge to a central zenith if you are looking up, or nadir if you are looking downward.

Lens Distortion Keystone Correction

It is helpful to create some vertical guide lines by using the View > Rulers command in the menu bar, and dragging a couple of vertical Guide Lines from the vertical ruler on the left side of the window. Set a contrasting Guides color in the Preferences menu under 'Guides, Grid, & Slices."

After you have made corrections to the vertical lines by stretching the top of the photo you now must also stretch the photo vertically to compensate for the widening that was necessary to fix the verticals.

Technical Note: By making these keystone corrections you will loose some of the photograph's left and right side information. If you are loosing sky, it is easy to use the Clone Stamp Tool, or simply copy and paste more sky in.

Manually Removing Lens Barrel Distortion

Barrel distortion is caused by wide angle lenses curves both horizontal and vertical lines around a central axis point giving a "barrel" effect to the photograph.

Lens Barrel Distortion Correction

In Photoshop CS you would use the 'Spherize' filter located in the menu at the top of the screen under Filter > Distort > Spherize. You will use a negative value to "pinch" the image at the center vertically and horizontally (when set to "Normal"). It is helpful to enlarge the Canvas size of the image by around 25% or more, using Image > Canvas Size..." in the top menu. Without this step, the filter may produce undesirable results, or crash the program.

Removing Lens Distortion in CS2 and CS5

In CS2 or later, the correction filter is located in the menu at the top of the screen under Filter > Distort > Lens Correction. Use the filter's grid overlay for a visual cue on how much distortion to apply - generally in the range of +1.00 to +6.00, or -1.00 to -4.00. The greater the correction, the higher the degree of undesirable results. You can use the slider to make corrections, or type a value in the 'Remove Distortion' box.

The first step is to straighten the image horizontally, using the Straighten Tool located on the left-side of the Lens Correction dialog box. Using the Remove Distortion Tool (D), click and drag across a curved horizontal line in the image to define a new horizon line, attempting to follow an existing horizon line in your photo.

Lens Distortion Correction Filter

As you make your horizontal and vertical corrections you can counteract any diagonal distortion by changing the Angle value. You can also remove any unwanted barrel distortion by adjusting the 'Remove Distortion' slider to the left towards 'bulge out,' or to the right towards "pinch in."

The last step will be to determine what happens in the areas that fall outside the new parallaxed image by using the Edge option. You can choose from three possibilities: Background Color: Fills the outside zone with pixels from the current background color, Edge Extension: Stretches edge pixels to fill the background (avoid), or Transparency: Which creates a transparent zone outside of the distorted image. It really doesn't matter which one of these you choose, as the best solution is to create a new Crop, or do some very fancy cloning and retouching.

There are also after-market third-party programs such as DxO Labs' DxO Optics Pro software, or a free-ware after-market Photoshop plug-in called "Panorama Tools."

Technical Note: A final point of concern may be that any of these lens distortion correction procedures will add some blurriness to the image as the software reinterprets or interpolates the pixel data. Note: The following hardware and software was used in this tutorial: An Apple Mac Pro desktop computer, a Wacom Intuos 6x8 drawing tablet, Adobe Photoshop CS-CS5 photo editing software and a properly calibrated monitor.

Back to: Illustration Tutorials

Copyright © 1996-2012 KHI, Inc. and All rights reserved.