How to stitch photos together on Linux

If you are an avid photographer, you will probably have several stunning panoramic photos in your portfolio. You don't have to be a professional photographer, nor need specialized equipment to create dramatic panoramic pictures. In fact, there are quite a few picture stitch apps (online or offline, desktop or mobile), which can easily create a panoramic view of a scene from two or more overlapping pictures.

In this tutorial, I will explain how to stitch photos together on Linux. For that, I am going to use panoramic photo stitching software called Hugin.

Hugin is an open-source (GPLv2) free panorama photo stitching tool. It is available on multiple platforms including Linux, Windows, OS X, and FreeBSD. Being open-source free software does not mean that Hugin won't match up to other commercial photo stitchers in terms of features and quality. On the contrary, Hugin is extremely powerful, capable of creating a 360-degree panoramic image, and featuring various advanced photometric corrections and optimizations.

Install Hugin on Linux

To install Hugin on Debian, Ubuntu or Linux Mint:

$ sudo apt-get install hugin

To install Hugin on Fedora:

$ sudo yum install hugin

Launch Hugin

Use hugin command to launch Hugin.

$ hugin

The first thing to do is to load photos that you want to stitch together. For that, click on "Load images" button, and load (two or more) pictures to join. It should be obvious, but individual pictures need to be overlapping with each other.

First Round of Photo Stitching

After loading pictures, click on "Align" button for the first round of stitching.

Hugin will then run stitching assistant in a separate window, which analyzes common keypoints (or control points) between photos to combine the photos properly. After analysis is completed, you will see a panorama preview window, which will display panorama preview.

Switch back to the Hugin's main window. Under the "Align" button, you will see the status of photo stitching (i.e., number of control points, mean error). It will also say whether fit is good or bad.

If it says "bad" or "really bad" fit, you can go ahead and fine-tune picture alignment as demonstrated below.

Add or Remove Control Points

In the main Hugin window, go to "Control Points" tab. In this tab, Hugin shows which common control points are used to join multiple photos. It shows a pair of photos in left/right panels, and common key points between them are visualized with small boxes of the same color. You can remove any spurious points, or add new common points by hand. The more accurately matched points there are, the better quality stitching you will get. Also, if matched control points are well spread-out, they will be more helpful (than highly clustered control points).

Using the left/right arrow buttons located at the top-center, find a pair of photos which have least common control points. Given such a pair, try adding more common points by hand as follows.

Click one spot on a left-side photo, and then click on the corresponding identical spot on a right-side photo. Hugin will try to fine-tune the match automatically. Click on "Add" button at the bottom to add the matched pair. Repeat this process to add additional common points.

Other Optimizations

You can also try re-optimization. Either click on "Re-optimize" button in the toolbar, or go to "Optimizer" tab to fine-tune the optimization.

Go back to "Assistant" tab in the main Hugin window, and click on "Align" button again to see if you get a better result.

If the combined panoramic view has a wavy horizon, you can straighten out the horizon. For that, click on "Preview panorama" button in the toolbar.

Then click on "Straighten" button in the Panorama preview window.

Once you are satisfied with the stitch result, you can go ahead, and export it to an image file. For that, go to "Stitcher" tab in the Hugin's main window, and do the following.

Adjust canvas size, and amount of crop. Also, select output format (e.g., TIFF, JPEG, PNG). Finally, click on "Stitch!" button.

You will be asked to save a current project file (*.pto), and then specify output file name for the stitched photo.

It will take a couple of seconds to finalize photo stitch.

Here is the output of my experiment with Hugin. This is a beautiful panoramic view of luxury beach front in Cancun, Mexico. :-)

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

9 thoughts on “How to stitch photos together on Linux

  1. I have built a panoramic head, and got a wideangel-lens. Hugin does a good job, but sometimes there are little mistakes left, and you have to do by hand.

  2. Nice tutorial. One thing to note is that it's based off an older version of Hugin, and if you are running Ubuntu 13.10 (Saucy) then you will have the newer version (2013.0.0). The only problem is that the newer version had a complete interface overhaul, so the above tutorial won't make any sense at all to someone running the newer version.

  3. I've been using Hugin for some time now and it does a hell of a job. However, I haven't found any tutorial on how to simultaneously stitch a panorama whilst enfusing every "tile" from a series of hand-taken bracketed images.
    I'm able to do this when the bracketed pictures are taken with the help of a tripod, but I can't get the hand taken photos to align properly, getting a ghost effect in the final output.
    Any help would be greatly appreciated.

  4. Tip for panoramas:
    Use a tripod. Get a hot shoe mounted spirit level. If you are taking more them 3 frames then take the shots in portrait. Otherwise you can get a landscape which 10 inches by 48 inches. Note, as you pan toward the sun the sky will not be as blue, so be prepared for a bit of work in the Gimp.

  5. You got it correct when you described Hugin as "Hugin is an open-source (GPLv2) free". Then you ruined it by describing it as "open-source freeware". At no time is Hugin Freeware. It may be available at no cost, but that is incidental.. the devloper/distributor is entitled under the terms of the GPLv2 to charge any amount of money for the Binary, so long as they make the source code freely available. Read the GPL.

    Freeware is and always will be proprietary software, for which no source code is available, that is made available at no monetary cost. There may well be some other cost associated with it, such as advertising or crippled functionality or even some other hidden cost. But Freeware is rarely made available without some other agenda.

Leave a comment

Your email address will not be published. Required fields are marked *

Current day month ye@r *