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.

top part of scan bottom part of scan

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.

Images tab

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.

Camera and Lens settings tab

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.

Stitcher Tab

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.

Control points set

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.

Camera and Lens tab

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.

Optimizer Tab settings

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.

Preview

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:

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.

Leaves from Nature No.1

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