Create a Panoramic Photo Using Hugin

Panorama stitching is a way to emulate having a much wider field of view than your lens and camera would provide by themselves. Hugin is the foremost open-source panorama stitching program, built around Panorama Tools. While it may not be as easy to use as some alternatives, the basics of using it to create panoramic photos are relatively simple. With some practice, you'll be taking photographs and stitching your own panoramas from them in no time.

Steps

Take Your Photos

  1. Consider setting your camera to a smaller quality setting. Remember that your final image may be many times as large, in each dimension, as a normal image from your camera. Unless you're doing enormous prints (and/or you have near-unlimited processing power, disk space and memory) you don't need to set it to the largest picture it can take (although you may want to not use much JPEG compression, if you possibly can).
  2. Set your white balance manually. Many cameras (including the ancient Canon D30, used to take the photographs for this article) do not lock their automatic white balance between shots, and have no provision for doing so, even when using auto-exposure lock (see below). Your camera may well decide on a different white balance for different parts of your panorama; consequently, you can easily end up with several photos, with very different white balances, which are a pain to correct in software later on.

    So don't use "Auto" white balance. Read your camera's manual to figure out how to set it yourself; on some compacts, this may be buried under "scene mode"-type settings. Don't worry about this if you're shooting film, of course. (You could, of course, shoot in raw and set the white balance when you convert to some more sane format.)

  3. Stop your lens down a little. Most—possibly all—camera lenses exhibit some kind of light fall-off towards the corners, or "vignetting", when shot wide-open (there will be some at nearly any aperture, but it is worse when the lens is wide-open). This is especially visible if you're shooting 35mm film or a full-frame digital SLR. Hugin can accommodate for this, to an extent, but it's best to eliminate it entirely.

    If conditions permit, try using an aperture one or two stops smaller than wide-open. This has the added advantage that lenses are usually somewhat sharper stopped down, too; it'll help Hugin find the common points between them much easier. (If you don't understand any of this, don't worry about it too much; just fix the vignetting in software later on if you're good with Photoshop and friends.)

  4. Take a test shot to get the exposure right, if you're on a digital camera. Check your LCD for a correct exposure. As ever with digital cameras: if in doubt, underexpose. You can pull shadow detail out later if you need to, but you can never recover a blown highlight.
  5. Hit your auto-exposure lock, if you have such a thing. On Canon cameras, this is the button marked with an asterisk on the back. This will prevent your photos being very differently exposed between shots. Hugin will blend them in such a way that it won't be quite as noticeable, but it's still a good idea nonetheless. (If you're weird, you might like the effect that comes from not using your AE lock; have fun if this is your sort of thing.)

  6. Take your photos. Remember that Hugin can deal with as many shots as you care to give it, in both directions (up and down). The most important thing is to leave a substantial degree of overlap between shots, perhaps as much as a third. Also be wary of large, blank areas of sky; Hugin may fail to automatically discern common points ("control points") between the two shots. If you want to be quite pedantic, use a panoramic tripod head; otherwise, ensure that when you rotate your camera, that you do so around the front nodal point. To quote Paul van Walree,

    To preserve the perspective during rotation, which prevents a displacement of nearby objects relative to the background (parallax), the axis of rotation should pass through the entrance pupil [...] the position of the entrance pupil can be approximately found by visual inspection. When you look into a lens from the front, the entrance pupil is the image of the diaphragm opening.[1]



Stitching Your Photos with Hugin

  1. Open Hugin and Hit the "Load images" button. Select the photos that you took earlier. Hit "OK", and wait.

  2. Enter your focal length and FOV crop, if needs be. If you shot this on digital, and intervening software did not strip the EXIF data from your pictures, it should determine this automatically, so don't worry about it too much (in our example, it was shot on a Canon camera fitted with a Strip and Clean a 29mm Pentacon M42 Lens, so it had to be entered manually).

    Remember to enter your real focal length and the crop factor of your sensor, not the 35mm equivalent focal length (you can find these out easily enough by a web search). If you shot on 35mm film, then just enter your focal length, and set the multiplier to 1. Divide 35 by the width of your film in millimeters to get the focal length multiplier for other formats.

  3. Hit "Align". The window which comes up is a keypoint generator; it's attempting to find common points between your photos in order to skew them and join them properly. After this, a window will pop up showing you a crudely stitched version of your picture. (Don't worry about the rough edges in this window; the stitching engine will smooth it all out later on.)
  4. Check the fit. In the main Hugin window, it will say something like "Mean error after optimization...". Look immediately below that. If it says "very good fit", or perhaps merely "good fit", then you're ready to stitch your photos, and can ignore the next three steps.

  5. Delete any stray control points. One cause of poorly aligned images is Hugin finding common points between images where none exist. Find these spurious control points and delete them. The control points will be marked with circles. Click once in the center of one, then hit the "Delete" button in the lower pane (by default, on Linux at least, this bottom pane is made too small, so you might want to make it larger).
  6. Add some control points. Go to the "Control Points" tab. You'll notice that there are two pairs of tabs, numbered. These are the numbers of your photos. Make sure that on both the left and right, you have two different images selected, with some shared point between them. Click on one on the left, then in the identical place on one on the right (see the picture to the right for an example).

    Hugin will, by default, automatically fine tune them, so don't worry about being too precise (though it's best to zoom in to 100%, from the drop-down menu on the bottom pane, so that Hugin doesn't need to guess quite so much). Click the "Add" button in the lower pane. Add as many as you wish, and repeat this process for each common area between all images.

  7. Go back to the "Assistant tab" and hit "Align". If you don't get the desired effect ("very good fit" or perhaps "good fit"), repeat the above two steps, and this one, until you get it right. Try more control points, further apart. Once the alignment is right, you might want to hit the "Straighten" button in the "Panorama preview" window.
  8. Optimize your panorama. There is a button on the toolbar to do this; see picture at right. Press it. You can also do this by going to the "Optimizer" tab; this will give you finer-grained control over what will be optimized.

  9. Set your stitching settings. Go to the "Stitcher" tab and hit "Calculate Optimal Size"; this will make your resulting file as big as it should be. Set "Stitching engine" to "nona"; this usually has great results, though doesn't permit outputting PSD files (which may or may not be useful to you), or anything but TIFF files. Set "image format" to "TIFF".

    You may want to use "multilayer TIFF" if you ignored the white balance and exposure-locking advice above; this will allow you to correct exposure and white balance individually if your software handles them well (GIMP, at least, does). Alas, this means you'll have to blend each photo into the others, manually, with layer masks. Good luck.

  10. Hit the "Stitch now!" button. Enter a filename for it to save to. Hit "Save", and sit back, and...

  11. Go away from your computer for a while. Stitching may take some time, and watching it happen is not particularly exciting.


