KNOW HOW Panoramas

Perfect Panoramas with , Enblend, and Autopano-SIFT 360 Degree View

You can create a pleasing image by aligning multiple landscapes to form a panorama. But the alignment can be tricky, especially if the individual photos do not match.Tools like Hugin, Enblend, and Autopano-SIFT help you create that perfect seamless panorama. BY OLIVER FROMMEL

f you have more pictures than you problems start. It is difficult to achieve can help correct this can fit in one image, you may wish to soft and invisible seams. Normally, pho- kind of , align the individual Itry the old trick of combining multi- tos are so distorted that it is impossible images, and finally, mount the images to ple digital photographs into a pleasing to correct them manually. The lens is create a panorama. wide-angle view. But you’ll find it diffi- partly to blame; lenses typically distort cult to combine these photos into a images, turning straight lines to curves Equalizing and Aligning seamless image using just the Gimp. that make photo composition difficult. Photos This article discusses some alternative The other reason is the distortion The Hugin [2] graphics program displays tools that you can use to automatically caused by shooting a series of pictures. If the images, allowing the user to select adjust and align images. These tools will you remain stationary and turn the cam- neuralgic points for equalizing and align- help you create seamless panoramas era left and right, the objects on the right ing the images. from separate photographs. of the image will appear too big, The program is easy to install, but it It’s easy to take a series of digital pho- whereas the objects on the left appear requires a few libraries that some distrib- tos for a panorama, but this is where the too small. utions do not include. Check out the “Installation” box for more details on the Box 1: PanoTools install. For a long time, the PanoTools package was Because the program’s author,Helmut GLOSSARY the only free software for creating Dersch,no longer has the software on his panoramic images.The PanoTools license own homepage,other people are offering Roll,Pitch and Yaw are all terms for spatial conditions have always been complex.The the old packages. In fact, there are even rotation about three axes. Roll describes a library and PTOptimizer are released under some commercial offshoots,although they rotation about an axis perpendicular to the the free GNU Public License,whereas various may not be quite legal. A Sourceforge project image plane,pitch is the rotation about a licenses apply to some of the individual has since been founded to maintain the free horizontal axis,yaw is the rotation about the programs. parts of PanoTools [1]. vertical axis.

48 February 2005 www.-magazine.com Panoramas KNOW HOW

Box 2: Installation Hugin needs the WxWidgets library from complaining about a missing package Debian does not have additional wxGTK (formerly WxWindows) and the WxWidgets- because the package dependencies are packages that include “xrc” in the package XRC extension. Most distributions include wrong.The workaround involves specifying names; look out for libwxgtk2.4-contrib-dev the other required libraries,such as Libtiff, an RPM program option to disable the instead. You can use the following dependency check: LibPNG,and LibJPG. Besides the FFTW math commands to install the required libraries, package,Hugin also needs the Boost Library, rpm -iv --nodeps hugin-0.4-cvsU LibPano, and Hugin (both of which are on the if you intend to build Hugin yourself. 20041021.bp.fc2.i386.rpm DVD with this issue): Unfortunately, the version and name depend apt-get install libwxgtk2.4-dev U on the distribution. For example, the Boost Although Suse has a version of WxWindows developer library for Fedora is simply called by default,Hugin cannot use the default. libwxgtk2.4-contrib-dev fftw2 U libboost-devel; Debian users need three Thus,you will need to remove the existing dpkg-i libpano12_20040917-1_i386. packages called libboost-graph-dev,libboost- package and use the Fedora packages deb dev and libboost-python-dev. instead – don’t worry, this worked fine with dpkg-i hugin_0.4pre20040917-1_i U Suse 9.1 in our lab: 386.deb The required files for Fedora are located in a U subdirectory on the DVD.The following com- rpm -iv panorama-tools-2. Whether this will work or not depends on mand installs the libraries: 7a-1.i386.rpm wxGTK-xrc-2.4.U the software and libraries you have installed 2-4.1.fc2.dag.i386.rpm fftw-2.1.U previously.If you are still missing a package, rpm -iv panorama-tools-2.7a-1.U 3-1102.i586.rpm hugin-200409U you might like to try googling for the pack- i386.rpm wxGTK-* fftw2-* 21-1.bp.fc1.i386.rpm wxGTK-2.4.U age name and required package format.The The include libpano12,but 2-4.1.fc2.dag.i386.rpm boxes for Autopano and Enblend give you this does not stop the package manager more detail on the requirements.

