Transformation




Transformation for perspective correction options may be selected using toolbar icons






The two main operations may also be selected from the Transform menu item.
Open two images or an image and a map for which corresponding control points have been entered.  Select the image to be transformed by clicking on its upper border:





















Clicking here permits selection of an area within an image to be transformed.  If not selected, the whole image will be transformed. 

Warning:

If the horizon is visible in an image, you must select an area which does not include it. Ignoring this will cause transformation to fail, since a  perspective transformation goes to a vanishing line at the horizon and the transformation constants are undefined. Left-Drag the mouse cursor to define a selected area. A red-white box shows the area which is set when the left mouse button is released. If you are not satisfied, simply repeat the mouse-down drag operation.

























The selection box may be closed by clicking on this symbol.



This little camera symbol with a blue lens when clicked transforms the active image (click on the top border to activate an image) to a rectified image on an inactive image with corresponding control points. After transformation, the transformed image becomes active. 





















This camera symbol with a white lens transforms the whole active image to fit a new image whose scale may be set between 50 and 200% of the size of the original image.  



The scale may be set using the trackbar in the middle of the bottom status bar before this operation is carried out. The default is to use the resolution of the original active image (100%).

The result is a single new transformed image:





















This button undoes a transformation. It can not undo a transformation using the white camera symbol, since source and original target images are closed before displaying the result.



Clicking this symbol places a temporary grid over an  image to aid in placing control points or for comparing with an original un-transformed image. The grid will be removed prior to transformation and is not written permanently to an output file.




















Transformation of paintings or other images without a reference image:


The third menu option, Clone and Transform, is primarily intended for correcting images which have no reference or map image, such as oblique photographs of paintings under glass or in inaccessible places.

First, you must set up a quadrilateral to encompass the area of the oblique image to be corrected:
































Then, simply click on the Clone and Transform menu item. A new blank image which can be scaled over a size range of 50 to 200% will be made, depending on the setting of the scale trackbar on the status bar. Control points will be added automatically to its corners, and the transformation carried out normally. If it is desired to improve the precision of the transformation, further control points may be added to the original image and using the Magenta/Cyan magnifier combination copied to the rectified image. These control points should be saved to files temporarily and then the rectified image undone. A new normal (not Clone and Transform) transformation is then applied to the original, and the new points in the input image tweaked with the Alt-Right Click method for minimum reprojection error. Another undo followed by a re-transformation should produce the best possible fit.
























If the proportions of the painting differ considerably from the width/height ratio of the camera, the result may be compressed vertically or horizontally:































If you are able to measure the proportions roughly (a tape measure will do) or if you wish to proceed by trial and error, click on  Undo after transformation to obtain a blank image with control points:


























Then click on the  Window menu or the Resize toolbutton to bring up the resizing dialog:


















Click on either the height or width fields and modify the value with the spinners so that the scale field percentage value shows the percent of measured elongation or pick an arbitrary value which you think may be appropriate:



















Choose a filter type from the list too. The best results will usually be obtained with either Lanczos3 or Bspline filter.


Then, click on the Transform menu option or on the Transform button to obtain a new stretched image.  

























If the appearance is not satisfactory, close the transformed image without saving anything, and try again with a modified height or width value.

Architectural images:

Architectural images with vertical perspective distortion may require placement of control well outside the image itself:






























For pictures of this type, start by placing the upper border of the control point selection frame so that it corresponds with the upper border of the image and the lower border coinciding with the lower border. Then using the Transform Clone option, do an initial transformation to set up the output image. Then, after clicking Undo, spread the lower border so that it extendends outside the image. It is often helpful to add a fifth control point in the center of the image and the blank image, then tweak this automatically to obtain a best match. The operations Undo, extending the bottom selection and tweaking the fifth point should be repeated until the vertical features are aligned with a temporary grid written after transformation. Turn off the grid before saving the transformed image. If the image is stretched or compressed vertically too much, use the resizing method described above on the blank initial image.


Testing placement of the transformed area:

Before transformation of any image, you may wish to test the placement of the transformed area. Click on Debug on the  Control menu and transform. The result area will be shown in red:























A window will pop up during transformation to show how things are progressing. If you have more than one physical processor, or have a dual-core processor,  or if you have a Pentium 4 with hyperthreading enabled in the BIOS, then the number of progress bars will reflect the number of physical or virtual processors. If there is more than one physical or virtual processor, the source image will treated in as many sections as there are processors, thus speeding up the transformation. This shows the progress window with a two-processor machine having hyperthreading for both enabled:












If control point placement leads to an average reprojection error for all points which is greater than 1 % of the average of the side lengths of all images, a warning dialog pops up and asks if you want to continue anyway. 











Click No if you want to try to improve placement, and then press F9 on the image window. Look for the control point with the highest error, then Alt-Right click on it and tweak it to reduce the error. Repeat this for the next highest error point and so on as described in the topic Move Control Points a Pixel at a Time in the
Control Points chapter of this help. Then try the transformation again.

Undo Notes:

Undoing a transformation permits choosing new parameters in Setup or modifying control points and re-transforming without re-loading everything. The undo function also turns off any area selection, grid and repaints the control points and the navigation palette of the original image.  It may also be used on rotated and resampled images.

When Clone and transform is selected, the empty cloned window is shown after undo, leaving any control points intact. This window can then be resized if desired and the normal transformation operation repeated.