Ponyboy's Web Pages Ponyboy's Web Pages Ponyboy's Web Pages
Home QTVR Images Links Resume Contact
QTVR Tips


PanoTools Introduction

Here's a complete walk-through of using PanoTools for the first time. This entire tutorial should take less than one hour to complete. This tutorial assumes that you've never used PanoTools before; but if you've tried it and haven't been successful, you may have better luck using this method. PanoTools is great freeware panoramic stitching and image correction software from Helmut Dersch (mirror). There are several shareware add-ons which improve upon it, but those won't be necessary for this tutorial.

Technically, this tutorial is more about PTPicker, which is the application used to set up a panorama session and define matching points between images. This is the primary way people now use PanoTools. In it's earlier days, PanoTools was a set of Photoshop plug-ins, and generally required creating a text file (called a script), which would contain all the parameters regarding perspective correction and image placement. Editing the script file can be confusing, and with PTPicker you really don't ever have to edit the file. However, this tutorial will involve some simple editing of the file to speed up the process.

Scenario

I've shot a complete 360° spherical multi-row panorama using a ultra-wide angle lens on a film camera (Sigma 14mm lens on a Nikon N90s), mounted on a spherical panohead (Kaidan QPS-1). This multi-row consists of 24 images in 3 rows.

12 images taken every 30° rotation, 0° pitch:

Middle Row of 12 Images

6 images taken every 60° rotation, +50° pitch:

Top Row of 6 Images

6 images taken every 60° rotation, -25° pitch:

Bottom Row of 6 Images

I've manually scanned the images. The images have all been cropped and resized to 340 x 512. No lens distortion corrections have been applied to these images. Download the images for this tutorial:

  • StuffIt file format for Macintosh (562 KB).
  • Zip file format for Windows (483 KB).


Installation

If you don't already have PanoTools, download and install from a mirror of Helmut Dersch's web site:

After installation, locate and run the primary application, "PTPicker". PTPicker employs a method of setting "control points" in multiple images and then performing the math necessary to determine where to place these images in a panorama. PanoTools contains other helper applications, such as "PTOptimizer" and "PTStitcher", which will run automatically from within PTPicker.

Preparation

With PTPicker running, you'll see the main screen, which consists of a standard file menu and a default project window. For now, the project window will appear as two white rectangles. These rectangles are where images of your project will appear. Generally you'll pick two images that overlap and set matching control points within both images.

PTPicker Main Screen

New Panorama Dialog Box

Let's create a new project for this multi-row. choose "New" from the File menu. In the "New Panorama" dialog box, you'll leave most of the fields at their defaults, and only need to enter the "Focal Length (mm)" and "Image Count". As listed above, this project consists of 24 images shot with a 14mm lens. Upon clicking "OK", you'll need to save the project file. I recommend saving it in the same folder as the images.

Now it's time to load in all the images. For a multi-row spherical panorama, I recommend that your first row of images be the row at 0° pitch, as this will help to make sure that your panorama will be level with the horizon. To load the images, simply go to either the "Left Image" or "Right Image" menu, and pick the default place holders "Image0" - "Image23". PTPicker doesn't support multiple image selections, so you'll have to do this one by one. If you make a mistake, you'll have to revert back to the lasted saved version of the file, so I'd recommend saving a few times during this process with 24 images. As you select images, you'll notice the default place holders change to the file names.

Control Points

After all the images have been loaded, you can begin setting control points. Start with selecting the first image "00.jpg" from the "Left Image" file menu, and choose the next image "01.jpg" from the "Right Image" file menu. Click inside of either window and set a control point. A corresponding control point will be placed in the other window at the exact same X & Y location. These points will be red, which means that they are the currently selected set of points. Position these points so that they appear over the exact same spot on both images. It's a good idea to stay within the middle of the images, and avoid the extreme edges because of lens distortion. Click and set another set of control points. Notice that the original set become green in color, which means that they appear in both images on screen. A third color is blue, and it is used for points that appear in only one of the images on screen. Pick points that are spaced far enough apart so that the upcoming Optimization process can determine your lens settings. Pick points by following the popular photographic technique "rule of thirds". Be careful not to choose points that are within the very center of the images, since there will not be very much mathematical difference. You want to choose your Control Points wisely. I picked the small roof detail just to the inside of the right tower above the parking garage (see image below), and for my other point, I chose the shadow detail from the guard rail on the sidewalk.

