Create panoramic images from single shots with Hugin
Expert Stitching
Hugin is a tool for creating panoramic images, with many additional functions that make it a powerful supplement to your image editing toolbox.
Hugin is a free and open source program that has been around for years. Up to now, it has mainly been used to create large panoramic images from a few – or even many – single images. If you use Hugin correctly, you can create good panoramic images very quickly.
However, Hugin also supports other uses that include generating HDR images and computing super resolution images – large, extremely high-resolution images created by interpolation. Hugin also includes many advanced tools, for example, letting users determine the correction data for lenses (calibrate_lens_gui
). The align_image_stack
command, which is used by many other programs to align images, is also part of the Hugin package.
Hugin [1] was originally developed as a user interface for Panorama Tools, also known as PanoTools [2]. Later, support was added for the combination programs Enblend and Enfuse [3]. Hugin, PanoTools, Enblend, and Enfuse are all mature tools – Hugin was already producing panoramic images worth viewing 10 years ago, the developers have been working on Enblend and Enfuse since 2004, and Panotools was originally released in 1998 and has been continuously improved. The longevity of these tools shows that they continue to be useful even though many cameras now have built-in tools for creating panoramas that generate more or less capable results.
Keeping It Simple
With images shot in the right way (more on this later), creating a panorama with Hugin is simple. The main focus of Hugin's development work in recent years has been to improve the Assistant for combining panoramic images, also known as stitching. You just need to load the raw material and run the Assistant to complete the next steps. If you accept the presets and the images meet the requirements, the software computes the results in less than five minutes (Figure 1). It's especially easy if the images you're merging into a panorama are a landscape with the main features at some distance from the camera (Figure 2).
In the current version (2019.2.X at the time of writing), the Assistant comprises three steps (see Figure 3). Step one is loading the images. This is where you determine which image is used as the reference point for the white balance.
Step two is alignment, where you define the control points that allow the alignment of the images. Various algorithms are available for this purpose; if necessary, you can add or move control points manually.
Creating the panorama is the third step. To do this, the software distorts the images using the control points and then stitches them together by blending to conceal the transitions. This distortion is similar to a cage transformation in Gimp, where the control points serve as anchors.
Shooting Images the Right Way
The better the images fit together and the more they overlap, the more accurate the results will be and the less distorted they will appear. Many of these issues will need to be considered as you are taking the photos.
Parallax errors are one potential problem. These occur when you have captured the images to be combined from angles that are too different, and the relative position of elements within the photos appears to shift [4]. You can avoid or reduce parallax errors by rotating around the parallax-free fulcrum (NPP: "No-parallax point") [5], often incorrectly referred to as the nodal point. You can achieve this with a special adapter for the tripod. For landscape panoramas, however, this is often not necessary if you rotate the camera only by small angles and use large overlaps in the images.
Composite images created indoors or generally in confined spaces are far more difficult. Sometimes it is virtually impossible to take all the required images with low parallax from a single vantage point, although this would be preferable for automatic stitching. Sometimes only manual postprocessing of the single images or many attempts will achieve good results. The example in the "A Challenging Subject" box shows the overhead that can be required.
A Challenging Subject
The Norddeutsche Landesbank building in Hanover [6], Germany, (also called the Nord/LB) is considered an architectural highlight of the city. However, because it is nestled in the relatively narrow streets of the city center, it can be very difficult to find suitable locations to photograph the building well.
For nearly all sides of the building, you need to capture partial images and stitch them together. From any location on the ground, many parts of the building are difficult to see. In addition, there are problems with the lenses. It makes sense to use fixed focal lengths with short focal lengths and with the camera mounted on a tripod.
Stitching with Hugin quickly reaches its limits, and visible distortions begin to appear: the edges of the buildings, the skywalks and other structures then appear curved. While this is far from ideal, Gimp can help clean up the most serious errors (Figure 4).
With 360-degree panoramas, an additional problem arises from the exposure. This often differs so greatly when you combine shots taken against the light and those with the sun at your back that there may not be a consistent exposure setting for all the images. Exposure bracketing and several exposure cycles help in these cases. You then have a good chance of finding suitable images to create a harmonious panorama by manually selecting which single images to use.
Hugin's Assistant
The Hugin interface takes some getting used to, as it connects several elements and you sometimes need to switch between different dialogs on different levels while working.
By default, the program starts with a wizard called the Assistant, which has already been mentioned and that will be described in more detail. In the menu under User Interface, you will also find the options to activate an Advanced and an Expert mode. However, you may want to avoid these settings as you are getting used to the program.
Below the menu, in a kind of toolbar, you can access the various dialogs you might need from Assistant to Crop. Again, less is more at first: If the Assistant produces good results with the default setting, leave things be.
These three steps are all you need to create 360-degree panoramas, although you may want to adjust the exposure of the individual images to avoid distinct transitions. Then crop the result so that no empty areas are visible. Also, if you use RAW images, you first need to develop them digitally. Hugin can do this automatically, but it's usually better to do it manually (see the "Using RAW Files" box).
Using RAW Files
The current program version lets you use RAW files directly for processing. The required conversion into bitmap images is handled in a semi-automated way. For example, if you drag a group of RAW files from the file manager directly into the editing window, a dialog box appears (Figure 5).
Hugin tells the RAW converters to produce bitmap images in TIFF format with 16-bit color depth. This offers you pretty good possibilities for blending.
If there are already sidecar files for the imported RAW files from other programs, the software uses them to adopt the parameters for developing. However, it often makes sense to convert the images manually for the best quality. The results are usually better, especially if the light conditions were difficult when taking the pictures.
The Assistant will guide you through the steps automatically, and the result is a PTO file (a Hugin project file), which the program parses again later on, if needed, to load the settings. During a rerun, you can test additional settings, for example, by choosing alternative options or generating a HDR image as the output. You can add more images to the project at any time via drag and drop.
Hugin's Assistant will default to cropping the generated image so that no empty spaces remain at the edges. This sometimes reduces the size of the image unnecessarily. Missing information in the corners can be filled in with software such as Gimp by cloning or using the resynthesizer plugin. If you take this approach, you are free to manually resize the panorama image by setting up another frame under Crop or by using the handles to enlarge the area for the output.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.