Autostereograms (e.g., Magic Eye) work in the same way that 3-D glasses and Viewmasters (the children's toy) work...

Binocular disparity refers to the slightly different (disparate) view that your two eyes have of the same object or scene (i.e., because your eyes are a few centimeters apart, they view any given object from slightly different angles.

3-D images are created with binocular disparity in mind: if you overlap an image drawn to show what your right eye sees with the same image drawn to show what your left eyes sees, binocular disparity produces a 3-D perception of the image!

This is essentially how autostereograms work: a similar illusion of depth can be created by superimposing two repeating patterns of dots in a single filled space, somewhat offset from each other, in such a way that some segments of repeated dots in one pattern are displaced farther from their counterparts in the other pattern.


 

Excerpts from this summary were taken from: Gray (2002)