Correcting Keystoning In Photoshop

Perspective Correction In Photoshop - Keystoning

Learn Photoshop with Photo Editing Tutorials at Photoshop Essentials.com!

Written By Steve Patterson

Have you ever tried taking a photo of a building only to have the building look like it's leaning backwards? That's a perspective problem known as keystoning, and it's caused by the building and the camera lens being on two different angles. Usually, unless you're fond of climbing trees or you have a friend at the fire department, standing on the ground and tilting the camera back a bit is the only way to get the top of a tall building into the photo, and since the camera is tilted away from the building when you snap the image, with the top of the lens being further away from it than the bottom of the lens, the building ends up looking like its leaning backwards. This problem actually exists any time you need to tilt the camera back to get something tall into the photo but it's most noticeable with buildings due to their straight parallel sides.

Keystoning can sometimes be a desirable effect since it can add a real sense of drama to the image. However, there are times when you'll wish there was some way to correct this perspective problem, and Photoshop gives us a few different ways to go about it. Up until recently, we had a choice of using either the Crop Tool or the Free Transform command, but in Photoshop CS2, Adobe introduced the powerful Lens Correction filter which quickly replaced those other two methods as the fastest and easiest way to correct keystoning. We'll look at how to use the Lens Correction filter in this tutorial. I'll be using Photoshop CS4 here, but any version of Photoshop from CS2 on up will work.

Here's the photo I'll be using. Notice how the building appears to be leaning backwards with the sides tilted inward rather than being parallel to each other as they should be:

A photo suffering from keystoning in Photoshop. Image © 2009 Steve Patterson.
The original image with the building appearing to lean backwards.

Here's how it will look when we're done:

Repairing keystoning in Photoshop. Image © 2009 Photoshop Essentials.com
The final result.

Let's get started!

Want an easier way to follow along with our tutorials? Download them as printable PDFs!

Step 1: Duplicate The Background Layer

Before we do anything else, we should first make a copy of the original image which is sitting on the Background layer in the Layers palette. This is to avoid doing any damage to the original in case we need it later. To duplicate the Background layer, go up to the Layer menu at the top of the screen, choose New and then choose Layer via Copy. Or, to save time, simply use the handy keyboard shortcut Ctrl+J (Win) / Command+J (Mac). Either way tells Photoshop to make a copy of the Background layer for us, and if we look in the Layers palette, we can see that we now have two layers. The original Background layer is on the bottom, and a copy of the layer, which Photoshop automatically named "Layer 1", is sitting directly above it:

The Layers palette in Photoshop CS4. Image © 2009 Photoshop Essentials.com.
Duplicate the Background layer to avoid damaging the original image.

Step 2: Open The Lens Correction Filter

Now that we're working on a copy of the image, let's bring up the Lens Correction filter by going up to the Filter menu at the top of the screen, choosing Distort and then choosing Lens Correction:

Selecting the Lens Correction filter from the Filter menu in Photoshop. Image © 2009 Photoshop Essentials.com.
Go to Filter > Distort > Lens Correction.

Step 3: Straighten The Image If Needed

Photoshop's large Lens Correction dialog box appears, with a few tools along the left, a large preview area in the middle and several options for correcting lens problems along the right. Before we fix our keystoning problem, we should take care of a couple of other potential problems first which will the make it easier for us to fix the keystoning. To start with, let's make sure the image is straight. We can do that using the Straighten Tool, which is the second tool from the top on the left side of the dialog box. Click on it to select it. Then simply click and drag across something in the image that should be straight, either horizontally or vertically. I'm going to click across the roof on the left side of the building in my photo. When you release your mouse button, Photoshop will rotate the image inside the preview area to straighten it (assuming it was crooked). If you find that the grid is making it difficult to see what you're doing, you can turn it off temporarily by unchecking the Show Grid option at the bottom of the dialog box:

Straightening the image in the Lens Correction dialog box in Photoshop. Image © 2009 Photoshop Essentials.com.
Click and drag with the Straighten Tool across something in the image that should be straight.

If you need to zoom in on the image, press Ctrl++ (Win) / Command++ (Mac), or to zoom out, press Ctrl+- (Win) / Command+- (Mac). If, while zoomed in, you need to move the image around inside the preview area, simply hold down your spacebar which gives you temporary access to the Hand Tool, then click and drag the image to move it.

Step 4: Fix Any Barrel Or Pincushion Distortion

Sometimes a photo can suffer from what's called barrel distortion where the image appears to bulge out from its center as if it's being wrapped around a sphere, or from pincushion distortion, the exact opposite problem where it appears to be pinched in towards the center. Not all images have one of these problems but if yours does, it's best to correct it before attempting to fix the keystoning. There's a couple of different ways to do this. One is to click on the Remove Distortion Tool, which is the top tool on the left of the dialog box, then simply click and drag inside the image with your mouse. Drag towards the center of the image to correct any barrel distortion, or drag away from the center to correct any pincushioning:

Selecting the Remove Distortion Tool in the Lens Correction dialog box. Image © 2009 Photoshop Essentials.com.
Click on the Remove Distortion Tool, then click and drag inside the image to remove barrelling or pincushioning if needed.

You can accomplish the same thing with the Remove Distortion slider at the top of the column on the right. Drag the slider towards the left to correct pincushioning, or drag it to the right to correct barrelling. Regardless of the method you choose, make sure you don't drag too far otherwise you'll end up causing the opposite problem that you're correcting. You'll probably find the grid helpful when trying to fix these problems, so check the Show Grid option at the bottom of the dialog box to turn it back on if you turned it off in the previous step:

The Remove Distortion slider in the Lens Correction dialog box in Photoshop CS4. Image © 2009 Photoshop Essentials.com.
Drag the Remove Distortion slider towards the left to correct pincushioning or the right to correct barrelling.

If you've gone too far and need to reset the image, just enter value of 0 into the Remove Distortion input box directly above the slider.

Now that we've made sure the image is straight and we've removed any distortion, let's fix our keystoning problem. We'll do that next!

Still scrolling through web pages? Download our Photoshop tutorials as print-ready PDFs!

Go to page: 1 | 2