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 2010.2.0 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.

You can download the two photos used in this example (scan-1.jpg, scan-2.jpg) and try it yourself.

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 Assistant 1. Load images.. button and select the scanned images you want to assemble.

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 enter 10 in the HFOV(v): text box, and select OK. You will have to do this for each image.

add image


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-C.

control points

Switch to the Camera and Lens tab.

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 one picture and hitting the New lens button. If you have more than two images, set New lens for all the images, such that each image has a different lens number.

new lens

Now select the Optimizer tab. We are not doing a standard panorama. For this project we can use the Mosaic mode, so change the Optimize setting to The Custom parameters below and then set r,X,Y,Z for all images other than the anchor image,  select Optimize now!

Note, that you could also optimize by setting r,v,d,e for all images other than the anchor.

optimise

When it is done you will need to Apply the changes.

Now is a good time to use the Fast Preview Window to check that everything is going to be ok.

fast preview

Select Projection and set to rectlinear, then drag the window sliders to set suitable fields of view.

Select Move/Drag to position the image using Mosaic mode, and then select Crop and drag the inside of the cropping rectangle to adjust the crop.

That's it, you can use the Stitcher tab to create a permanent output file as usual.
In the Stitcher tab select calculate Optimal Size, set your outputs and then Stitch Now...

We have used Calculate Optimal Size for this example because the images have been scanned from printed material and the optimal size will minimize any pattern effects that might occur if the resulting stitch is scaled down.

stitch

Advanced techniques

Other things you might want to experiment with are:

Below is a final version stitched with nona and enblend. 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.

Updated for Hugin 2010.2, Nov 2010 by Terry Duell