Control Points Example Control Points Example Control Points Example Control Points Example Control Points Example
Control Points Example Control Points Example Control Points Example Control Points Example Control Points Example
Control Points Example Control Points Example Control Points Example Control Points Example Control Points Example

After setting these two control points, save the project file and quit PTPicker.

Script File

Let's examine (and edit!) the project file. Open your favorite text editor and load the project file. PanoTools only uses a few types of lines in project files, all designated by the first character of the line. This file will currently have four types of line definitions:

  • p - Panorama
  • i - Input Image
  • v - Validation
  • c - Control Point

To quickly go over some of these lines:

The Panorama is a equirectangular (f2) with a width and height of 1500 x 750 pixels (w1500 h750). There will be a feather of 10 pixels on each stitch (u10), and the output file will be a Photoshop layered file (n"PSD_mask" -buf).

The Input images are similarly defined, the important settings are the yaw, pitch, roll, and horizontal field of view (y, p, r, and v). Notice that the first image sets the horizontal field of view (v81.2026), and all remaining images reference that first image (v=0). 81.2026 was calculated automatically from the 14mm focal length defined earlier in the New Panorama dialog box.

The Validation lines specify which settings should get optimized. Notice that the first image will only get the horizontal field of view optimized (v0), while all remaining images will get the yaw, pitch and roll optimized (y1 p1 r1, for example). As I mentioned earlier, all the remaining images were already set to reference the first image's horizontal field of view, so they too will automatically get that optimized as well.

Finally, the Control Point definitions specify references to the images (n1 N0), and then the x & y coordinated of the points in each image (x92 y171 X209 Y172). Basically, lowercase represents the left image, and uppercase represents the right image.

Look at the Input Image definitions and notice that the pitch and roll for all the images are set to 0, but the yaw for all images increases by 15°. PTPicker assumed that all our input images were in a single cylindrical row, and calculated that all 24 images represented a complete 360° panorama (24 x 15 = 360). Since this is not how the panorama was shot, we'll edit some of these settings to better describe our scenario, and give PTPicker a more accurate idea of our multi-row spherical. The first twelve images were taken 30° apart, at a pitch of 0°. The next six images were taken at 60° apart, at a pitch of +50°. The final six images were taken at 60° apart, at a pitch of -25°. Go ahead and manually edit the y and p settings for all 24 images to match this scenario.

if0w340h512y0p0r0v81.2026n"00.jpg"X0Y0Z0
if0w340h512y30p0r0v=0n"01.jpg"X1Y0Z0
if0w340h512y60p0r0v=0n"02.jpg"X2Y0Z0
if0w340h512y90p0r0v=0n"03.jpg"X3Y0Z0
if0w340h512y120p0r0v=0n"04.jpg"X4Y0Z0
if0w340h512y150p0r0v=0n"05.jpg"X5Y0Z0
if0w340h512y180p0r0v=0n"06.jpg"X6Y0Z0
if0w340h512y210p0r0v=0n"07.jpg"X7Y0Z0
if0w340h512y240p0r0v=0n"08.jpg"X8Y0Z0
if0w340h512y270p0r0v=0n"09.jpg"X9Y0Z0
if0w340h512y300p0r0v=0n"10.jpg"X10Y0Z0
if0w340h512y330p0r0v=0n"11.jpg"X11Y0Z0
if0w340h512y0p50r0v=0n"12.jpg"X12Y0Z0
if0w340h512y60p50r0v=0n"13.jpg"X13Y0Z0
if0w340h512y120p50r0v=0n"14.jpg"X14Y0Z0
if0w340h512y180p50r0v=0n"15.jpg"X15Y0Z0
if0w340h512y240p50r0v=0n"16.jpg"X16Y0Z0
if0w340h512y300p50r0v=0n"17.jpg"X17Y0Z0
if0w340h512y0p-25r0v=0n"18.jpg"X18Y0Z0
if0w340h512y60p-25r0v=0n"19.jpg"X19Y0Z0
if0w340h512y120p-25r0v=0n"20.jpg"X20Y0Z0
if0w340h512y180p-25r0v=0n"21.jpg"X21Y0Z0
if0w340h512y240p-25r0v=0n"22.jpg"X22Y0Z0
if0w340h512y300p-25r0v=0n"23.jpg"X23Y0Z0

Now that the input files more accurately match the way the images were captured, let's save this file, and exit the text editor. This is the only manual editing you'll have to do with PanoTools.

Optimizer

Open PTPicker and load the project file. With these much more accurate settings, it's time to run the Optimization process. From the "Project" file menu, choose "Optimizer". With only two control points, this process should be done very quickly, but you might notice a small progress dialog box.

