This page described how to assemble many individual photographs into a single panorama in 2006.  Hugin has become so featureful that it no longer needs a lengthly tutorial.  This page should probably be retired. -- 2009


Panoramas near Perfection

These instructions should work on any platform -- Linux, Mac, or Windows.



Each pano will require you to perform four steps:

  • Create the control points (Autopano). Control points describe how the pictures line up. Autopano will automatically create control points, or you can create them manually in Hugin. Generally you'll do a combination: let Autopano create the control points, then touch up the areas that don't quite look right in Hugin.
  • Stretch the images (Hugin). In this step, Hugin manipulates the images so they'll fit together better and saves them to a set of files.
  • Blend the images (Enblend). Tries to remove all the seams and artifacts along the lines where the images meet.
  • Final Touchups (Gimp). Enblend does a very good job but you will probably have to touch up a few areas that it didn't quite get right. You'll also need to crop and scale the final image to the size that you want.


Download the Software

Most Linux distros will have these built-in. Hopefully installing is as easy as, 'apt-get install autopano-sift hugin enblend.'

Right now (28 Jan 2007), Hugin and Enblend have significant improvements that have not hit the Ubuntu repos yet. It's worth compiling these packages yourself if you know how. this might help.

On windows, you'll have to download and install each program:

TODO: background on autopano-sift

Hugin is a front-end for the Panorama Tools toolkit developed by Helmut Dersch.

TODO: background on enblend.


Take the Pictures

  • Use your camera's panorama setting if it has one. This will try to ensure that the exposures and white-point remain close during the shooting.
  • Use your camera's manual mode if you can, for the same reason as above. Try to meter on the average of all the pictures you're going to take.
  • Hold the camera absolutely level. Place it on a flat surface or a tripod if you can. Lenses introduce enough distortion as it is -- no need to make your job harder by adding your own distortion too.
  • When adjusting to take a neighboring shot, try to rotate the camera about the front of its lens (called the nodal point). Most people tend to hold the camera at arm's length and turn. Don't do this, it can cause significant parallax errors and make stitching much harder. Instead, turn yourself about the camera.
  • 20-30% overlap is usually fine. Less than this and many of your control points will be placed in the relatively high distortion areas near the picture's border. You'll need more overlap if you're moving the camera a lot rather than just rotating it.
  • Take more pictures than you need, and shoot a much larger area than you think you'd need. You will be surprised at how much area you will lose to distortion.
  • 360 degree panoramas are very difficult to stitch together, especially if they are multi-row. You will probably find it easier to first stitch 3 180 degree segments together into panoramas, then stitch the three segments together into a final, single panorama.
  • I'll say it again because it's important: shoot a much larger area than you think you need.

If adjoining pictures have wildly different exposures, or there's just too little overlap, there may be no reasonable way to produce a decent-looking panorama.

Hugin can try to correct for roll. The PTStitcher can also try to compensate for exposure and white balance problems. Of course, just taking the right picture will always produce the best results and take a lot less time to stitch.


Prepare for Stitching

Place all the images for this panorama in a single directory. This directory will also contain a number of control files and intermediate images as you work.

For your first pano, start small -- only three or four pictures. Make sure they have a lot of overlap.

(TODO: include an example)


Generate Control Points

TODO: tell how to create control points from within Hugin (in the Images tab, select the images you want to search for control points, then click "Create Ctrl Points")

This step is optional. You can also your pictures directly in Hugin and place all the control points manually. This is a fun process and gives you a good feel for what Autopano is doing. On the other hand, since will generally place around 150 points for a 6-picture pano, it gets tedious fast.

Launch autopano-sift and load your images. The defaults are generally OK.

  • Reducing the input size can sometimes result in noticeable errors. If

you're not in a hurry, and your computer isn't short of RAM, et "Downscale Resolution" to "Keep Input Size".

  • Enable "Refinement Step". TODO TODO
  • You need to tell autopano where to save the output file (in the same folder as all your pictures).
  • If you don't know whether to use absolute or relative paths, then use absolute.

Click "Compute," then do something else for a while. Your computer will chug for a few minutes to a few hours, depending on your input files and your resolution settings.

I've seen autopano-sift go into an endless loop on Windows. If it sits for 1/2 hour without doing anything, you'll want to kill it and try again with slightly different settings. I haven't seen this on Unix.

The settings above tend to be needlessly compute-intensive. Dropping the resolution saves some time, but I've seen some small inaccuracies caused by working at low resolution. Refining also tends to be unnecessary but it can't hurt, as long as you don't mind the computer taking longer to produce the output file.


Align the Images

Open the output.pto file generated by Autopano. If you didn't use Autopano then load each of your images manually.

