Single Image Random Dot Stereograms
Single Image Random Dot Stereograms are 3d images created by tricking the eyes into seeing the same picture at different positions.  The brain percieves distance by two methods.

Firstly, if it knows how large an object is, it can judge it's distance by how small it appears.
Secondly, the brain can figure distance by the position (convergence) of the eyes when focused on it.

Stereogram images work on the second method.  A good example of this would be to stare at a section of wallpaper with a repetitive pattern and force your eyes to cross.  The wallpaper will move closer to you and appear to hover in mid air. This is because normally your eyes converge/diverge as you look around and will automatically track distances so that both eyes are focused on the same point.  If you force your eyes to converge more than they need to, they will eventually see the same image due to the repetition of the pattern and they will remain focused in that way although they are not actually focussed on the same point.  Since they are both seeing the same image, they must be correctly focused!! Right??
Here is a diagram showing how this works:
Return to Stereogram Page
You can see from the above diagram that when the eyes are crossed to focus on an image, they are tricked into percieving the image as being placed at the point where the eyes cross.  Keeping the illusion is difficult because as soon as the brain finds the images differ too much, it will try and re-focus and the image will fade away.  As your eyes move along the image, they will follow the 'virtual' contours of the image in the same way that they do when examining a real object except, they are actually following two images at once.  This is the main problem people have with seeing these pictures and causes the image to fade away as soon as you see it and try to examine the object in 3D.  To avoid this, when the image becomes visible, retain focus for several seconds before slowly moving your eyes.

So how do I create one of these images??
You need two things:
A pattern of random dots with NO repetitions or a tiled image with repetitions at fixed intervals.
A two dimensional table of  values whereby the rows and columns represent X and Y and the values represent Z.
Basically, the table is scanned from left to right working down (like reading a book) and a formula is then used to calculate the position of the two pixels.  Look at the diagram below to see how the formula works:
In the above picture, the grey line is perpendicular to the point represented by the X and Y coordinate being processed.  Based on Z value, eye separation and observer distance, two offsets from the original x coordinate can be created.  Take the color at these  X and Y coordinates from the background picture and place that colour at point A and B.  This will then cause the same points to be seen when the eyes are crossed at point Z. I won't include an explanation of the actual formula since this is only intended as a simple explanation and the formula needs to be explained in a lot of detail.

Simple as that!  Not quite.  For every point seen, there are two points drawn which means there is twice as much being drawn into the same place.  This means that most of the points will be overwritten.  This will cause the image to have 'phantom points' all over the place due to points which conflict with other points and the 3D illusion won't work.  The way to overcome this is to apply 'hidden surface removal' techniques which involve rendering only points which are closer to the observer than the points which would be overwritten.  You could process the Z values for each line in sequence from closer to further and not overwrite any points or any of a number of other methods.  My method uses an array which represents the x plane and a z value is written to the equivalent locations to the two points.  The numbers are written only if the points are either empty or if the new Z value is closer to the observer. 

The best way to practise viewing these pictures would be to take a tiled image and practise with it first.

G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G     G       
O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O    O H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H   H  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A  A R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D    D

Try the text above and see if the letters can be made to jump out of the screen.  If you can make it work, retain focus for several seconds then move up or down a line whilst keeping focus and then, try moving up and down (G-O-H-A-R-D-R-A-H-O-G-O-H-A etc).  This is a good exercise for keeping the illusion focused whilst moving to different distances.

You could also try focusing on the background wallpaper on this page and you will find that the repetitive nature of it will bring on the same illusion. I have left a large amount of empty space at the end of this page so you can scroll right down and try it out without text making it more difficult
Try viewing this background with your eyes crossed.