USING "MORPH-TO-FIT" WITH PTGUI

Morph-to-Fit is a fairly recent Panorama Tools option that is currently not programmed into PTGui (V1.04). (It is already available in PTAssembler). What it does is to force control points into exact alignment by distorting the images. If used indiscriminately, you can readily force the entire set of control points into perfect registration, but this is probably not generally desirable. However, it can be used selectively to deal with bad double images caused by parallax or lens distortions that may be awkward to correct in post processing. To invoke this feature in PTGui, it is necessary to make some edits to the script file prior to running the stitcher.

The Morph-to-Fit feature

I found the following brief details in the Panorama Tools FAQ (provided by Helmut Dersch).

These lines in the script file are used by the 'morph-to-fit' feature:

C i0 x0 y0 X0 Y0

This means: After remapping image 0 (i0), take the point with coordinates x/y, and move it to position X/Y. This will only happen, if you specified 'o' in the corresponding image line. You can manually edit these 'C' lines to change the positions.

The morphing algorithm triangulates the panoramic image. Each control point becomes the corner of a triangle. The triangle mesh is then distorted according to the 'C' lines. This guarantees that the control points match exactly. This feature can be used in hopeless cases, e.g. parallax errors or weird distortions. I should add that all transformations (remapping + whatever correction is specified + morphing) are performed in a single step requiring just one sampling of the original source image.

Editing the script file

How to make the required changes to the script file behind PTGui's back, so to speak, is reasonably straightforward and covered in this section. The details of the precise changes to make will be covered in the section that follows.

The "C" lines referred to in Helmut's description are added to the script by PTOptimizer. To see them, you should check the "Show script" box before optimizing. After the optimizer has completed, the script will be displayed and the "C" lines can be viewed by scrolling down to the end of the script. Note that these lines will NOT be included in the script file that PTGui presents to PTStitcher. So what needs to be done is to highlight and copy the lines from the script file as displayed by the optimizer and paste them onto end of the file that PTGui hands to the stitcher (again checking the "Show script" box to gain access to the script before processing). Edits will also be needed to the image lines to activate the morphing.

Morph-to-Fit in practice

Why is it undesirable to morph all the control points? The problem is one of generating appropriate C lines for the parts of the image you are having the problems with. Experienced users of Pano Tools know that it's best to avoid putting control points on nearby or moving objects (especially when using a hand held camera) because of the real risk of interfering with the overall integrity of the panorama. So if the parts of the image showing parallax errors don't have control points on them, there will be no C lines generated either, so they won't be available for use in the morphing feature!

So how do we persuade the optimizer to generate C lines for control points on the problem parts of the images without impacting on a generally satisfactory alignment of the images already established without their assignment?

My solution is to first perform all the usual optimization to get the panorama right without setting control points on the features affected by parallax. Then file the project file away safely in case you want to return to this state later. Suppose there is a nasty problem in the overlap area of images 3 and 4, say. Assign several new control points around and on the area with the problem. Then run the optimizer, optimizing just yaw on one other image ( image 0, say). The optimizer will then run and do virtually nothing, but it will generate the wanted C lines for the newly added control points, without them having any effect on the overall alignment of the panorama. Use copy/paste as described earlier to add all the C lines (not the c lines) to the script for the stitcher, and add the "o" parameter to the end of the two image lines concerned (image lines start with "o") and then stitch away.

In my own limited tests, I found that once you assign control points in the area of the error, parts of the image away from that area can get distorted and might need additional points assigning for protection.  But it looks like a useful feature for occasional use, and I found it worked quite well for dragging quickly scudding clouds into better alignment, where any consequent distortions are less obvious.

 

Written by John Houghton
16th October, 2002
Email: j.houghton@ntlworld.com