After this process has finished, let's look at the project file to see what's changed. You can view the file within PTPicker by choosing "View Script" from the "Project" file menu. Scroll below the Control Points definition lines to see a whole new section created by the Optimization process:

# =======================================

# Output generated by Panorama Tools

You'll notice many lines that begin with the # symbol; these are just comments for you to read, and are completely ignored by the PanoTools applications.

You'll see a new definition line, the "o" Output Definition line. This line is very similar to an Input Image Definition line. There's an image format (f0), roll, pitch yaw and horizontal field of view (r0 p0 y0 v79.1502), and stitch feather (u10). The main difference between input and output definitions is that output definitions do not care about the image dimensions or file name. These lines just describe the position of this image. Basically, the Panorama and Output definition lines are all that the actual stitching process needs, and this section can become a reusable template for this particular setup. We are now done viewing the script, so you can close the script window.

Stitcher

With the optimization is complete, let's finally generate a panorama. Again from the "Project" file menu, choose "Stitcher". You'll be prompted to save the output file, remember that it will be a Photoshop layered file, so Windows users might want to make sure to add the ".psd" file extension. This process will take some time, perhaps several minutes. You'll see a progress dialog box while this is running.

Read More about PanoTools while you wait:

  • It's important not to optimize too many settings for the first image, since it's the anchor for the whole panorama. That's why the default setting for PTPicker is to only adjust the field of view. If you use a digital camera, your field of view will never change, and once you've stitched a few panoramas, you'll determine a very accurate setting that you can put in your first "i" Input Image Definition line, and remove the "v v0" line from your project files.
  • To get even better stitches, you should learn about correcting lens distortion with PanoTools, and perform batch correcting to your images prior to using PTPicker.
  • I'd always recommend shooting an anchor image at 0° pitch. You don't shoot an entire row, just one image that will help keep your output straight at the horizon.
  • Photoshop format is an excellent choice for the output file, because each image will appear on it's own layer, with a mask. You can very easily mask around objects, and you don't have to have straight vertical seams, as with most other stitching software.
  • To deal with the Zenith and Nadir, you can shoot an extra image straight up, and one extra image straight down, and stitch them as well. But, I personally find it faster to manually drop them into the cube faces in Photoshop after the stitch is done.


Results

Once the stitching process is finished, you can open the output file to see the results.

PTPicker Output Results

It shouldn't look too bad, considering that you only set two control points. The biggest stitching problems are actually due mainly to the top and bottom rows. Notice that there are 24 layers, named L1 - L24 to correspond to the 24 input images. If you turn off all the layers except the bottom L1 & L2, you should see that the control points you selected line up pretty well. Since the optimizing process had no control points for the remaining images, it left them at their default settings. This is why it helps to manually edited the project file to put those images at their proper locations.

More Control Points

You can close the file in Photoshop, and return to PTPicker. Now it's the time-intensive process of setting more control points. 2 points should be set for each pair of images. Basically just load the next image in each left and right window for the middle cylinder. Don't forget to set points for 11.jpg and 00.jpg, which will close the cylinder. When setting control points with the +50° and -25° rows, I'd only match them to the images in the middle row. So, I'd set points on 00.jpg and 12.jpg, and 00.jpg and 18.jpg. Don't worry too much for now about connecting those rows across, like 12.jpg and 13.jpg. Connecting them to the middle row should be sufficient.

Don't forget that after setting the control points, the process is to choose "Optimizer", and then "Stitcher" from the "Project" File Menu.

Conclusion

At most, you shouldn't have to run through more than three attempts. The second stitch should really line everything up, and you might want to make a third pass to line up any really stubborn areas. This tutorial will stop here, since you can are now done with PanoTools. To generate QuickTime VR cubic movies from your pano image, you can use another program such as MakeCubic or CubicConvertor for Mac OS, and PanoCube for Windows. To generate output for a java viewer, I'd suggest using PTViewer.

You might notice that all your layers in the Photoshop file are "locked". I believe it is due to a slight bug in the file format PanoTools generates. I've created a Photoshop script to fix this. Download the script (requires the Photoshop Scripting Plug-In [Win/Mac]).

See my completed version, called "Marina Towers" on my QTVR Samples page, but remember that I used higher resolution source files. Also, be sure to let me know if any part of this tutorial gives you problems.

©2008 Jimmy McGue -- 13941 Palisades Ave -- Huntley, IL 60142 -- USA


Valid XHTML 1.0! Valid CSS!