A program and explanation by Zellyn Hunter, FidoNet 1:362/1203.2
A Random Dot Stereogram (RDS?) is a simple, effective way of representing a 3-dimensional image on a flat surface. Despite the simplicity of the method, the results are quite spectacular.
Viewing an RDS may be a little difficult the first time, but it is well worth the effort, and most people should be able to see a clear 3-dimensional image after a few minutes.
If you wear glasses, it should be ok, as long as your vision is pretty good when you're wearing the glasses. (I can not see RDS's very easily or clearly when I am not wearing my glasses, but with them, it works fine. I presume contact lenses would be the same.)
Seeing the image will be substantially easier if you understand how and why RDS's work. If you feel you don't want to know the technical stuff, you can skip this bit, and try it cold turkey! (Actually, even the theory is pretty simple)
You are able to see depth and distance of objects for 2 reasons:
Hold one finger up about 30cm/1ft away from your eyes, and another one twice as far away, so that you can see both fingers at once. When looking at the nearer finger, the one behind it should appear double.
(If it doesn't, you either only have 1 eye, or else it actually does appear double, but you are refocusing your eyes on the further finger to see if it is double, instead of leaving your eyes focused on the nearer one & looking past it)
When you look at the further finger, the nearer should appear double. The reason is that the further finger appears to the left of the nearer when viewed by your left eye, and to the right from your right eye. When you focus on the nearer finger, a double image of the further finger forms, one to the left and one to the right of the center. The reason that they are half- transparent is that you are only seeing each out of one of your eyes.
You probably have already figured out all this when you were little and noticed that images jumped around when you opened and closed each eye alternately...
Well, now comes the interesting part:
| Diagram 1: X | | . . | | . . | | . a . | | . \___/ . | | . . | | . . | | /O\ /O\ | | \_/ \_/ |
When you look at an object, the lines(dots) from your eyes(those weird things at the bottom!) to the object(X) form a triangle, and the angle(a) tells your brain how far away the object is. With an object further away, the triangle will be more acute, and the angle smaller. Your brain uses the difference in the directions in which your eyes are looking to determine how far away an object is.
| Diagram 2: X | | . . | | . . | | ---x-----x--- | | . . | | . . | | . . | | /O\ /O\ | | \_/ \_/ |
The way and RDS works is to fool your brain into thinking that it sees an image where there is none. Just as one finger can appear as two, two images can appear to be one. In this diagram, the small x's are drawn on a flat surface(----), a screen or paper or whatever. If you then focus your eyes BEHIND the paper, the two little x's intercept the lines of the triangle that your brain uses to measure distance, making an image appear at the large X. (Incidentally, it WILL appear larger- because your brain thinks it is FURTHER away, it also thinks it must be larger if it appears the same size as the CLOSER x.)
What we are doing is essentially drawing hundreds of pairs of dots, and by changing the distance between the dots in the pair, we can make the image of the single dot you see appear closer or further away.
We simply work across the screen coloring each dot the same color as the dot 'd' units to it's left, where 'd' is the distance in pixels between the two dots needed to make it appear further or closer. (The first few columns with x-coordinate < 'd' are just colored randomly)
For instance, to create a flat plane behind the screen, we color each pixel the same color as the one an inch to its left. So dots one inch apart will always be the same color. When you focus your eyes behind the screen, these dots intercept the triangle of vision where it is one inch wide, and you see a plane behind the screen. Naturally there are many dots that do not fit in to the image, ie that are the same color as dots, say, half an inch behind. The important thing is that EVERY dot ONE INCH apart is the SAME color, and the other dots that do not fit in are distributed randomly, and therefore are outnumbered.
Now what we do is use different equations to determine 'd' at any (x,y) location on the screen. If we repeat every one inch over the whole screen, except for a square in the middle where the like-colored dots are slightly closer together, the square will appear floating above the plain. (This is the first image in the program.)
Image number 5 in the program uses the sine of the x-coordinate multiplied by the sine of the y-coordinate to determine 'd', giving an "eggbox" pattern of waves.
If you have Turbo-C, then you can add your own functions in pretty easily. (Or you could convert to another C compiler.) If you don't program, you really should learn to- it's not very difficult and lots of fun. If you don't program in C, you can try to see what the program is doing anyway, or write your own program- good pixel distances are an inch or so (about 70-85 pixels on a screen with 640 pixels across) or about as far apart as the crosses my program generates. Start simple- try generating a flat plane with repetitions every inch or so, and work from there once that works.
Basically, you have to focus your eyes BEHIND the screen, while looking at the image ON the screen. It's not quite as easy as you might think, because you have to "override" your natural tendency to focus on the screen.
I don't think RDS's should really cause eye-strain, because you are actually looking behind the screen and your eyes should be more relaxed than if yo were looking at the screen. If you use this program, and do get eye-strain. I take no responsibility. By using this program, you agree...etc...etc. heh heh heh- now where have I seen THAT before?
Look at the crosses at the bottom of the screen. Now un-focus your eyes, and look "behind" the screen. The crosses should separate and become four crosses. Shift the focus of your eyes until the two middle crosses are on top of each other, and you see three crosses. Look at the middle one- it should appear further away (or closer if you are looking at the RDS backwards)
( You can view an RDS in reverse- by focusing in front of the image, you form a large X-shape between your eyes and the dots- the lines of vision cross and you see the image at the vertex of the X, nearer than the screen. Although this works fine, for some reason it does not give the same effect. Although your eyes are seeing the image the same size - the one on the screen doesn't change - your brain will convince you that an image seen "behind" the screen is larger than the one "in front of" the screen simply because of distance. This makes the vertical relief more exaggerated on the further one, and just looks better. You will also see the images in reverse- ie a hill will be a valley and vice versa. Although not usually too important, this makes a BIG difference when looking at an RDS of, for instance, a human face. I can see RDS's both ways, and believe me, faces look pretty weird viewed backwards! Sorry- no faces in my simple program; see the section near the end.)
Anyway, once you can see the middle cross, the trick is to look at the image above WITHOUT ALTERING THE FOCUS OF YOUR EYES. This is probably the most difficult part of trying to see an RDS. If you find you can't look up without altering your focus, try without looking at the crosses. ie Just focus behind the screen while looking at the image -not the crosses- and use the crosses only once in a while to check whether your focus is correct or not.
Some other tricks: Try looking at an object about twice as far away from your eyes as the screen is, over the top of the screen. Focus on it, and then slowly lower your eyes to the screen.
Whatever you try, it will probably not work immediately, but if you understand what you are supposed to be doing, you should have it in a couple of seconds.
Good Luck, and try not to stare at the old computer screen for too long!
Written in Turbo-C, the program is quite simple. The main function sets up the graphics mode, using standard BGI graphics. (Yes, there are nicer ways, but I wanted it to be fairly general.) It sets up some global variables like the maximum X and Y values, the midpoint-of-screen X and Y values, and the number of pixels in X or Y that make up "1000" units. The original program used a 640 by 200 screen, and these values were coded in as numbers. I have replaced all numbers with variables or expressions, so it will work on any screen (as long as its actual physical dimensions are similar.) For instance, "20" in the original program becomes ( iX1K / 50 ) or ( iY1K / 50 ) depending on whether we are dealing with X- or Y-dimensions... messy, but it works!
The main program then calls the routine that actually draws the dots, passing it a pointer to the function it must call to find out the distance between identical points at any (x,y) location. By changing this to point to your own function, you can make almost any shape.
I have seen RDS's of a human face, and also Mandelbrot sets. A mandelbrot should not be too difficult.
Feel free to change or warp the program in whatever way you want, but give me credit, and please try to send me any improvements!
All the information came from a South African magazine called:
"archimedes Die natuurwetenskaptydskrif vir die hele gesin The natural-science magazine for the whole family"
(Punctuation is as on the magazine)
The articles were written by Walter Meyer and Lotz Strauss, Physics Department University of Pretoria. They appeared in the January and May issues in 1992.
The original articles were written in afrikaans, as was the program they supplied, written in BASIC. (My program does not look all that much like the original at all!)
The written description of RDS's above is completely my own, however. It was the articles that got me interested in RDS's, but the January issue simply had the "eggbox" RDS and no descriptions. I figured out how they worked before the May issue came out. In other words, my description is completely by me- it is not adapted or translated from theirs!
As I said above, my FidoNet address is 1:362/1203.2 Please send me mail- I've just got the point running, so mail would really make my day! (It might even get to me!)
Good luck, and try not to stare at your screen for TOO long!
This is part of the Graphics Without Greek collection in the home pages of Dan Lyke , reachable at email@example.com