Straightening Images in Photoshop -- Part I

Article and Photography by Ron Bigelow

Photoshop CS or Photoshop CS2 Used in this Tutorial

One of the first things that we teach novice photographers is to make sure the camera is level. That said, even the best of use sometimes make mistakes. We get home only to discover that one of our favorite shots is slanted. Luckily, the problem is quick and easy to fix -- but not without a cost.

Prevention is the Best Cure

Prevention is usually better and easier than a cure. This is the case with straightening images. Straightening images is a two step process. First, the photo is rotated to level the image. Second, the image is cropped so that the image will again be rectangular. Both of these tasks create their own problems.

Rotating the Image: When an image is rotated, Photoshop has to figure out the new color value at each pixel. It does this by interpolation. Any time interpolation is used, some degree of image degradation occurs. So, the image quality of the rotated image will not be as good as the original image. This is true for all rotations except for 90o and 180o rotations (90o and 180o rotations do not use interpolation).

Cropping: Cropping is a double whammy. First, anytime an image is cropped, pixels are thrown away. Thus, for any given size print, there are fewer pixels (i.e., less data) to spread across the print. This will result in lower image quality. Second, cropping changes the composition of the image. Most experienced photographers tend to fill the viewfinder with the image. In other words, they know what they want and they compose accordingly. They do not leave a lot of extra space along the edges. This results in the highest quality image. However, if the image is subsequently cropped, the composition could be destroyed. Some important object toward the edges could get cropped out of the image or get cut off in the middle.

Figure 1: Bubble Level

Therefore, whenever possible, one should attempt to ensure that the camera is level before the image is taken. Luckily, this very easy and relatively cheap. The solution is a bubble level. Shown in Figure 1, a bubble level is essentially a carpenter's level redesigned for a camera. It fits into the hot shoe of the camera (there are also models that mount onto the tripod, but they only guarantee that the tripod is level, not necessarily the camera). These levels work extremely well. There have been times when I was convinced that there was something wrong with my level because the level's reading conflicted with my own appraisal of the situation. However, the level has always been correct.


Figure 2: Preferences Dialog Box

In order to straighten an image, the image must be rotated. As mentioned above, rotating an image requires the image to be interpolated. Thus, it is desirable that the best interpolation algorithm available be used. The interpolation method is set by choosing Edit/Preferences/General. The Preferences dialog box appears as shown in Figure 2. I recommend that the Image Interpolation be set to Bicubic or Bicubic Smoother. Clicking OK closes the dialog box.

Assessment of the Image

Figure 3: Image with a Horizon

Figure 3 shows an image with a horizon. The horizon appears to be tilted. However, it is better to get a more accurate evaluation. For this, a guide is used by choosing View/New Guide. The New Guide dialog box appears as shown in Figure 4

Figure 4: New Guide Dialog Box
For this image, a horizontal guide is required, so the Horizontal option is checked. Clicking OK closes the dialog box and places a guide at the top of the image (see Figure 5).
Figure 5: New Guide
Figure 6: Move Tool on Tools Palette
The guide needs to be moved down so that it can be aligned with the horizon. For this, the Move Tool is selected from the Tools palette (See Figure 6). The guide can then be grabbed with the Move Tool and moved to align with the horizon as shown in Figure 7.
Figure 7: Image with Guide
Figure 8: Horizon not Parallel with Guide
The problem is that, at this view, the image is too small to properly evaluate whether the horizon lines up with the guide. To better view the image, the image is enlarged. Now, Figure 8 shows that the horizon clearly does not line up with the guide. The image will need to be rotated to level the horizon. At this point, the guide can be moved out of the way or removed by choosing View/Clear Guides.

Straightening the Image: Measure Tool

Figure 9: Measure Tool in Tools Palette

The Measure Tool can be used to level the image. The Measure Tool is selected from the Tools palette as shown in Figure 9. The Measure Tool is then used to draw a line along the horizon (see Figure 10).

Figure 10: Image with Measure Tool Line
Figure 11: Rotate Canvas Dialog Box
Next, the image is rotated by choosing Image/Rotate Canvas/Arbitrary. The Rotate Canvas dialog box appears as in Figure 11. The proper settings are already established in the dialog box (the settings came from the Measure Tool). Clicking Ok closes the dialog box and rotates the image.
Figure 12: Rotated Image Close-up
Figure 12 (a close-up view) shows that the image now has a straight horizon. That is the good news. However, when the image is seen at normal size, (see Figure 13) the bad news becomes evident. The edges of the image are now angled. The image needs to be cropped.
Figure 13: Rotated Image at Normal View
Figure 14: Rectangular Marquee Tool in Tools Palette

To crop the image, the Rectangular Marquee tool is chosen from the Tools palette (see Figure 14). Once the Rectangular Marquee tool is selected, the Rectangular Marquee Tool options will appear in the Options bar (see Figure 15). In the Options bar, the New Selection option is chosen, Feather is set to zero, and anti-alias is unchecked. Three options exist for style.

Normal: Allows any size of rectangular shaped selection.

Fixed Aspect Ratio: Confines the shape of the selection to a rectangle that has a specified width-to-height ratio.

Fixed Size: Confines both the size and shape of the selection to a rectangle of a specified width and height.

For this image, it is important to keep the original 1.5 width-to-height ratio. Thus, the Fixed Aspect Ratio option is chosen. The Width is set to 1.5 and the height is set to 1.0.

Figure 15: Rectangular Marquee Tool Options in Options Bar
Figure 16: Selection Drawn with the Rectangular Marquee Tool
A selection is now drawn on the image with the Rectangular Marquee tool as shown in Figure 16. The selection is carefully drawn to get the maximum amount of the image without including any of the non-image area.
Figure 17: Image with a Straight Horizon
The final step is to perform the actual cropping of the image by choosing Image/Crop. The final image is shown in Figure 17.

Straightening the Image: Lens Correction

Another method of straightening images is the Lens Correction filter. An advantage of the Lens Correction filter is that it allows the image to be rotated and cropped all in one action. A word of warning before you start: I suggest that you perform this method only on images that do not have multiple layers. If an image already has layers, the image should be flattened before this technique is used. Using this technique on images that have layers is likely to produce a ghosting effect around objects.

Figure 18: Another Image with a Horizon Problem

Figure 18 shows another image with a slanted horizon. To correct this problem, the Lens Correction Filter is launched by choosing Filter/Distort/Lens Correction. The Lens Correction dialog box appears as shown in Figure 19.

Figure 19: Lens Correction Dialog Box
Figure 20: Close-up Reveals the tilted Horizon

Selecting the Zoom tool and clicking on the image enlarges the image. The grid allows the horizon to be checked to determine if it is level. Figure 20 shows a close-up of the image that shows the tilted horizon.

To prepare for straightening the image, the grid is removed for easier viewing by unchecking Show Grid, and the Edge is set to Transparency. The Straighten Tool is chosen from the dialog box and is used to draw a line along the horizon (see Figure 21).

Figure 21: Applying the Straighten Tool
As soon as the Straighten tool is released, the image is rotated. Moving the Zoom tool back to the Fit in View option (right click to reveal the option) reveals the rotated image (see Figure 22). A problem immediately becomes apparent: the edges of the image are angled revealing blank space along some of the edges. This is easily remedied.
Figure 22: Rotated Image
As seen in Figure 23, moving the scale slider to 103% (for this image; other images will require a different setting) enlarges the image and crops out the blank space along the edges. Clicking OK closes the dialog box and reveals the corrected image (see Figure 24).
Figure 23: Scale Adjustment Made
Figure 24: Corrected Image
The biggest advantage of the Lens Correction filter is that it allows several corrections to be performed at the same time. While beyond the scope of this article, this filter will correct barrel distortion, pincushion distortion, vignetting, perspective, and chromatic aberration.


Straighten Part II