_ __                 ______                         _ __
' )  )                  /                           ' )  )
 /--' __.  __  ,     --/ __  __.  _. o ____  _,      /  / _  , , , _
/  \_(_/|_/ (_/_    (_/ / (_(_/|_(__<_/ / <_(_)_    /  (_

Compiled by Eric Haines, 3D/Eye Inc, 1050 Craft Road, Ithaca, NY 14850
	erich at eye.com

All contents are copyright © 1994,1995, all rights reserved by the individual authors.

Archive locations: anonymous FTP at princeton.edu:/pub/Graphics/RTNews, wuarchive.wustl.edu:/graphics/graphics/RTNews, and many others.

RTN is an irregular newsletter edited by Eric Haines. Contact him if you want to be on his subscribers list. Back issues are archived at the above sites though some issues have also been HTMLised by Ture Pilsson and Inge Wallin. The two SIRDS articles are

  1. "SIRDS/SIS/stereograms/Holusions/whatever": a gentle introduction to SIRDS.
  2. "Two Books on Stereograms": a couple of book reviews.
These have been HTMLised by me (PC) and the editor's notes are mine.

SIRDS/SIS/stereograms/Holusions/whatever, by Eric Haines

Everyone's doing it. You've seen them in card stores, you've seen them in malls, you've seen them in, um, card stores in malls. Those repeating pattern posters, books, postcards, tea cozies, and antimacassars, which when you focus your eyes just so cause a hidden image to pop out and look three dimensional. Personally, people have waved black and white random dot versions of these in my face for years without me getting it. I finally got it this summer, and can now defocus my eyes and stare off into the middle distance in the blink of, yes, an eye.

What worked for me was looking into my computer screen at one and looking at a reflection in the screen to get my eyes to defocus; there are at least five other methods of doing it, and I leave it to you to find them in the FAQ (next paragraph) or in books. My other piece of advice: don't try to cross your eyes, as this is not usually the way to do it as it makes the images reverse themselves in depth.

So anyway, I thought I'd try to add this capability to my renderer. After puzzling through the SIRDS FAQ (which can be FTPed from katz.anu.edu.au [150.203.7.91]: /pub/stereograms, and the FAQ is maintained by Stuart Inglis (singlis at cs.waikato.ac.nz)) and trying out a few wrong ways, I came up with a very short addition to my renderer which made some reasonable SIS (Single Image Stereograms). I was going to explain it here in depth, but it turns out there are now a few books that deal with the topic, so who am I to ruin capitalism?

[Ed: See the information page for pointers to the FAQ.]

Actually, I'll give you the five minute description. In creating these images you take a repeating texture pattern and vary it slightly. The pattern repeats horizontally every couple of inches or less, i.e. the repeat pattern must be less than the width between your eyes (so you can defocus and get a separate repetition of the pattern for each eye), and should probably be less than 1-1/2".

Say you just repeat the texture pattern again and again horizontally without variation. You defocus, and the left eye sees a pattern, and the right eye sees the same pattern, but is actually looking at the repetition of that pattern one to the right. Still with me? (if not, think of a picture, say Babe Ruth on a baseball card, and a copy of the Babe right next to it - defocussing makes the left eye look at the left image, the right eye at the right). You all (should) know about stereo pairs, where one image is shown to the left eye and the other to the right and your brain puts them together and gets a 3D effect. This idea of having separate similar images go to each eye is key to SIS.

Now, since the pattern is repeated a number of times, once defocussed, your left eye and right eye can move over the entire image and continue to be in sync. You will perceive the entire image to be at a distance farther from where it really is, as the angle formed by left eye/perceived thing/right eye is a lot smaller than if you just looked at the image normally. Your brain knows that when this angle is small, you're (supposed to be) looking at something far away.

Now, if you vary this left eye/perceived thing/right eye angle over an image, your brain will interpret these variations as changes in depth and you'll see a 3D effect. I've read a fair bit of gobbledy gook about how to vary the depth, about dealing with factors like the left eye seeing parts of 3D objects that the right eye doesn't, and vice versa, but forget all that. Just think that, given the basic repeating pattern being seen by each eye, if the right eye then has to look a little bit to the left of this base pattern at some feature (compared to what the left eye is seeing), then the brain will interpret this feature as being closer, since the angle has become larger.

You now know the essential secret, believe it or not. The basic algorithm starts with a texture pattern that the left eye is going to see and will be repeated. The "hidden object" which is to appear is used to vary this pattern. Say the hidden image is a square floating above a plane. When the background of this hidden image is visible, the repeat pattern is not shifted, when the square is seen, the repeat pattern is then shifted to the left. The closer the object is, the more left-shift there is. [Actually, in practice these algorithms look at the distance from pixel to pixel, and you can start from the right or from the middle of the image, but this horizontal shifting is the basic mechanism] If you look at the image (without defocussing) you'll notice that the pattern repetition is relatively rapid on the square that is closer - this makes your eyes form a larger angle with the perceived object and so you think it is closer.

So, we've started with a pattern on the left (call this pattern #1) and made a copy of this pattern just to the right (call this pattern #2), shifting the data in pattern #1 to the left as required by the hidden image to form #2. Now we move the process over to pattern #2 and use this as the starting point for the next repetition, where we form pattern #3 by shifting pattern #2 as needed. Pattern #3 is used to form pattern #4, etc, until the image is done. Algorithmically it's even simpler than this.

One great feature of these algorithms is that each scan line is entirely independent of the others. That is, you can generate a scan line without any knowledge or effect on the other scan lines, so the entire depth image does not have to be saved. Using the left-to-right algorithm above, you don't even need to keep the whole scan line of z-depths around, since you're shifting as you go along. This is what makes the algorithm easy for ray tracers: you're simply using the ray tracer to get depths as you go and shifting the pattern as you go. Note that you don't really need a ray tracer, though (hey, I had to mention ray tracing, right?) - a zbuffer renderer works just fine for the hidden images, and even just stored images used as depth maps work fine, too. Notice that a single depth map is used for generating the image, so there's nothing special about the image generation process.

The good news is that once you have a half-decent renderer it's pretty easy to add this algorithm to it. My first attempt was about 30 new lines of code to access and shift the texture pattern using the z-depth. The bad news is that once you do the easy algorithm, you notice problems. There's echoing, where pattern repetitions and elements get intertwined in a way that false 3D features appear. There's also a limit to the number of levels of depth in the basic algorithm, making the 3D object look like it was terraced for farming by miniature Southeast Asian farmers. You might try interpolating colors in the texture to get rid of this artifact (I did), and then it just looks blurry on the right side of the image. Me, I finally wrote some additional code that maintains the exact links between repetitions and uses these precise numbers to interpolate between samples for output, which reduces blurring (though I still get some echoing). Anyway, even with this additional code we're talking of a total of around 100 new lines (including whitespace and comments).

I hope this article has given you a flavor of how these images work and are generated. If you're seriously interested, look at the reviews that follow of two books which discuss in depth how to generate these images. Playing with these algorithms (and seeing the sorts of goofs you can make) has given me a greater appreciation of well-constructed commercial images made using this technique. It's also interesting to figure out what went wrong with the bad ones out there. All in all, a cute technique, but watch it: if you defocus too much your eyes will get stuck and you'll see everything in 3D.


Two Books on Stereograms, by Eric Haines

Recently two books have come out about stereograms, _Create Stereograms on Your PC_, by Dan Richardson, Waite Group Press, 192 pages, 8 color plates, $26.95, ISBN 1-878739-75-1, and _Hidden Images: Making Random Dot Stereograms_ by Bob Hankinson and Alfonso Hermida, QUE Corp, 242 pages, 16 color plates, $24.99, ISBN 1-56529-994-9. Each book comes with a disk in the back containing software for the PC.

Richardson's book collects some of the better stereogram generating tools together and describes how to use them and how they work. He spends a little bit of time describing stereogram history and algorithms, then discusses many of the different ways the autostereogram effect can be used. He covers normal text stereograms, random text stereograms, random dot stereograms, image mapped stereograms, and icon based stereograms. Most of these (the exception being normal text stereograms, which are usually made by hand anyway) have one or more free or shareware programs presented along with them.

For random text stereogram generation the SIRTSER program, written by the author, is provided on the disk and does the job. The next program presented, RDSdraw, is a lot more fun. It's an interactive program which is tailored towards making depth images for generating random dot stereograms (SIRDS). It's a fun program in which you can put various objects (boxes, pyramids, ellipses, etc) and text on the screen and turn the image into a SIRDS. Another SIRDS program, MindImages, is also presented. I personally have a tough time getting MindImages images to work for me on my 15" screen because they have a wider repetition distance than RDSdraw, but they are nice when they do work. There is also a cute program called Shimmer which ameliorates echoing and helps some people "lock on" to the 3D image quicker. It's cute, and the effect reminds me of the book _Snow Crash_ (which is a great trashy cyberpunk [or cyberpunk parody, it's hard to tell the difference] novel).

My favorite program is RDSGEN (by Fred Feucht, from a program originally by Alexander Enzmann), for two reasons. One is that it generates image stereograms just like you see in malls, and the other is that source code is actually provided, a boon for explorers who would like to get their hands dirty with a little code. The code provided in the book has evidently been cleaned up a bit from earlier versions out there. If you have internet access, you can find some of these programs at katz.anu.edu.au [150.203.7.91]: /pub/stereograms, though I didn't notice RDSGEN there.

[Ed: Actually, RDSGEN is called rdstuff in its distribution form. Look at my list of PC programs available at katz.]

The book then goes on to discuss other ways of creating depth maps. The wonderful fractal program Fracint is described in this context, and the book's diskette provides some parameter and map files useful for making SIRDS (Fractint itself is not included due to space limitations, but is easy to find on the net at oak.oakland.edu:/pub/msdos/graphics/frain182.zip). Using the POV Ray ray tracer with fog to generate depth maps is also discussed, and some sample scenes are provided. To end, there's a short chapter on icon based stereograms and how to generate these with POV Ray.

Hankinson & Hermida's book focusses on random dot stereograms. The principles involved in generating and viewing stereograms are made easily understandable. Many variations and pitfalls involved in the process are covered. Along with the book is the Windows program POPOUT-LITE and some sample depth maps and random dot stereograms. Installation was a snap, and the program is easy to use for generating SIRDS. Creating depth maps is not so easy; the program relies on the Windows Paintbrush program to generate these. Using Paintbrush finesses having to present and distribute (let alone write) new software, and this program is understood by many users already. However, it is not tailored for creating depth maps and so makes for a lot of work for the user to do anything non-trivial. I find RDSdraw much better for the task, as it is made to create simple 3D object depth maps as part of the program.

Since I've begun a comparison of this book to Richardson's (which includes RDSdraw), let's continue. The software offering of Richardson's is richer. It includes programs for a wide variety of generation techniques and also includes a little source code. Hankinson includes essentially one program; the nice thing about it is that it's a Windows program which uses the standard BMP format. However, after a short while you reach its limits. You have to have an artist's abilities and patience to generate depth images using Paintbrush. For example, Hankinson would have you draw each depth slice of a tilted cylinder separately by hand, since Paintbrush doesn't know anything about 3D objects. This time would be better spent generating depth maps with appropriate tools. Hankinson does briefly discuss other methods of generating these, e.g. via POLYRAY. However, POPOUT-LITE has only 16 levels for depth information (as does RDSdraw), so images generated with it all have serious terracing artifacts (where it looks like the object is made out of layers of corrugated cardboard glued together).

Hankinson does discuss image stereograms (like those seen in malls) and puts a few in the set of plates and in the text. However, there is no software to generate these images, unlike Richardson's book. Throughout the book there are references to POPOUT PRO, which does generate these images and uses 256 depth levels, but it is made available only by paying another $17.50 (discounted from $35) for the program. There is also a confusion between GP POPOUT and POPOUT PRO which I have not figured out - they seem to be the same thing, or maybe different things; it's hard to tell from the text. Perhaps my review copy did not come with the discount coupon described in the book, which might have cleared up some of the mystery.

Whatever the case, it is misleading to put a sunflower pattern image stereogram on the cover with a hidden teapot and say "Create Your Own Incredible 3-D Stereograms with Software Included", when in fact you cannot generate image stereograms or the teapot depth map with the software provided. This is a poor way of treating readers and it mars an otherwise fine book.

Hankinson is good at fully presenting the algorithms involved. He is thorough about discussing the various problems which are encountered and ways to fix these. About two-thirds of the book purely is about the algorithms, the rest about describing how to run software.

In summary, both books have their strengths. Richardson's gives a quick once-over of the algorithms, then gets you using the programs in order to learn more. Hankinson's spends time giving a coherent, full presentation of the algorithms involved, then allows some play time to try out SIRDS. Both are well written and nicely presented. Neither book gives a formal presentation on stereogram theory (nor should they) - for this you'll need to hit the scientific literature (check the FAQ). Richardson's software offering is excellent, but the reader should be comfortable with DOS and some basic image manipulation software (most readers of this newsletter qualify). Hankinson's software is simple to use and has on-line help, but doesn't actually do all that much. Hankinson explains things thoroughly enough that you could implement the algorithms after reading his book. Richardson points at net resources and provides code; this is both a good and bad thing - it allows you to get going quickly, but without as deep an understanding of the techniques available and the problems you'll encounter. If you want to read about random dot stereograms in a methodical fashion and don't care so much about playing (or would rather surf the Internet for software), get Hankinson's book. If you would rather play as you go and learn about a wider variety of stereograms, get Richardson's.


Back to the information page.
1st March 1995

Peter Chang: peter.chang at nottingham.ac.uk