Hugin tutorial — Stitching flat scanned images
This tutorial covers another non-panoramic usage of Hugin — Taking two or more partial scanned images of a large object, such as an LP cover, map or poster, and stitching them seamlessly into a single final image.
Note: This tutorial is based on the March 2005 beta version of Hugin, although your version may differ, the underlying principle will remain the same. The rest of this article assumes that you are familiar with basic photographic stitching using Hugin.Here is a page that is too big to fit in the scanner and has to be scanned in two parts. These can be assembled in the gimp, but each scan is rotated differently and it is nearly impossible to line them up.
The solution is to use Hugin and Panorama Tools to rotate and align the pieces perfectly.
Start by launching Hugin, use the Add individual images.. button to select the scanned images you want to assemble.

Switch to the Camera and Lens tab.
Panorama Tools expects images to be photographs taken with a camera. Obviously this is not the case, but in fact a scanned image is very similar to a simple Rectilinear photo taken with a 'perfect' camera — A camera with zero pitch, zero yaw and zero lens distortion.
We don't know the FOV (Field of view) of this imaginary camera, but it doesn't matter since the picture is the same regardless (setting any mid-range value between 5 and 40 degrees would probably be ok). Just select an image and enter 10 in the degrees of view (v) text box.
Our 'perfect' camera doesn't have any lens distortion, so ensure that each of the a, b & c boxes in Lens Correction Parameters are set to 0.

The output image format is going to be equivalent to yet another 'perfect' rectilinear camera (except with a larger Field of View), so switch to the Stitcher tab and change the output format to say 'as a Rectilinear panorama'. Change the Field of View setting to something a bit larger than your source images — Something like 40 degrees for both Horizontal (v) and Vertical.
Tip: don't worry about getting this field-of view exactly right just yet, Hugin can calculate it for you later.

Switch to the Control points tab. Add a series of control points for each pair of images, just as you would when stitching two photos together.
Tip: You you need at least two control-points per pair of images, but more points will allow the optimizer to find a better alignment. I'm lazy, so the control points for this tutorial were generated automatically by autopano-sift.

The plan is to use one image as an 'anchor'. This image will stay in place and the other images will be rotated, scaled and moved by the optimizer until they align perfectly.
In Panorama Tools terminology, rotation is equivalent to Roll, scaling is equivalent to Field of View and movement is equivalent to d & e lens shift parameters.
Switch back to the Camera and Lens tab and tell Hugin that these parameters are going to be different for all of your source images. Do this by 'unchecking' the Inherit 'checkbox' for each of degrees of view (v), horizontal (d) and vertical (e).
You need to stop Hugin from assuming that all the pictures were taken with the same camera, so you need to asign a different lens to each image. Do this by selecting each picture in turn and hitting the New lens button for each.

Now select the Optimizer tab. We are not doing a standard panorama, so change the Optimize setting to the Custom parameters below
You need to optimize roll(r), fov(v), d and e for all images except the anchor. Make sure that you are not optimizing any pitch, yaw, a, b or c parameters.

Hit the Optimize now! button and wait while Panorama Tools tries to find a good fit. When it is done you will need to Apply the changes.
Now is a good time to use the Preview Window to check that everything is going to be ok (press the Ctrl P combination to launch the preview window).
Tip: Hit the Fit button in the preview to resize the output image to fit the combined input images.

That's it, you can use the Stitcher tab to create a permanent output file as usual.
Advanced techniques
Other things you might want to experiment with are:
Rotational alignment — Horizontal and vertical control points can be used to get the overall rotation perfect. See other tutorials for tips on using these types of control points.
Note: you will need to optimise roll (rotation) for all images including the anchor.
Image shearing — Most scanners produce some amount of shear distortion (racking), especially if they have been knocked. You can experiment with g or t shear parameters in conjunction with both horizontal and vertical control points to correct this distortion.
Note that there is no point setting both g and t shear parameters at the same time. For most scanners a portrait oriented scan produces t distortion.
You are not limited to stitching two scans at a time, you can assemble as many as you like in single or multiple rows.
A similar method can be used to stitch photos of a surface taken from different viewpoints and distances (such as a mural), this is a subject for a future tutorial.
Tip: All lens distortion needs to be corrected beforehand, as d and e parameters interfere with the a, b and c lens correction parameters.
Below is a final version stitched with nona and enblend, then cropped with the gimp. There has been no manual re-touching, however the join is completely invisible.
About this picture
The Grammar of Ornament by Owen Jones, was published in 1856 and is a landmark of Victorian architecture, printing and design. The final chapter; Leaves and flowers from nature was extremely influential in the development of the Arts and crafts and Art Nouveau movements.
Author Bruno Postle - Created March 2005. Updated May 2005


