PANORAMA TOOLS - PTGUI TUTORIAL
HOW TO STRAIGHTEN HORIZONS AND CORRECT VERTICALS

(See also the more recent tutorial here )

Are your panoramas spoilt by wavy horizons or converging verticals? This tutorial will show you how t1 and t2 control points can be used with the optimizer to correct distortions that are the result of camera tilt (deliberate or accidental) when taking the original photographs. It is assumed that you have the basic knowledge to run PTGui and Panorama Tools to stitch images together (see links below).

It should be clearly understood that curved horizons and converging verticals are two sides of the same coin. Correct converging verticals and you automatically correct the curved horizon, and vice versa. In a properly corrected image, the horizon will lie along the line representing pitch= 0 degrees, dividing the output area into two equal halves.

NB.  PTAssembler users will find much of what follows generally applicable, but they should take care to avoid using the Auto-Optimize button after adding t1 and/or t2 points since the default optimize operations that this invokes includes an "equalize roll" operation that is counter productive. (You can, of course customise the Auto-Optimize operations to avoid this problem).

STRAIGHTENING HORIZONS USING t2 CONTROL POINTS

SAMPLE IMAGES

Here, the horizon is positioned well below the centre of the frame, which indicates that the camera was pointed upwards for all of the shots. (This was deliberate, because the sky was the subject. I wanted an interesting sky to insert into a panorama that had a blank, boring one).

PTGUI - INITIAL STITCH

An initial trial stitch was made (cylindrical projection), having specified pitch and roll values of 0 degrees for all the images, and optimized with image 2 anchored. The result was, as expected, a badly curved horizon:

The horizon can be straightened by specifying the correct pitch values for all the images instead of 0. However, if the true angle of pitch is not known, the optimizer can be used to work it out. Put t2 control points along the horizon and allow the optimizer to try different values of pitch in order to bring the points level with each other.


ADDING CONTROL POINTS TO IDENTIFY THE HORIZON

When the t2 parameter is added to control point lines in the project script, only the Y coordinates will be taken into account when the optimizer tries to align those points. The X values are completely ignored. (Likewise, the t1 parameter ignores the y values and can be used to correct vertical features). The pair of control points may reside in the same or different images. So all you have to do is set pairs of control points along the horizon in some of the images. The two points of a pair can be placed on the same or different images. Remember, the control points are NOT assigned on identical features but on features that are presumed to be on the same horizontal level.

At the bottom of the Control Points tab is the alignment selection menu. You need to select "Horizontal line" before you click on the two horizontal features. This will have the effect of adding "t2" to the end of the control point line in the project script.

After adding a few sets of points, click on the optimizer tab and set parameters to optimize for yaw, pitch and roll for all images, except yaw on the anchored image.  (NB. Recent versions of PTGui offer a selection of optimizers to use.  The PTGui optimizer in versions prior to V7 does not support t1,t2,tn points, so you may need to select the Panorama Tools optimizer)

 

After running the optimizer, clicking the Image Parameters tab will reveal the new pitch and roll values, and here indicates that the camera was tilted upwards by 16 degrees or so.

A final stitch now gives a much improved horizon:

 

CORRECTING SLOPING VERTICALS WITH t1 CONTROL POINTS

t1 points are used in exactly the same way as the t2 points except that the points are placed on features that should be vertically aligned, like edges of doors, windows and buildings etc. You can use t1 and t2 points together in a panorama or a single image. This picture is a single image taken with a camera tilted slightly upwards, which has resulted in a rather obvious tilt to the lamp post.

The technique for applying the t1 parameters is exactly the same as in the horizon example above. The difference is in the control points that are set. I identified two vertical features that I believed to be truly vertical. These are the tower on the left and the lamp post on the right of the picture. (Casual observation shows that street lamposts are not always vertical, but this one is). The first pair of flags I positioned on the top and bottom of the side of the tower, and other pair were positioned centrally on the stem of the lamp.  Before clicking on these features, "CP type" was set to "Vertical line ( | t1)".

Then optimizer was then run for pitch and roll, keeping yaw fixed.

The Panorama Editor window then showed a nicely corrected image.  It has moved upwards in the output area so that the horizon is centrally placed in the frame, leaving some blank space at the bottom, which will have to be cropped away.  This is quite normal and there's no way of avoiding it.

So the final image looks like this:

Correcting the verticals in a panorama (cylindrical projection) is just the same,  You should first optimize the images as usual.  Then add 3 or 4 pairs of t1 control points on vertical features spread over the width of the panorama.  Then optimize y,p,r on all images, except for yaw on the anchor image.  The images will then float into the optimum position.

LINKS

Panorama Tools http://www.all-in-one.ee/~dersch/
PTGui
http://www.ptgui.com
How to use Panorama Tools and PTGui to produce a printable panorama
http://homepage.ntlworld.com/j.houghton/pttute.htm

Written by John Houghton
September, 2001 (amended 4 May 2009)
Email: j.houghton@ntlworld.com