Java code to generate and display a random dot autostereogram based on a user-supplied grayscale depth map.
An autostereogram is a 2D image that creates the optical illusion of a 3D shape using one picture rather than a normal stereogram which requires two; this approach is perhaps best known through the Magic Eye series of books.
A random dot autostereogram employs a randomly generated dotted image to tile the background, with the 3D effect implemented using a depth map to offset pixels in the tiles by varying amounts.
I've used an offset based on the amount of black, so darker parts appear to stick out from the image plane. This is coded in just a few lines in genStereo() in Stereogram.java.
Click on the thumbnail depth map images to see them at full size, and on the link to see the generated stereogram. Cross your eyes so that the two black dots at the bottom of the stereogram converge, and then stare at the picture for a while. After a few seconds, the 3D shape will gradually begin to appear.