Hugin Optimizer tab
hugin uses a photo alignment scheme where it adjusts image orientation and lens settings of source photos until the control points line-up. This process is called optimisation and the hugin Optimizer tab is where it is controlled in detail. You actually create individual control points in the hugin Control Points tab, and manage them in the hugin Images tab and hugin Control Points table.
So to align two or more photos we need to connect them with some control points. A general rule is that optimising more parameters requires more control points.
Use the Optimize combo box to pick one of several pre-set optimisation schemes, then click the Optimize now! button to calculate the best available fit. For a spherical panorama, which is where each image is taken from the same position, you should not optimise translation. For a linear panorama, where you take pictures from different locations of the same flat surface, you must optimise translation.
One valid technique is to try each optimisation scheme in turn, starting at the top, and skipping the ones with translation if you are making a spherical panorama, until you are satisfied with the results.
The Optimisation result tells you how good the alignment is, large control point error distances indicate one of several things:
- Some control points are in the wrong place, look at the list in the hugin Control Points table and identify points with large distances and check they are set properly.
- If points are set correctly, there may be parallax errors caused by camera movement between shots. If so it may be necessary to decide which objects in the scene are important to have aligned and delete unrelated control points in the hugin Control Points tab.
- Otherwise you may not be optimising enough parameters. For example, the EXIF data retrieved from a JPEG file may not give a very accurate starting Field of View, in this case you should optimise view (v).
Use only control points between images selected in preview window. allows you to work on just a few of the images in the current project rather than all of them. Use the buttons along the top of the Hugin Preview window to enable and disable source photos. When optimising with the Hugin Optimizer tab, all the hidden images will be ignored.
The following pre-set optimisation schemes are provided:
Positions (incremental, starting from anchor)
This is the simplest setting, and is probably sufficient for a lot of purposes. Only the relative orientation of images are optimised, lens parameters are left untouched, this works best if either of the following is true:
- The lens has minimal barrel distortion and the photo EXIF information supplies an accurate Field of View.
- Lens calibration has already been performed, saved to a file and loaded into the current project via the hugin Camera and Lens tab.
Note that to align any pair of photos, there should be at least two pairs of control points connecting them.
This is exactly the same as the incremental setting above except that the parameters are optimised at once, this may confuse the optimiser if the images are not already roughly in the right place. Don't use this setting.
Positions and View (y,p,r,v)
Note that for this too work you need at least three well-spaced pairs of control points between any pair of photos. With a 360 degree panorama it is usually beneficial to optimise the Field of View, even if you have already calibrated this beforehand.
Positions and Barrel Distortion (y,p,r,b)
This is the same as optimising Positions except that an attempt is made to discover the lens barrel distortion at the same time. Only the b parameter of the full lens correction model is varied by this optimisation scheme, as this is a reasonable approximation of the distortion of a typical lens. You should trust the field of view if you use this.
Again you need at least three well-placed pairs of control points between any pair of photos.
Positions, View and Barrel (y,p,r,v,b)
Everything without translation
This optimises image orientation and all geometric parameters in the full lens correction model. It includes more lens distortion parameters. The x shift and y shift (d and e) parameters account for the centre of the projection not being in the centre of the image. This is quite common, and gets very bad if an image is the cropped corner of another image.
You will need many control points, the more the better, and preferably a full spherical panorama (360 by 180 degrees) to get the best correction. You should also use a calibrated panoramic head. If the control points are bad (either there are not enough or some are in the wrong place), or your images were not taken around the no-parallax point, this could produce bizarre results.
Positions and Translations (y,p,r,x,y,z)
This will optimise image orientation and the translation you get when moving the camera for a linear panorama. This is great for stitching images of the same flat surface taken from different places, for example when you couldn't fit a painting or the front of a building into one picture. Again it isn't ideal if the lens information such as the field of view is wrong.
Positions, Translation and View (y,p,r,x,y,z,v)
Positions, Translation and Barrel (y,p,r,x,y,z,b)
This is the same as optimising Positions and Translation except that an attempt is made to discover the lens barrel distortion at the same time. Only the b parameter of the full lens correction model is varied by this optimisation scheme, as this is a reasonable approximation of the distortion of a typical lens. You should trust the field of view if you use this.
Positions, Translation, View and Barrel (y,p,r,x,y,z,b,b)
This is useful when you are optimising a linear panorama, don't trust the field of view, and want to correct barrel distortion.
The Custom parameters below
The pre-set optimisation options are useful for most situations, but often it is necessary to switch to Custom parameters.
For example, when shooting hand-held panoramas, some of the position variation between shots can be resolved by using different d and e Image Center Shift parameters for each shot. Select The Custom parameters below and pick the d and e parameters for optimisation. Note that by default, lens settings are shared for all photos in the project, go to the hugin Camera and Lens tab and uncheck the link box for any you want to have different values in each photo.
Similarly, the translation parameters could be used to correct a wonky shot. However, they were meant for linear panoramas which expand to infinite distance at 180 degrees field of view, so you must make sure any images with non-zero translation (X, Y, or Z parameters) are in the middle of the panorama (y and p should all be around zero, and the field of view shouldn't be large enough to make them expand more than 180 degrees). This can be used to patch in the floor after you have removed the tripod that was obscuring it. You can take a shot of the floor where the tripod was at an angle (therefore you can avoid casting a shadow on the image in most cases). You can then optimise X,Y,Z on only this image. However, the floor must be flat for this to work, and this shot must be in the middle of the panorama. You can make down the middle by rotating the panorama on either of the previews.
The Image Orientation section shows the photo number and roll, pitch and yaw rotation/orientation values for all input photos (in parenthesis), and the X, Y, and Z translation parameters. The check mark indicates parameters that will be optimised. The translation parameters should all be 0 on a spherical panorama.
The Lens Parameters section shows the lens number and the lens correction model parameters (in parenthesis) for each of the distinct lenses in the project. Only parameters that are linked in the hugin Camera and Lens tab are shown in parenthesis.
Note that normally all the photos in a project have the same lens, so there is usually only one row here.
edit script before optimizing
hugin actually creates a PTOptimizer script file which it passes to the panorama tools library for optimisation, select edit script before optimizing and you can tweak this file for each optimisation run.
This is something you would only do in obscure cases such as:
- Linking the positions of input photos. For example photos in a multi-row panorama taken with tripod can all be assumed to have the same roll, similarly photos in each row can be assumed to have the same pitch - This will help when there are few details available for setting control points.
- Optimising the g or t shear parameters of the lens correction model for scanned images is only possible by editing the script file.