The requirement to remove keystone or horizon tilt artifacts happens all too often. This opportunity arises in landscape, architectural, and social event photography. The Lightroom transform panel can handle 95% or so of the challenges. The remainder can be handled by backing up further, a wider zoom, paying closer attention to the horizon and verticals, or Photoshop. This tutorial is the Photoshop technique.

This is the original image. It is not an interesting image. It should be trashed. But it is the first image I found to illustrate this technique.

Below is the result when the Lightroom "Auto" transform was applied. The top is gone.

Below is the result when the Lightroom "Vertical" transform was applied. The verticals aren't vertical. The horizontals aren't horizontal. While it could be cropped, it would not be a pleasing composition.

Totally frustrating. Many times we need to use more agressive tools!

Here is the image in photoshop. This is the result of the "PrepareLens" action. This is one of the first actions I created because this problem happens a lot! The first step lifts the background layer to a separate layer. The second step increases the canvas size by 140%. Sometimes the width needs to be increased even more or the scale in the lens correction filter needs to be reduced.

This is the result after the "Lens Correction" filter shown below.

Below is the result in the lens correction filter. The axis was tilted to vertical and the lines in the building are now vertical. To apply a reasonable crop the triangle on the sides need to be filled and the white on top trimmed. We could reduce the scale of the image or expand the canvas width to include the cropped side. With severe keystoning the filter needs to be applied twice.

The second image below is the result after the "Load&SmartFill" action is applied. There are several steps.

  1. The basic "Edit / Trim" command is applied
  2. Remove any lingering selections (cntrl-D)
  3. "Select / Load Selection" with invert top select just the transparent pixels
  4. This step is critical to avoid pesky lines after the smart fill. The options in the "Select / Select & Mask" are all zero except:
    1. feather about 2 pixels. A slight feather seems to help with the next step
    2. Shift the edge into the image away from the transparent area! With this there are no transparent pixels to create those pesky lines.
  5. Use "Edit / Fill /Smart Fill"
  6. Clear the selection and finish as desired

Below are the settings for the Content Aware Fill

Sometime the fill doesn't behave as desired. In that case, various combinations of clone stamp, healing brushes and content aware patch tools can minimize the issues.

Below is the final result. This is a 2 / 3 crop.