Here are the steps used to convert a pair of left-right stereoscopic images into a single red-cyan anaglyph. Yes, it is rather tedious, but it's nice to be able to understand the process. (I'm waiting for anyone who can point me to an anaglyph plug-in for gimp that actually works.)
| Note: These instructions refer to the 1.x version of The Gimp. Version 2.0 has since been released. All the tools are there, but some are found in different places. |
An anaglyph is a full-color image in which the left-eye image of a stereo pair is used for the red channel, and the right-eye image is used to encode the blue and the green channels. When the anaglyph is viewed with red-blue or red-cyan glasses with the red lens over the left eye, the left eye sees only the red channel, which came from the left image, and the right eye sees only the blue or blue & green (cyan) which came from the right image. Somewhat surprisingly, full-color stereo pairs can be successfully used to create red-cyan anaglyphs so long as there is neither too much red or blue in the original; images with lots of green (as in nature) seem to work especially well as full color anaglyphs.
The separation and combination of the color channels can be trivial, as in this script using the netpbm tools:
ppmtorgb3 ${1}.ppm
ppmtorgb3 ${2}.ppm
rgb3toppm ${1}.red ${2}.grn ${2}.blu >$3
However, it is usually necessary to make manual adjustments to the alignment of the two images in order to get an anaglyph that is pleasant and easy to view – doesn't make you cross-eyed. The steps below show how I do this using The Gimp image processing program, version 1.x. (If you have more money than sense, Adobe Photoshop will work, too.)
Get started.
You need a pair of stereoscopic images to start with. Here are a pair of images of some beautiful land on Mars I'd like to sell you. These were taken by the Spirit Mars Exploration Rover.
I usually load both images in The Gimp and work with layers in the left image. Using the Layers, Channels and Paths dialog, create a transparent layer in the left image. You could name the layer "R" just to help keep in mind that that layer is for the right image.
Select the right image and hit Control-C to copy it into Gimp's copy-and-paste buffer. Select the left image and hit Control-P to paste it into the top "R" layer. (You might make sure that that layer is what is selected for operations (highlighted) in the Layers dialog.) The pasted image will initially appear as a floating selection in the Layers dialog.
Click the anchor button to anchor the selection in place in the top layer. You can now close the frame holding the original right image.
Align the images.
Usually you can only see the top layer in an image. In the Layers dialog, move the Opacity slider to around 50%. Now you can see the bottom (left) layer showing through the top (right) layer:
Notice that with this image pair nothing is aligned; there is no point where features of the left and right overlap. For comfortable viewing you want the foreground to be aligned and the background diverging more as you go deeper into the image.
Choose some feature in the foreground of the image. With the top "R" layer selected, use the Move tool to grab and slide the right image around until the left and right version of the feature are aligned. Here I've chosen to use the dark rock in the right half of the images near the bottom. I slid the top image to the left and down a bit until the foreground aligns and the rock looks sharp. Slide the Opacity control back to 100% opaque.
Crop the layers.
The yellow-and-black dashed lines show the orientation of the top layer relative to the bottom. We need to crop the image so that it encompasses only those parts of both layers that overlap. Select the area inside the dashed lines and crop it.
To make sure that the image is now composed of two equally-sized layers right-click on the image and select Layers-->Layer to Imagesize. Select the other layer in the Layers dialog and repeat to perform the same operation on the other layer.
Separate the color channels.
When we have two identically sized, properly aligned layers it's time to separate out the color channels for the left and right images. Remember that the top layer may be shown, but operations happen on the layer that is selected in the Layers dialog. Select the bottom (left) layer.
Right click on the image and navigate to the Mode dialog.
Select Decompose. When asked, choose the RGB method of decomposition. Three grayscale images will appear labeled red, green, and blue. These are the brightness levels of the red, blue, and green channels of the selected layer.
Close the green and blue image and keep the red; the bottom layer is the left image, and we take red from the left. Select the top layer and Decompose again. From the three new images that appear, throw away the red and keep the green and blue. Make sure you don't accidentally mix up the two red-labelled images you'll have on screen at this point. You want red from the bottom (left) layer, and blue & green from the top (right) layer.
Create the anaglyph.
Select one of the color-channel images and navigate to the Mode dialog again. Now you'll see Compose as a selection. Select it. Here you select the images used to compose the red, green, and blue channels of a new image to be created. Select the red, green, and blue images available from the previous decomposition steps.
When you select the proper channels and click OK, your anaglyph appears.
Be sure to save the anaglyph (right-click:File->Save as...).
Notes
I've also taped two disposable cameras together and shot 24 stereo pairs by pressing both shutter releases simultaneously. You have to be careful to hit both buttons at precisely the same time if your subject is moving. (It doesn't help that some of those cameras take awful pictures.)