Open Source Corner
Stitching Images the Open Source Way
by Stacey Falconer
any advanced photo editors have the ability to stitch multiple overlapping images together. Most digital shutterbugs look at the word stitch and think of panoramas; a good understanding of these tools can unleash a tremendous amount of creative potential.
Since this is Open Source Corner, we are going to focus on an application called hugin, and a few associated programs. Hugin can be used to simply stitch a panoramic image together, but can also do the following:
- Increase the mega-pixel resolution of your camera.
- Create 360degree VR (Virtual Reality) images.
- Scale images using powerful interpolation algorithms
- Adjust architectural images for perspective distortion.
- Adjust for barrel and pin cushion distortion.
- Stitch scanned images, such as large artwork.
- You can even adjust for transverse chromatic aberration!
How to Increase the Mega-pixel Resolution of Your Camera:
First we need to dispel the myth that double the pixel count will double the resolution. Say you have a 5 megapixel camera. Now, there are a bunch of new 10 megapixel cameras for sale—why not purchase up? To double the resolution in both x and y dimensions, it is like adding floor size—you will have to add not twice the area, but 2-squared, or four times the area.
In reality, your new ten-megapixel camera will have less than a 50% gain in resolution (square root of 2, or 1.4), not double the 5 megapixel camera. To get a true doubling of resolution you will actually need a 20 megapixel camera.
A way of creating multi-megapixel images with a digital camera is to tile a bunch of overlapping images with a stitching program. Hugin can do that and much more. Hugin is an open source stitching program that can be found at www.hugin.sourceforge.net, along with some user friendly tutorials.
Hugin is not an easy program to install and get good results right from the start. I worked at it for some time before getting my first real stitched image that didn't look like it had escaped from Dr. Frankenstein's lab. Fellow club members asked me why was I working so hard trying to get results out of hugin when I could easily use the equivalent tool in Photoshop or PhotoImpact? It was tough going but the results were worth it. A really complex program with a large number of variables and a whole lot of options can give those who work at it that much more image manipulation power.
Hugin doesn't just stitch images together. It can scale images up or down with complex, very high quality interpolation algorithms that can put bicubic interpolation to shame. Hugin can be used to correct for barrel and pin cushion distortion. It can be used to critically straighten convergence lines. Hugin can (with autopano-sift), auto-select control points to use when stitching, and (with enblend) can blend and colour match the overlapping portions of an image to make them seamless. Hugin can also be used with the ptstitcher program to do the same. Though parts of ptstitcher are not open source, it is freely available for non-commercial use, and offers a few advantages.
So, as I suggested above, hugin can be a frustrating experience at first. Did I say frustrating? Try repeatedly smacking your forehead with a brick for a few weeks. It's not that there's not enough documentation, there's more than enough tutorials on line to get you started. It's the complexity of the program that rocks the learning curve.
If you're not one of Don Cherry's 'Rocket Surgeons,' hugin's successful application to images relies heavily upon external tools, most being open source and covered under the GPL. Here are the most important ones:
Autopano-sift
Autopano-sift is itself covered under the GPL, and can significantly reduce the pain and suffering of using hugin. I run it separately to create a .pto file, that is then opened and further manipulated with hugin. If used with Win-XP, autopano-sift needs to have .net2 installed. In Linux it requires an equivalent open source application.
There are some good tutorials on how to use autopano-sift, and, like hugin, it has a large number of options, so it is wise to get a modicum of familiarity with their use from the online tutorials.
Ptstitcher
Ptstitcher is an optional stitching engine that is run from within hugin. It is closed source, but is freely available to download and use for non-commercial purposes. In Windows, ptstitcher is not really installed, just unpacked, and the hugin preferences modified to reflect the path to ptstitcher.
Ptstitcher has a few advantages over the nona stitching engine that comes embedded with hugin. It comes in a tool suite called panotools, which also includes a GIMP plugin.
Enblend
Enblend is an optional blending tool when not using ptstitcher. It will blend overlapping edges together, and colour match images based upon an anchor image. Enblend must be installed separately from hugin.
Suffice it to say that demonstrating hugin and it's associated software is well beyond the scope of this simple article. If any members are interested in exploring hugin and programs like it, as either a Special Interest Group, or as a multi-session course, then please contact me at: training@bbc.org.



