Hugin tutorial — Simulating an architectural projection

This tutorial covers a basic non-panoramic usage of Hugin; taking a handheld photograph and using 'vertical' control-points to correct lens 'barrel' distortion and remove perspective effects.

Note: This tutorial is based on the 0.7 beta version of Hugin, although your version may differ, the underlying principle will remain the same.

You can download the photo used in this example (p1010003.jpg) and try it yourself.

Start by launching Hugin, and using the Add individual images... button to select the image you want to adjust.

Images tab

Switch to the Control points tab.

This is where you are going to input all the information the software needs to correct lens barrel distortion and re-align the perspective.

Notice that there are two identical images side by side, each pair of control-points that you set involves selecting a related feature in each image.

control points

Make sure that Zoom is set to fit to window and that Auto add is set.

Now you can use the mouse to select control points; pick a vertical feature that you can see in both the left and right-hand windows then select a point on one end of the feature in one window. When happy with the location of the selection click on a point at the other end of the feature in the other window. You can go back to each of these points and selecting them should open a small magnifier to allow fine tuning. Repeat until you have at least three pairs of control points.

Tip:If you are having trouble accurately selecting the control points, after picking each point 'fine-tune' the location using the 'f' key. Do this by selecting a control point pair in the tabular list, then pressing the 'f' key, and using the magnifier window and mouse to move each end of the control point pair. For more detail on key commands see the Hugin manual.

This tutorial is going to use a special type of control-point called a Vertical line control point. After clicking to pick each pair of points, you may have to change the mode: to Vertical line. You can do this by selecting the control point in the data table, as has been done for point #2 in the control points window above, then click on the mode: button and select vertical line.

Now select the Optimizer tab. Hugin uses an optimization scheme where it adjusts image orientation and lens settings of the source photo until the control-points line-up.

Choose Positions and Barrel Distortion (y,p,r,b). Note that Hugin will not actually optimise yaw (y) for this example because all possible values would be a 'correct' solution.

Click on the Optimize button and wait while Panorama Tools tries to find a good fit. When it is done you will need to apply the changes by selecting the Yes key.


Now click on the preview icon (3rd from the right on the icon bar at the top of the window). Select Rectilinear projection and adjust the sliders to get a good field of horizontal and vertical field of view. You can also use the center button to position the image if necessary.

Tip: click on the Auto icon and the preview image will automatically reflect adjustments you make with the sliders


Close the preview window.

Finally we are going to generate the output image. Select the Stitcher tab.


Ensure the projection is set to Rectilinear. Under Output -> Normal choose Blended panorama, and under File formats -> Normal Output: choose your desired format.

Hit the Save project and stitch button.

You will firstly be asked where you wish to save the project files (you can reload these into Hugin later if you wish to revisit the project), then you will be asked for the filename prefix for the output image.

Notice that all the vertical features in the scene are now actually vertical in the output image.

This is a very popular way of presenting architectural photographs, not least because the only other way of creating such images is to use a very expensive shift lens with a vertical plane, front rise camera.

Below is a final version. This image clearly shows the distortion that has been applied to correct the vertical features. If you want to crop the final image to a rectangular shape it would be good idea to have a bit more space around the lower edges of the image.

Cropped output image

Note that this technique works just as well with multi-photo images, it's also a crucial part of the process used to level cylindrical and equirectangular panoramas — See the other Hugin tutorials.

Original tutorial, Bruno Postle, October 2003; updated for Hugin v0.7 by Terry Duell May 2008.