Several years ago, somebody showed me a program called "Autostitch," which uses some new technology to automatically assemble one large image from a lot of overlapping small ones. So I thought I would try this in the desert this year, and brought back two sets of pictures meant to be stitched into two large panoramas, one at Aguereberry Point and the other at Eureka Valley.
I figured that with the passage of several years, the state of the art would have advanced to the point that I would have half a dozen stitching programs to choose from. Half an hour of Google searches later, I was extremely annoyed to find that this is not the case. There is still almost nothing available except the crappy binary-only crippled Windows "demo" of Autostitch. How can this be? It turns out the professors that wrote it have patented the algorithm and are trying to sell it. Great.
So, with Autostitch off the table, is there still any way to get this done? The answer turns out to be yes, barely. I will spare you the many false starts and talk about only the tools that eventually worked.
Taking the source pictures
You have to be mindful of a few things when you take the pictures you are going to stitch together. Mostly, you want to eliminate as much variance across the scene as you can. So, find the place you want to stand, and set your camera to aperture priority. Assuming this is in daylight, you probably want f/8 or f/11. Make sure the ISO setting is fixed, if your camera has an auto-ISO mode.
Now you have locked down two of the three variables that determine the exposure, and need to find a shutter speed. Sweep the camera across the scene, and observe the meter. If you see more than about 2½ stops variance, you might as well give up now, because the end product won't have enough range. Otherwise, pick a shutter speed that looks like it will cover the most ground. Better to be a little under than a little over, so a half-stop faster than the midpoint of the scene is probably about right. Both of my scenes were shot at about f/9 and 1/1000 at ISO 100.
Switch to fully manual mode and dial in the aperture and shutter speed you chose. You might want to switch to manual focus, too, or lock the focus to infinity. Taking landscapes at small apertures, it doesn't really matter. If you are stitching pictures of closer subjects, you'll have to balance depth of field as well.
Now start taking pictures like a crazy man. I didn't fuss about rotating the camera around the nodal point of the lens, because again, tiny parallax errors don't really matter on distant scenery. Don't worry about keeping the horizon level or making precise overlaps, that doesn't matter either. Just make sure there's plenty of overlap, and be aware that anything moving while you are shooting will make life difficult later. I usually shoot raw files, but I turned that off for the panoramas to save time and space.
Generate control points for stitching
The process of assembling the panorama depends on "control points," which means that you tell the stitcher that point P in image A is the same as point P' in image B. You need a handful of control points for every overlapping pair of images, and you can mark them all by hand, but you probably have better things to do with a weekend. So you want a tool that can apply the SIFT and RANSAC algorithms to identify overlaps automatically.
The best we can do for now is autopano-sift, written by Sebastian Nowozin, a grad student in Germany. It has only one glaring flaw, which is that for some unfathomable reason, it was written in C#. Sigh. So off you go to download the 100MB Mono runtime before you can run the 23k of code you need. Once you have gotten it to run, it's easy to use:
# mono autopano.exe eureka.pto IMG*.JPG
Come back in a couple of hours, and eureka.pto is ready to go.
Transform the source images
Next, you need to use a thing called hugin to apply the affine transformations (translations, rotations, skew) to your source images. This is a GUI frontend that thinks it can run the autopano and enblend steps for you too, but I found this awkward and unreliable, as GUI wrappers that rely on command line tools to do the heavy lifting usually are. (I would know, having written one called flacenstein.) So I would recommend that you only ask hugin to do the transformations, and maybe fool with the control points if you want.
Open the .pto file in hugin, and run the thing called Optimizer. This calculates various distortion constants, which I didn't bother to learn what they were, but hey, if there's a button labeled Optimize, how can you not push it? Then go to Stitcher. The projection you probably want is equirectangular. Go ahead and click "Calculate Optimal Size," but think about what you are going to do with the finished product before you accept the "optimal" size. I was using so many source images that the 1:1 output size was about 50,000 pixels wide, which is too many. Printed at 200ppi, that would be over 20 feet wide. So I saved many hours of rendering time by limiting it to 20,000x7,000 or so.
Set the output image format to Multiple TIFF, turn on either kind of compression, and check the "Save cropped images" option. (If you leave out compression or cropping, it will still work, but you might fill up your disk. Each output TIFF tends to weigh a few GB.) Leave the stitching engine set to nona, since it doesn't matter. Click "Stitch Now," and go entertain yourself for another hour or two.
Blend the source images together
When you come back, if you didn't fill up your hard disk and crash, you will find a collection of TIFF images that were generated one from each source image. If you open one of these for fun, you will see that it's just the source image, rotated and distorted as necessary and placed inside a huge blank field. Now you want to lay these all on top of each other and melt them down into one combined image. For that you use enblend, which came in the Hugin bundle (also available on its own).
suntop:bin mikey$ cd /Applications/HuginOSX.app/Contents/MacOS suntop:MacOS mikey$ ./enblend -o eureka.tif stitched*.tif
This also takes a long time, but when enblend finishes, you're done...almost. More precisely, you're done if you want a TIFF file and are completely happy with the projection you got. If not, you'll want to apply the finishing touches in Photoshop. I hate to say it, but the Gimp is just too painfully slow on images of this size. Anything that triggered a screen repaint, such as clicking on a menu, meant a five minute wait. Photoshop was running laps around it.
All done, here is a finished product:
What to do with it now, is an open question. Kacirek tells me it is possible to get one massive print, using the people that make the prints for the gigapixel project. Otherwise, I was going to slice the finished image into tiles and print them at any standard size, possibly the 10x10 squares from mpix. I thought that if the tiles were mounted on foam board and hung at the right spacing, one might create the appearance of a window. Or at least, this idea might work if executed by a person of sufficient artistic ability.
30 Mar 2008 02:31 PT - persistent link - trackback - 1 comment

4171622

