Using Hugin

Carpebble-logo

Processing the photos part 3

In this series of web pages, I have documented the process which I currently use to create 360x180 degree panoramas. This page explains how I stitch my photographs using Hugin. This is, by far, the longest and most detailed of the pages in this guide and success depends upon capturing the images correctly and creating a composite nadir image for use during stitching. Recently I have had some success creating panoramas in Hugin without first editing a composite nadir image. A link to an example is here, along a mini planet and the files I used to create them, there are also some instructions here if you want some example images to play with. Hugin is free software, which can be obtained from this link.

1. Loading the images into Hugin

Open Hugin and use the Assistant to load the eight tonemapped images. Control-click the six horizontal images, the zenith and the composite nadir image before clicking Open.

When using a manual lens, such as the Opteka "fish-eye" lens it is necessary to put in the correct lens data when the images are being loaded. Forget to do this correctly and Hugin will never stitch the images correctly. Most important is the Lens type, which is Stereographic for the Opteka. The focal length written on the lens is 6.5mm, but using somewhere between 8.8 and 9.2mm for the Focal length seems to work better. Hugin seems to make small adjustments to the focal length during alignment. The focal length multiplier for my camera is 1.62x.

Using my Canon kit lens, Hugin picks up the lens parameters automatically from the EXIF data, so I imagine it would do the same if I was using a more expensive electronic Canon lens for shooting my panorama. For this to work with tonemapped images, I would need to copy the EXIF data from the original files to the output files, using the utility in the Tools menu of Luminance HDR.

Although I have tried other methods, I allow Hugin to anchor the first image for position and for exposure, which is the default.

Hugin can handle stacks of images, for example bracketed images for tonemapping. I have not succeeded in getting this to work, although I have not tried that hard and have quickly reverted to Luminance HDR, with which I am more familiar.

2. Aligning the images

After the images have been loaded successfully, I use the assistant to align the images. This involves Hugin finding similar points on adjacent images and creating control points to pin the images to each other. If there are control points joining all of the images, then Hugin starts the Fast panorama preview to show the results.

With the image set from Glendurgan, Hugin failed to find any matches in the nadir image. I have shown the screenshot of the error message.

It was therefore necessary to add control points manually using the Control Points tab and then identify the same points on the nadir and adjoining images. Sometimes it is necessary to add or delete control points manually if the images do not match well, often because something in the field of view has moved, most often, clouds, but sometimes people, vehicles or plants blown in the wind.

Adding a control point on a leaf.

Load the images
Unconnected images
Manually add control points

Adding a control point on a fern.

Add more control points

After adding some new control points and re-running the Align assistant, this is what Hugin produced, which is not bad for a first attempt, although a tripod foot can be seen in the middle of the picture at the bottom. The variation in sky colour will be removed when the image is blended.

Hugin initial attempt

This view shows the Fast Panorama preview. Often the horizon in a panorama is not straight, in which case, I go to the Move/Drag tab, where I drag the panorama into a reasonable shape and then straighten the horizon automatically. In other circumstances, the Crop tab is also very helpful, but not for a 360x180 degree panorama, where I want to keep the whole panorama and not crop at all.

When alignment is complete, Hugin will have set the yaw, pitch and roll for each of the images. Yaw is the angle that the camera rotated between each shot, pitch is the angle of each row in a multi-row panorama and roll is the angle of the camera which is 270 for landscape and -90 for portrait.

Shooting 4 images in 1 row at 90° increments plus Zenith and Nadir would produce these parameters.

If you straighten the panorama, Hugin tries to set the pitch of all images in the same row to the same value.

Information from http://www.panoguide.com/forums/qna/5884/

3. Masking off undesirable parts of the images

To remove the tripod foot from the image, it is necessary to use a mask. Sometimes, additional shadows and movement can appear during stitching, so I generally tell Hugin how to handle these anomalous areas, even if they do not appear in the preview, rather than leaving Hugin to make the decision for me. You can see that in all, I used seven masks in the Glendurgan set, mainly to remove tripod shadows from the images. In the first image, shadows from all three legs were visible, which is why there are three masks.

Masks are polygons, which I add in the same way that I might add polygons in other drawing packages, by left clicking to add each node and then double-clicking to close the polygon.

After the mask has been created, it is possible to move the whole mask, or to move individual nodes, by clicking off the mask and then either clicking on one node and dragging it, or left-clicking and swiping over the node to select nodes in an area. The nodes are coloured blue when they can be moved.

Other things that I mask out include my own feet in the nadir shot, people who move through the shots, one image of people who appear at the overlap of two images, or moving pictures on a screen.