On Windows, Autopano will save output.pto in its own directory, probably C:\Program Files\Autopano-Sift. Use the File Search tool to find it.


Specify the Anchor Point

Autopano uses one spot on one photo as the origin and transforms the other photos relative to it. By default it uses the middle of the first photo in the list. You'll probably want to change this.

(Actually, sometimes this is really hard. Unless it's really easy, you can skip it for now, then specify the anchor point when you first preview the result).

Find the spot that you want to be the center of your panorama. In the Images tab, select the picture that contains this spot, then click on "Adjust the Anchor Spot." Place the anchor spot right on the center of your panorama.

PTStitcher will also use the anchor point as a reference for color and brightness compensation. Finally, you can rotate the anchor point with the right mouse button but this is pretty flimsy. It's much better just to add horizontal and vertical constraints.


Specify Camera Data

TOOD: add more here

If your pictures inlucde EXIF data (and if they came from a digital camera they had better!) then everything should be set up automatically in the Camera and Lens tab. In older version of Hugin you might have to click on "Import Exif Data," and for really crappy cameras you might have have to tweak these settings a bit.


Specify Control Points

Control points identify identical spots in any pair of pictures. Leave image 0 selected in the left-hand pane and select image 1 in the right. You will now see the points that Autopano chose. They will probably all line up (if a circle is on the top of the antenna on the left picture, a circle of the same color needs to be on the top of the antenna in the right picture).

Autopano does a fantastic job at matching features. If it isn't sure, it simply doesn't apply a control point. You will probably never have to move a pair of control points that it selects.

On the other hand, sometimes it distributes the control points rather poorly. You want control points distributed evenly over as large an area as possible, but not right on the edge of the photograph. If a control point is right at the edge, it can cause ripples where Hugin needs to apply high distortion to get all control points to line up.

Do the best you can when placing control points but don't stress it; after previewing the picture, you will here later to touch things up.


Specify Horizontal and Vertical Constraints

The distotion caused by your camera's lens, and now by Hugin as it tries to line up the control points, can cause the horizontal and vertical lines in your picture to start leaning at crazy angles. To tell Hugin to force the side of a building to be vertical, or a railroad tie or the horizon itself to be horizontal, go to the Control Points tab select the same picture on the left and right hand panes. Click to create a point at one end of the line, then click in the opposite pane on other end of the line. Hugin will automatically determine if the line should be horizontal or vertical.

You can be sparing with these for now but you will almost certainly have to go back and add more horizontal and vertical lines after previewing the picture. Panoramas have a tendency to snake around rather than laying nicely flat. Horizontal and vertical guidelines are the best way to get the pano to lay flat.


Calculate the Field of View

Click on the very last tab.

You need to decide what projection you're going to use for your panorama.

  • Rectilinear: tries to keep straight lines straight, even if it means causing serious butterfly distortion near the corners. A very good choice for small panoramas (say, 60-90 degrees).
  • Equirectangular: can be used for very large, 360 degree panoramas.

See for examples of these projections.

Now click on "Calculate Field of View".



Select the Optimizer tab. Leave the default optimizer selected (Positions (incremental, starting from anchor)) and hit optimize. You should always optimize as little as possible. There are a number of reasons for this:

  • Optimization adjusts the pitch,yaw,roll,etc of each photograph to ensure all the control points line up as close as possible. Hugin needs a little help to find the best settings. If you immediately try to optimize everything, Hugin will probably lock itself into a wrong answer (local minima).
  • If you optimize too much, the areas near your control points will look good but other areas will ripple as Hugin overcorrects for shooting defects. Your pictures require tons of overlap and tons of well-distributed control points to optimize aggressively

So, only select "Everything" if your images overlap by a large amount (>50%) and you have placed a lot of control points.


Optimizer Parameters

Each optimizer adjusts a set of parameters to try to get the control points to line up better. To understand the optimizer, first you need to understand the parameters that it will be optimizing.

  • y yaw --
  • p pitch --
  • r roll --
  • v hfov horizontal field of view --
  • a --
  • b --
  • c --
  • d --
  • e --
  • g --
  • t --



  • Optimize Positions (incremental, starting from anchor): holds your anchor picture steady, then tries to reposition each neighbor to glue it on. Unless you're only stitching two or three photographs together, you'll probably not get away with such a simple optimizer.
  • Positions (y,p,r):
  • Positions and View (y,p,r,v):
  • Positions and Barrel Distortion (y,p,r,b):
  • Optimize Positions, View and Barrel (y,p,r,v,b): Same as
  • Everything: (TODO: how is this different from y,p,r,v,b)?
  • Custom Parameters: TODO

Now hit Preview and take a look at what you have.

Unfortunately, it will probably look like junk. The horizon will be S-curving around and the outer pictures will be so bent that there are no straight lines anymore and everybody looks fat. Scary.

Now you can go back and fix things up by adding horizontal and vertical guidelines and some more control points. Equirectangular only works for narrow fields of veiw, say up to 120 deg. Use cylindrical if you want to go wider.



The optimizer reports the maximum distance that a point on the picture has moved from its control point. You generally want less than 5 pixels of error. If you're careful when shooting, even without a tripod it's possible to get less than two pixels. If you're seeing large error, then it may be that some control points are placed badly. Go back to the Control Points tab and sort the points by error distance. Click on the highest-distance points and either delete them

Often the optimizer will get stuck such that more points don't seem to make any difference. When this happens, the only thing that I know of to do is to go back to the Photographs tab, select all the photos, and click Reset (if you see some numbers that look really different from other numbers, try resetting only those). Then optimize all over again, starting with the simplest and working your way up.

The preview mode offers a very good way to tell how well your images are overlapping. Set the Blend Mode to difference. Ideally, everywhere pictures overlap would appear black, meaning that everything has stitched together perfectly. Of course this won't happen but hopefully you'll see that most things are stitching together fine and it's one or two pictures that are causing trouble. Adding or moving control points on these pictures or, if you can, just drop them entirely.

Dropping a few frames is a tried and true technique to get some sets of pictures to stitch properly. In theory, of course, this should never be necessary and there will certainly be more distortion in the final result than if this picture contributed to the whole. However, if the alternative is often simply being unable to get the pictures to stitch at all, dropping the picture is a fine alternative. TODO: what causes this? errors when shooting the pictures?

You may also find, surprisingly, that dropping some control points will actually improve the images overlapping. I'm not sure why -- atmospheric aberrations maybe? Camera jiggle during slow shutter speed? Anyhow, don't be afraid to delete control points, especially if they're near the edges of a photograph and you're seeing high distortion numbers.



When all your images line up properly in the preview pane, it's time to render them.

Click on the Stitcher tab and:

  • Click on Calculate Field of View again, then preview again. You want enough black border that nothing gets cut off, but you don't want so much that you consume hundreds of megabytes of disk space with TIFFs containing nothing but black pixels. You can preview and adjust the field of view in the Preview pane.
  • Click "Calculate Optimal Size." Since you'll be doing a lot of cropping, this should be quite a bit larger than the resolution you want your final image to be. Don't make it too large, though, or it will take days to stitch. and gigabytes to store the intermediate images.
  • Stitching Engine: nona. This is a good and very fast stitching engine. The other engine, PTStitcher, takes a much longer time but it can also perform color and exposure correction.
  • Image Format: Multiple TIFF if you want to use enblend. Hugin can do its own blending but only gradually fades from one picture to the other over the region of overlap. Not many subjects lend themselves to being blended like this. Also, if you have significant optimizer error, it will show up as blurry sections in the final pano. Enblend can handle some pretty serious error and still make the final result look good, the built-in blender can't.
  • Leave Stitching options alone: the default interpolator and gamma should be fine.

Click Sitch now! (it's in the middle of the Stitcher tab), tell it where to save the intermediate images, and then do something else for a while.


Merge with Enblend

If you open the intermediate tiffs, you'll see that Hugin has distorted the images but hasn't not joined them together (Hugin actually can join them itself, but Enblend does a far better job). Enblend searches for optimal areas to join, and does a bit of automatic photo editing to hide the seam. It takes longer than just letting Hugin join the pictures itself but the results are worth it.

Open a terminal and run:

enblend -m 1024 -v -o enblend.tif nona*.tif
-m: should be a little less than your system's total RAM.  If -m is
   too small, you'll spend too much time reading from the disk, and
   if -m is too large you'll spend too much time thrashing to the disk.
   If you don't know then 256 is probably a reasonable guess.
-v: be verbose so we can watch progress
-o: name of the output file

On Windows, because Enblend is command-line only, it's somewhat difficult to describe how to run it. Here's a technique that should work. First, copy the "enblend.exe" file into your pano directory. Then bring up a terminal window (Start menu, "Run...", and type "cmd"). Open an explorer window on your pano directory, and copy the location starting with "C:\...", like "C:\Files and Documents\you\pano". Type "cd " (the space is important), then paste the path, and type return. Now type the command above. If you don't know what your .tif files are called, type "dir" to show what's in that directory. TODO: make this more understandable!

The finished picture should look really good. Now you'll probably have to do a fair amount of photo editing to crop out a rectangular portion, equalize exposure in the sky, fill in some areas with missing textures, etc.

And hopefully now you have a nearly perfect panorama.



You don't only have to do panoramas with these tools. Here are some other examples: