SourceForge.net Logo

2D to 3D Conversion

The hard way - doing it by hand

Let us assume that we want to create a variant of the 2to3 logo. We start out with the left-hand picture:

We want to make a stereoscopic picture from this one that has the digits standing out in front of the window, so we load it into our favorite image manipulation program, put the digits in a separate layer, and shift them off to the left, obtaining something like this:

Now, we combine both pictures into a crossview image suitable for freeviewing, putting the newly created right picture on the left side, and the original left picture on the right:

This image can be viewed by crossing one's eyes until both pictures merge.
Alternatively, one can create an anaglyph image by separating the RGB color channels of both images and combining the red channel from the left image with blue and green from the right:

This method works quite well for simple cases like this one, but for realistic images it tends to get tedious - one has to use a larger number of layers, shift them off by different amounts, fill the gaps that are created by shifting, and do all this over again if the result is not right (for example, if the stereo effect is too weak or too exaggerated).

There is a simpler idea available, though:

Using a depthmap

The idea here is to create another grayscale picture the same size as the original image that encodes depth by intensity - regions in the original image that should be farther away are painted darker, those that are closer to the viewer are painted in a lighter shade of gray. Of course, one needs a special utility to convert this pair of pictures to the appropriate stereo views. There are programs like Bas-Relief available for this purpose, but they suffer the drawbacks that they run under Windows only (although at least the demo version of Bas-Relief can be used under wine), that there are no open-source solutions, and that they are somewhat expensive for what they actually do. Thus, this project aims at creating an open-source, multi-platform utility for this purpose.

Coming back to our example, the pictures shown above have all been created from these pictures:

using the command
2to3 -d 0 -o 20 -tpng 23a.png 23ad.png
2to3 is mainly a command line utility; it can read images in the JPEG, PNG, BMP (only uncompressed 8 and 24 bit), and PPM/PGM/PBM formats, and do some tweaking of the depth map, too. For shellenged Windows users, there is also a simple GUI version (which will run under Linux/wine, too, if anybody wants to do that). You can get it from
Sourceforge project page