Further processing

  1. Open your TIFF file in your favourite photo editor. Gimp or Photoshop, or anything else that can handle huge TIFF files and have a crop tool, will be fine.
  2. Crop your photo. In the default nona stitcher, with the default TIFF output, you'll end up with large, transparent areas left over from where Hugin had stretched it. Crop all the transparent areas out.

    Actually, you should be ruthless about cropping everything; anything that doesn't add to your photo should be removed from it.

  3. Do any further post-processing that you want. Again, if you ignored the advice about white balance and exposure locking, you'll need to correct this. Our photo didn't need this, but did need a kick up with the colour; exactly how this was done is detailed in How to Make Skies Beautiful with GIMP.

  4. Save your photo in some saner-than-TIFF format (like JPEG). Print it off, upload it places, and show it off to the world!

Tips

  • Don't use a polarising filter when taking your photos. You don't do this for the same reason you don't do the same thing with ultra-wide lenses:[2] you will likely end up with such a wide angle of view that the polarisation of the sky will be different from one side of your final stitched photo to the other, and so using a polarising filter will cause some parts of the sky to be darker than others.
  • If you are on Linux and repeatedly get control points in completely unexpected and random places, it probably means that you have cached keypoints sitting around for a different file with an identical file name. "rm /tmp/*.key.gz" will fix this nicely; a longer-term solution is to make sure your camera is using continuous file numbering.

Warnings

  • Using Hugin can use up a lot of memory, disk space and processor cycles. Save any data you have in any other programs you have running and close them if you don't need them. Having other processes running will cause Hugin to take longer than it normally would, too.

Things You'll Need

  • A camera. If you're on digital, the ability to set white balance and an auto-exposure lock button is useful, though not totally essential. Any film camera with either manual control or an AE lock should be just fine, too.
  • Hugin, which is available for Windows, Linux and Macs. You can download it for free from the project's website.

Related Articles

Sources and Citations