After you type hugin to launch the pro- The second tab, Camera and Lens, is Manual Control Points gram, the main window shown in Figure for correcting optical distortion caused Hugin needs a few definitive image 2 appears. Click on Add individual by the camera and lens. If your images details to be able to align two adjacent images… to select individual images. In include EXIF information, Hugin can images correctly. The Control Points tab the dialog that appears, you can hold automatically extract the required data. handles this. The tab shows you two down [Ctrl] and click to select multiple If you do not know the angle of view for images, allowing you to click on signifi- images. your lens, refer to Table 1 (extracted cant points to create assignments. Hugin displays a list of images in the from PanoTools documentation). First, set up Hugin to display two adja- panel on the left, adding some details, The Inherit switch allows all the other cent images by setting the number in the such as the width and height; the rota- images to inherit the settings from the tab above the right-hand image one tional values (Yaw, Pitch, Roll) are also current image. If you disable this setting, higher than the left-hand tab (Figure 3). displayed, although they default to zero. the program can handle images with In other words, if both are 0 when you Hugin uses the first photo as a reference different distortion values. After discov- start, you need to set the right-hand tab point for aligning the other images. The ering the best values for your camera (by to 1. You can then use the arrow keys to “Anchor this image …” button allows trial and error), you can store these val- flip through the images, and Hugin will you to select another image as the refer- ues under Lens Management and load show you consecutive images on the left ence point. them for your future Panorama projects. and right.

Figure 1: Loading the individual images in the Hugin main window. Figure 2:The Camera and Lens tab.

www.linux-magazine.com February 2005 49 KNOW HOW Panoramas

Figure 3: Hugin displays two adjacent images, allowing the user to select Figure 4:The Optimizer tab supports granular control of the optimization image details as control points. values automatically set by Hugin.