Although generally I use exclude masks, it is also possible to add include masks, to tell Hugin which version of an object to use. Both types of masks have been important when I have stitched panoramas containing people, such as the geology students on Carn Brea, or panoramas from school concerts.

I have never used the crop tab which is visible in this view and neither have I used the Import/Export, Colour and Options tabs at the bottom of this picture.

There is still much more for me to explore in Hugin.

4. Optimising the control points

When I have made changes to the control points, either adding new ones, or deleting less reliable points on moving objects, like clouds, it can be desirable to optimise the match between images.

There are also options hidden under the pull-down menu to alter all sorts of characteristics of the images to get a better match, promising a better match, when sometimes my camera has not stayed very still during shooting.

Although I normally click the Optimise now! button, quite often the maximum difference shown in the result dialogue has been massive, showing that one of the images was way out of alignment. Although this has not been a problem since using my panoramic tripod head, it has been a regular issue with either the nadir or zenith in hand-held shots.

If I inadvertently accepted the large maximum control point distance, then the panorama would become corrupted and it would be quicker to start again.

The moral is, be careful before you accept the results of the Optimiser.

5. Adjusting the centre of the panorama

Hugin has two previews, the Fast panorama preview, that opens automatically when alignment has completed successfully (with default options set) and the slightly slower, but more accurate Panorama preview shown here.

The two previews allow you to change the appearance of the panorama in different ways.

I use the Panorama preview shown here to change what appears at the centre of the panorama. If you look carefully, the instructions are at the bottom of this screenshot.

Left click to define a new centre point. The point where I left-click moves to the cross-hairs in the preview window.

Right click to move point to the horizon.

These two commands are useful, because the panorama does not always have a straight horizon and the default positioning is unlikely to be the most pleasing to the eye.

In the Panorama preview, it is sometimes necessary to click Update to redraw the window after making a change.

When creating a panosphere, it is possible to change the projection in this window from Equirectangular to Stereographic, but I have included more on that topic later.

6. Optimising the exposure

You may have noticed that the tabs in Hugin are arranged in the direction of work flow, from left to right.

Although it should not be necessary to optimise the exposure, because the camera settings did not change during image capture, sometimes it is helpful to run the Photometric Optimiser, since lighting conditions can change, even if camera settings don't.

This optimiser has not damaged any of my panoramas recently, but in the past, as I was learning how to take the photographs, the optimiser struggled to handle the images that I gave it and it ruined a promising, but defective panorama, particularly by massively changing the exposure of the nadir and the zenith images, so be warned and look carefully before you accept the results of this process, as it can signal the end of a promising panorama.

This is the last tab before the Stitcher. At this point, the panorama shown in either of the Panorama previews should be devoid of anomalies or photographic clutter and the colour match between the images should be pretty good.

7. Checking the settings

Mask undesirable areas
Optimise positions
Hugin first stab
Optimise exposure

This screenshot shows the final tab in the sequence, the Stitcher. Working from the top down, the Projection is Equirectangular, which is correct, it will have a height which is half of the image width.

The field of view should be 360 by 180. Click the Calculate field of view button if it says anything else.

Click Calculate optimal size and Fit crop to images, to set the size of the output image.

You can see the options that are set for Panorama Outputs and Remapped images. These are the default settings. I have not tried very hard to use stacks or HDR within Hugin.

When I had computer memory problems, I tried to change the settings of the remapper and blender, both here and in the File | Preferences dialogue, but have returned them to their default values and have not changed them recently.

The final thing to do is to click the Stitch! button, which places a job into the batch processor. Hugin asks to save the project and then defaults the name of the panorama to the same name as the project when it queries you for a panorama name.

The process of creating the panorama can take 20 minutes or more and is slowed down by saving files on a network. I use a NAS drive to store my photos, but download the images onto my computer hard drive for use in Hugin and then upload the finished images back onto the NAS drive at the end.

8. Batch processing

Check stitcher settings

This final window from Hugin shows the Batch Processor.

If you close this window, it does not stop the batch, but the window disappears and you have to go hunting for it in the "Show Hidden Icons" option at the bottom right of the screen in Windows 7.

Several Projects can be queued, ready for processing and they remain in the Batch Processor window. The Remove complete button clears complete projects from the list and also gives the option to remove failed projects as well.

If a project does fail and you reset it and run it again, Hugin will ask whether you want to overwrite the original working files. My answer is always to overwrite the files, but they can prove useful if you want to use enfuse / enblend with command line options.

The default output file for the panorama is a TIFF file.

In the next page, I explain how to create a panosphere or mini planet in Hugin. Alternatively, you may want to skip to the next set of pages, to find out how I edit my panoramas in the GIMP, publish images in 360cities and publish images on Flickr.

Batch Processor