Sometimes, you want to align photos, and remove barrel distortion maybe, but you do not want to stitch them. I detailed one example before, aligning photos for HDR. Typically, this does not work too well in graphics programs if you have moving clouds. Hugin is very good at ignoring moving stuff on its own, and it has an inbuilt feature, Celeste, that’s tailor-made for the task.
Today, I’ll go into more detail, and turn the previous post into a tutorial, telling you exactly what to click. And I’ll show you another way how this alignment can be useful.
Let’s say walk around the zoo and suddenly see an animal doing something interesting. A pelican playing around with an acorn or so. You whip up your camera and take a ton of photos. Later, you realize that they would make a nice sequence in PowerPoint or even an animated GIF. You will quickly find that there are at least two problems, more probably three.
First of all, it is highly likely that your field of view varies between photos: you didn’t keep the lens pointed at the same place for all photos, so that the animal would “jump around” in an animation. (note: if the animal locomoted, that focus spot would be on the animal, not the background, if it stayed in the same place, the point should be on the background, even if that spot is hidden from view by the animal).
Here is an example:
(if the animated GIF doesn’t play, click it to go to image view)
looks jittery alright – wouldn’t it be nice to get rid of that? All you have to do is align all the photos based on background feature, then crop them. Manually, in a graphics program, that’s a bother. Hugin to the rescue!
In the gallery below you find the images needed to replicate my example. DL via right-click.
1) Load your photos into hugin,
2) switch to the ‘Mask’ tab, and create masks for all images that cover the moving object (the pelican). Do this by selecting an image from the list, clicking ‘Add new mask’, then clicking into the image repeatedly to create a polygon around the pelican, ending with a double-click.
3) go to the ‘Images’ tab, and select all images by clicking the first, holding down SHIFT and clicking the last.
4) create control points by clicking the ‘Create control points’ button.
5) switch to the ‘Optimizer’ tab and optimize – I normally go for the full Monty (Position, View and Barrel – more on what’s what later). If you didn’t jaw or pitch your camera while taking the photos, you can go with ‘Position only’, but usually you need more, because of the second problem: you moved the camera in the lateral or horizontal plane, and thus you created parallax effects. That’s the thing that makes manual alignment so difficult.
If you run into a glitch here, see bottom of this post!
6) go to the ‘Stitcher’ tab, and click ‘Calculate field of view’ and ‘Calculate optimal size’
7) go to the ‘Fast Panorama preview’ window – that’s the icon in the main window’s top row that has the letters ‘GL’ in it. If the image you see fills the screen, all is fine.
8) back to the main hugin window’s ‘Mask’ tab. Delete the masks.
9) in the ‘Crop’ tab of the Fast Panorama Preview, mouse over the little boxes with numbers. They stand for the individual images. If you mouse over one, a gaudily coloured frame in the preview shows which part of the total panorama is covered by the image you selected. Take note of the least inclusive image for each border (i.e., first check which image extends the least far to the left, then do the same for the top, bottom and right)
10) at the top, enter numbers into the boxes to adjust the cropping of the images. Make sure that the white line denoting the crop is at or inside the least inclusive image’s extent for each border.
Example where Image 2 has the least extent to the left; crop was set so white line is at border of Image 2 [red] in this area)
11) back to the main window of hugin, go to the ‘Stitcher’ tab. Deselect all boxes in the Panorama Outputs: section, select ‘No exposure correction, low dynamic range’ in the Remapped Images: section. This results in hugin recalculating the images as if you wanted to stitch the panorama as shown in the preview window, including the crop. But it does not stitch it, and it saves the working images hugin creates so the panorama can be stitched. These are what we’re after!
12) click ‘Stitch’ in the bottom right corner. Hugin now asks for the desired file name, and saves the images.
Easy, hu? Now throw your images into an Animated GIF maker or Flash maker.
what can go wrong? Mainly, you can get bad results for a ‘full Monty’ alignment – see image below
in this case, try for ‘Position only’ alignment. Once that has run its course, you can usually run a more inclusive option without any problems. if the error of the position only alignment is small, you may not even need to go for barrel correction.