You will want to check auto fine-tune Anchor) option for the Optimizer, and Optimizer, you can manually set the val- and auto-estimate, as this tells Hugin to then click Optimize now!. The three text ues for each image – this is a setting for help you assign the control points. auto boxes below display the image number experts. add tells the program to add each and the value by which Hugin needs to The Preview in the bar at the top gives mapped pair at the specified points – you correct the individual image, following you a preview with the calculated val- can do this manually by clicking the Add the square brackets with or without a ues. You might want to select Auto in the button. checkmark. If an image is not checked, preview window to tell the program to If you have enough points, you can this means that Hugin will not be modi- show you the latest results. switch to the number crunching part by fying it, which is the case with the clicking Optimizer (Figure 4). Check the reference image (Anchor). If you select Mounting Images Positions (pairwise optim., starting from the Custom parameters below for the The final tab, Stitcher, is the heart of the program – and the biggest challenge at Box 3: Mono for Autopano the same time; things don’t always work Autopano-SIFT is written in the C# program- mount -t binfmt_misc none /proc/U out as expected. Stitching is the process ming language and needs the Mono project sys/fs/binfmt_misc of putting multiple images together to create a panoramic image. libraries [3].To use the software,you do not Finally,you need to tell the kernel how need the complete Mono environment.You to recognize Mono files and launch This process typically implies aligning do need the interpreter,which runs the pro- mono. the images and correcting distortion gram,and a few libraries.The Suse packages echo ':CLR:M::MZ::/usr/bin/mono:' U beforehand. Hugin supports two so- are mono-core-1.0.2-1.ximian.9.1.i586.rpm, > /proc/sys/fs/binfmt_misc/register libicu26-2.6.2-1.ximian.9.0.i586.rpm,gtk- Assuming that your exe files are executable Box 4: Enblend sharp-1.0.2-1.ximian.9.2.i586.rpm, (chmod +x),you can now launch them The Enblend package [6] does not need any- libgtkhtml3.1_7-3.1.13.0.200405120525- directly.You still need to unpack Autopano- thing special in the line of libraries,apart 0.snap.ximian.9.1.i586.rpm. Fedora users do SIFT [5].To do so,you can either launch right from LibTIFF and LibJPG. Under Fedora and not need the libgtkhtml package. into /path/to/autopano-sift-2.0/bin/ Suse,you can install Enblend by typing Debian users should add the Apt repository autopano.exe or use the Mono program rpm -iv enblend-2.0-1.bp.fc2.U to /etc/apt/sources.list,and install the mono, mono /path/to/autopano-sift-2.0/bin/ i386.rpm. libgtk-cil and libglib-cil packages via the com- autopano.exe. If all of this works,Autopano Unfortunately,binaries are not available for mand line.The Mono website at Debian [4] should output a short help text. If the bin every distribution,and you may need to gives you more detail. subdirectory is in your executable PATH build Enblend yourself,which again necessi- Exe files written in Mono are launched by variable,you do not need to enter the full tates installing more software.The typing mono program.exe.The kernel-based pathname.This is also the best way of following line handles the install on Debian: testing the GUI-based version, Binfmt-Misc module can execute Mono apt-get install libjpeg62-dev U bytecode directly.Most distributions include autopanog.exe. libtiff4-dev libpng3-dev fftw-U the module by default. If your automounter To allow the autopano-complete.sh script to dev libboost-graph-dev libU does not load the pseudo filesystem work,you need to set up your PATH variable boost-dev libboost-python-dev required to use this functionality, try the as described,otherwise the script will com- following command: plain that it failed to find an “assembly.” You can now go on to compile Enblend.

50 February 2005 www.linux-magazine.com Panoramas KNOW HOW

nal Enblend program, which Hugin does not Table 1: Lens and Field of View support directly, and Focal length Field of View Landscape Field of View Portrait which entails an extra 28mm 65 46 35mm 54 38 step. First, use Hugin 50mm 40 27 to create a series of TIFF images, which are correctly aligned but run the script and don’t forget to specify not stitched. Then select the output file (using the -o parameter), the option into a layered which Hugin then parses later, as well as TIFF file for Stitch the the individual images. images (see Figure 6). The program will then autopano-complete.sh -o output U automatically select Mul- left center right.jpg tiple TIFF as the output format. Click on Stitch As an alternative, you might prefer to Now!, and Hugin will use the GUI-based autopanog.exe front- prompt you for a file- end, which does exactly the same thing name, appending a four but at least saves you typing the file- digit number to the file- names. When you load the resulting PTO name for each image. You file with Hugin, you will need to set the Figure 5:The individual images are in the right order, but the seams can then pop up a termi- degrees of view in the Camera and Lens are clearly visible. nal window to stitch the tab. The Optimizer and Stitcher steps are TIFFs using Enblend; use as previously described. called stitching engines; the stitching the -o to specify the output file name: engines are the software modules that Where To Next? actually put the panoramic image enblend -o panorama.tif U These tips should help you get started together. The Nona stitcher supplied pic0000.tif pic0001.tif U with creating your own panoramic with the program works quite well, pic0002.tif images. The fact that we have not even although the quality is not quite up to looked at many of the vast range of avail- scratch. A visible seam appears in the The results are quite impressive. able options and menus just goes to final product in most cases (Figure 5). Enblend stitches the images without ugly show the potential of tools such as Before you start stitching, make sure seams . Hugin. you select Calculate Field of View to A friendly mailing list covers the latest recalculate the field of view. Only the Automating Control Points Panorama software developments, with program’s authors know why Hugin If all of this involves too much clicking users who are quite happy to help new- does not do this automatically. Similarly, for your liking, you can use another pro- comers. It is safe to assume that the you will need to modify the image size gram to automatically set the control minor bugs will be removed from the by selecting Calculate Optimal Size. If points. Autopano-SIFT will even find program shortly. And if you feel like you use the Nona stitching engine sup- matches that are invisible to the human helping out after reading this article, plied with the program, the JPG image eye in your images. To launch the tool, then why not? format will be pre- selected, and you INFO can simply click [1] New homepage for the orphaned Pano- Stitch now!. tools:http://panotools.sourceforge.net/ A short time [2] Hugin:http://hugin.sourceforge.net/ later (or possibly a lot later, depend- [3] Mono Downloads:http://www. ing on the size mono-project.com/downloads/ and the number [4] Mono on Debian: of images), you http://pkg-mono.alioth.debian.org/ should have the [5] Autopano-SIFThttp://user.cs.tu-berlin.de/ final image on ~nowozin/autopano-sift/ your hard disk [6] Enblend:http://enblend.sourceforge.net/ under the name [7] Packages for various panorama tools: you selected. http://bugbear.blackfish.org.uk/~bruno/ The alternative panorama-tools/ is to use the exter- Figure 6:The Hugin stitching module supports a variety of output formats.

www.linux-magazine.com February 2005 51