From: thale@novell.com (Todd D. Hale)
Newsgroups: alt.3d
Subject: SIRDS/Stereogram/Stare-E-O FAQ
Date: Mon, 4 Apr 1994 23:16:54 GMT
Organization: Novell, Inc., Provo, UT, USA
Lines: 897
Message-ID: <thale.20.2DA09FE5@novell.com>
NNTP-Posting-Host: thale.npd.provo.novell.com

The following is a smattering of info I've collected about SIRDS.  It is not 
totally organized, nor complete, but it answers a lot of FAQs out there.  
Please submit any updates/changes to me at thale@novell.com.

The following sections are covered herein:

   Stereogram Terminology
   Stereogram FTP Sites
   Commercial SIRDS Software
   Stereogram Publications
   Sample TEXT Stereograms
   How Single Images Stereograms work
   Stereogram Algorithm
   C Code to Generate SIRTS
   Hope for the Hopeless
   Commercial Stereogram Producers



-----------------------------------------------------------------------
----- STEREOGRAM TERMINOLOGY ------------------------------------------
-----------------------------------------------------------------------

The definitions below are listed hierarchically (a SIRDS is a SIS is a 
Stereogram):

Stereogram   
             Any stereo picture using stereo pairs or multiple repeating 
             patterns
   Stereo Pair
             Two pictures from slightly different viewpoints, as used in
             the old handheld viewers and viewmasters
   SIS (Single Image Stereogram), Autostereogram
             Includes SIRDS, SIRTS, Single Image Rendered Data Stereogram; 
             extends stereo pair concept to "stereo megtuples"
      SIRDS (Single Image Random Dot Stereogram), RDS, AutoRDS, Random
             Dot Anaglyphs
             Repeating image is made up of random dots
      RLS (Random Line Stereogram)
             Original repeating image is made up of vertical lines of 
             varying widths; very instructional, see Slinker and Burton
             paper
      SIRTS (Single Image Random Text Stereograms), ASCII stereograms
             Repeating image is made up of random text characters
      SITS?
             Non random text stereograms; see Sample Text Stereograms,
             done manually for sigs and such

a SIRD (Single Image Random Dot) 
             not much to view in a dot; used by newbies :-)
Wall-eyed viewing   
             Viewing stereograms by focusing past the actual image
Cross-eyed viewing  
             Viewing stereograms by focusing in front of the image
Focusing to infinity   
             Forcing your eyes' lines of sight into parallel, NOT 
             necessary for wall-eyeing SIRDS! (only occurs when the length
             of the repeating pattern = distance between centers of eyes)


-----------------------------------------------------------------------
----- STEREOGRAM FTP SITES --------------------------------------------
-----------------------------------------------------------------------

Submissions from michael@eccles.anu.edu.au, E.Thompson@newcastle.ac.uk, 
kbaum@novell.com, ...:

THE FTP SITE for Stereograms is KATZ:
katz.anu.edu.au ()
  /pub/stereograms
    00Index.txt  - This listing
    00Readme.txt - An introduction to this site
    ls-lR        - Full list of files under this directory
    SIRDS.FAQ    - This file, created by Todd Thale (thale@novell.com)
    ascii/       - ASCII stereograms
    blue_red/    - Stereograms requiring Blue/Red glasses
    een/         - Single Image Stereograms created by EEN
                   in both TIFF and BMP formats
    images/      - Single Image Stereograms (some GIF and PS)
    ls-lR        - Directory listing of all stereogram files
    papers/      - Papers on single image stereograms
    programs/    - Programs for creating and viewing stereograms (IBM, 
                   X and Unix)
    mac/         - Programs and Images for Apple Macintosh computers
    acorn/       - Programs and Images for Acorn Archimedes range of 
                   computers

WWW access for MOSAIC users:
  http://h2.ph.man.ac.uk/gareth/sirds.html
    From Gareth Richards (gareth@v2.ph.man.ac.uk, richards@cernvm.cern.ch,
    gareth@h2.ph.man.ac.uk)

OTHERS (Most of this is available at katz, above):
ftp.uwp.edu (131.210.1.4)
  /pub/msdos/picture.viewers/rdsdraw.zip
    EXCELLENT SIRDS painting/generating program.  CHECK IT OUT!
oak.oakland.edu
  /pub/msdos/graphics/mindim20.zip
  /pub/msdos/graphics/sirdvu11.zip
  /pub/msdos/graphics/perspect.zip
wuarchive.wustl.edu (128.252.135.4) 
  /pub/xpgs/xpgs
  /pub/MSDOS_UPLOADS/graphics/dynamic.exe
  /graphics/graphics/mirrors/sugrfx.acs.syr.edu/3d/randot/3drandot.zoo
sunsite.unc.edu
  /pub/academic/computer-science/virtual-reality/3d/*
ftp.cs.waikato.ac.nz
  /pub/papers/???.tar.Z
gwaihir.dd.chalmers.se
  pub/een/SIS/*.tif
  pub/een/Dirk-SIS/*.tif   <-- GET THESE (not on katz, yet)



-----------------------------------------------------------------------
----- COMMERCIAL SIRDS SOFTWARE ---------------------------------------
-----------------------------------------------------------------------

STW_DEMO.EXE: the full package will allow RDS creation
   Approx 40$
   N.E.Thing Enterprises
   P.O. Box 1827
   Cambridge, MA 02139

A company called I/O Software, Inc. (909/483-5700 800/800-7970)
has a program called STEREOLUSIONS.  It works on both WINDOWS and
Windows NT and allows people to create, render and even print SIRDS on
any Windows compatible machine.  (From William Saito, 3/07/94)

KAI's POWER TOOLS for the MAC has a Photoshop add-on for SIS creation.

Stareo-3D ??

SEND MORE INFO!


-----------------------------------------------------------------------
----- STEREOGRAM PUBLICATIONS -----------------------------------------
-----------------------------------------------------------------------

Search library databases with these keywords: Stereogram, Autostereogram, 
SIRDS (Single Image Random Dot Stereogram), RDS.

Considered by most as the original work on Random Dot Stereograms: 
'Principles of Cyclopean Perception' by Bela Julesz, from MIT press, circa
1972.
>Charles Eicher (CEicher@Halcyon.com)

An excellent source of information (sample RDS and source code)
is contained in Andrew A.Kinsman - Random Dot Stereograms
ISBN 0-9630142-1-8  $13.95 U.S.  Published by Kinsman Physics, 
P.O. Box 22682, Rochester, N.Y. 14692-2682
>E.Thompson@ncl.ac.uk

Journal of Imaging Science and Technology, May/June 1992, Vol 36, #3.
Slinker & Burton.  Their use of random line stereograms really helps
to understand how stereograms work, as well as some of their limitations.

New Scientist (9 October 1993) has a 4 page article on SIRDS. There is a 
pretty cool example too.
>Simon Dear (sd@mrc-lmb.cam.ac.uk)

David G. Stork and Chris Rocca.  "Software for generating auto-random-dot
stereograms", Behavior Research Methods, Instruments, and Computers,
Vol. 21, No. 5, 1989, pp. 525-534.
>Steve Tate (srt@cs.unt.edu)


"Stereo Computer Graphics and Other True 3D Technologies"
David F. McAllister, Ed.
Princeton University Press, 1993
ISBN 0-691-08741-5   US$75.00
It has several nice color plates, with stereo "triads".  The triads consist
of a left, a right, then another left image.  Use the left pair for viewing
walleyed, or the right pair for viewing crosseyed.
>Mike Weiblen (mew@digex.net)

"Stereogram" (c) 1994, Cadence Books, San Francisco, CA
"a newly edited version of CG STEREOGRAM and CG STEREOGRAM 2,
published by Shogakukan Inc. In Tokyo, Japan"
ISBN 0-929279-85-9
Cadence Books, A division of Viz Communications, Inc.
P.O. Box 77010
     I liked it.  Much better in my opinion than the other Stereogram
book I've seen ("Magic Eye").  This one includes much textual
information, including the origins of stereograms, how to see them,
precursors such as stereo pairs, and an article by Christopher W.
Tyler, who invented the SIRDS.
     Best of all were the stereograms themselves.  There are roughly
50 SIRDS, most of them full page (the book is softcover and about 8"
square).  The ones I've managed to see so far have been quite good,
and also included are some of the very first ones.  In the history
department there are stereo pairs, stereo photographs, and even some
stereo-pair paintings by Salvador Dali.
     All of the stereograms indicate whether they require wall-eyed or
cross-eyed viewing (or either).  Most are true 3d designs, not the
"cutout" variety.
      The book is 93 pages and most of the plates are full-color.
Well worth the money in my opinion.
>Michael Moncur (mgm@xmission.com)

_Magic Eye: A New Way of Looking at the World_
copyright (c) 1993 by N.E. Thing Enterprises.
Andrews and McMeel, A Universal Press Syndicate Company, Kansas City
ISBN: 0-8362-7006-1
First Printing, September 1993 ... Fifth Printing, January 1994
Introduction contains a history of the technique and phenomena.
Viewing Techniques are explained.  25 pages of full-color STARE-E-O images.
(Plus images inside the front and back covers.)  "Answers" included.
32 pages, hardcover, 8.75x11.5 inches, horizontal format, with slipcover.
US$12.95 ($16.95/Canada)
I just bought this for US$7.77 at Media Play in Utah.  It's currently on
their best seller list.  Well worth any price under $30!  
>Todd Hale, 3/25/94

Magic Eye II: Three Dimension Trip Vision
Copyright 1992 by N.E. Thing Enterprises/Tenyo Co., Ltd.
Korean Translation Copyright 1993 by Chungrim Publishing Co.
All the text is in Korean, so I can't read it.  But it has some pretty
cool pictures.  They are all SIRxS where x is various patterns/pictures.
I paid US$20 for it.  Interestingly, this title doesn't seem to be mentioned
in my N.E. Thing catalog.
>Mark Hudson (M_Hudson@delphi.com)

SEND MORE REFERENCES!


-----------------------------------------------------------------------
----- SAMPLE TEXT Stereograms (Not random) ----------------------------
-----------------------------------------------------------------------

From: dthomas@bbx.basis.com (Dave Thomas)

                            O   O
n   n   n   n   n   n   n   n   n   n   n   n   n   n   n  n
f    f    f    f    f    f    f    f    f    f    f    f   f
e   e   e   e   e   e   e   e   e   e   e   e   e   e   e  e
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



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
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r
 e    e    e    e    e    e    e    e    e    e    e    e    e    e    e
a     a     a     a     a     a     a     a     a     a     a     a     a
 t      t      t      t      t      t      t      t      t      t      t
<<<<>>>><<<<>>>><<<<>>>><<<<>>>><<<<>>>><<<<>>>><<<<>>>><<<<>>>><<<<>>>>
 d      d      d      d      d      d      d      d      d      d      d
e     e     e     e     e     e     e     e     e     e     e     e     e
 p    p    p    p    p    p    p    p    p    p    p    p    p    p    p
t   t   t   t   t   t   t   t   t   t   t   t   t   t   t   t   t   t   t
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


From: jittlov@gumby.cs.caltech.edu (Mike Jittlov)
       .    .          .    .          .    .           .    .
           @  .           @   .          @    .          @     .
>     /^\           /^\           /^\           /^\           /^\
> ####################################################################
> ####################################################################
>  /    ####     /   ####\     /  #### \     / ####  \     /####   \
>/       ## \__/      ##  \__/     ##   \__/    ##    \__/   ##     \
>   ____ ##     ____  ##    ____   ##   ____    ##  ____     ## ____
>  /    \##    /    \ ##   /    \  ##  /    \   ## /    \    ##/    \
> |  2D  |#   |  2D  |##  |  2D  | ## |  2D  |  ##|  2D  |   #|  2D  |
> |  or  |#   |  or  |##  |  or  | ## |  or  |  ##|  or  |   #|  or  |
> |  3D  |#   |  3D  |##  |  3D  | ## |  3D  |  ##|  3D  |   #|  3D  |
> |  ??  |#   |  ??  |##  |  ??  | ## |  ??  |  ##|  ??  |   #|  ??  |
> |      |    |      |    |      |    |      |    |      |    |      |
> --------    --------    --------    --------    --------    --------
>  \\\\\\\\    \\\\\\\\    \\\\\\\\    \\\\\\\\    \\\\\\\\    \\\\\\\\
>   \\\\\\\\    \\\\\\\\    \\\n\r\\    \\f\o\d\    \\\\\\\\    \\\\\\\\
>     \\\\\\      \\\\\\      \\\\\\      \\\\\\      \\\\\\      \\\\\\
>                                                            DR J

_____________________________________________________________________________
 [] [] [] | [] [] [] [] | [] [] [] [] | [] [] [] [] | [] [] [] [] | [] [] [] 
=============================================================================
        * :         *   :       *     :     *       :   *         : *        
      .' `:       .' `. :     .' `.   :   .' `.     : .' `.       :' `.        
Mike Jittlov Mike.Jittlov Mike Jittlov.Mike Jittlov Mike Jittlov Mike Jittlov
 The Wizard`  The Wizard.  The Wizard . The Wizard  .The Wizard  'The Wizard 
*   * of  . *   *  of   *   *   of  * . *    of *   *     of*   * .    o*   *
|\^/|peed . |\^/|Speed  |\^/| Speed |\^/|  Speed|\^/|   Spee|\^/| .  Spe|\^/|
 \V/ and  .  \V/  and   .\V/   and   \V/    and  \V/.    and \V/  .   and\V/ 
 /_\Time! .  /_\ Time!  ./_\  Time!  /_\   Time! /_\.   Time!/_\  .  Time/_\ 
_/ \_     . _/ \_       _/ \_       _/.\_       _/ \_       _/ \_ .     _/ \_
=============================================================================
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


One more from ... well ... YOU figure it out!

_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~
!   Adam      Adam      Adam      Adam      Adam      Adam   ! "Lawn       !
!Spragg   Spragg   Spragg   Spragg   Spragg   Spragg   Spragg!   service!" !
!   Adam      Adam      Adam      Adam      Adam      Adam   !       -Stup !
!Spragg   Spragg   Spragg   Spragg   Spragg   Spragg   Spragg!             !
!   Adam      Adam      Adam      Adam      Adam      Adam   !  atspragg@  !
!Spragg   Spragg   Spragg   Spragg   Spragg   Spragg   Spragg! ucdavis.edu !
!   Adam      Adam      Adam      Adam      Adam      Adam   !   GO AGS!   !
_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~-_-~



-----------------------------------------------------------------------
----- How Single Image Stereograms Work -------------------------------
-----------------------------------------------------------------------

Let's start with a simple repeating pattern.  First we'll examine viewing
stereograms wall-eyed (focusing beyond the picture).

              Adam
Adam                       Adam          <-- PERCEIVED IMAGE (3D)
  \ 
   \ \
    \   \
    Adam  Adam   Adam  Adam              <-- ACTUAL PICTURE (Flat, 2D)
     \       \
      \         \                        <-- LINES OF SIGHT FROM EACH EYE
       \           \
       (*)           (*)                 <-- EYES

As shown in the above graphic, the lines of sight go through different
(but identical) words.  The eyes must be directed to just the right level
behind the picture to get the two "Adams" to line up.  When they do line 
up, a single "Adam" appears at the level shown behind the picture.  

This is why it is easiest for some people to look at stereograms behind
glass.  You simply look at your reflection, which appears to be behind
the glass at about the same level as the 3d stereogram image.  More on
this later.

So, why is the second "Adam" in the above image "deeper" than the other
two?  Since the next two "Adams" that line up are FARTHER apart than the
first two, your eyes must diverge a little more to get them to line up.  
As the eyes diverge, their lines of sight meet a little further away.
This causes the next "Adam" to appear deeper in the image.

              Adam
Adam           |           Adam          <-- PERCEIVED IMAGE (3D)
              / \
             /   \
            /     \
    Adam  Adam   Adam  Adam              <-- ACTUAL PICTURE (Flat, 2D)
           /       \
          /         \                    <-- LINES OF SIGHT FROM EACH EYE
         /           \
       (*)           (*)                 <-- EYES

The above graphic was crammed into 10 lines of text.  If we moved the 
eyes back (to a more realistic distance), the whole 3d image would 
appear deeper, and not so spread out.

Cross-eyed viewing follows the same principles, but brings the focal point
up front of the picture and inverts the image.  I'll use the same eyes and
picture, but move the eyes back for room to illustrate.

    Adam  Adam   Adam  Adam              <-- ACTUAL PICTURE (Flat, 2D)
       \   |
         \|
         Adam                            <-- PERCEIVED IMAGE (3D)
         |   \
         |     \
        |         \                      <-- LINES OF SIGHT FROM EACH EYE
        |           \
       (*)           (*)                 <-- EYES

Now for the inverse part.  Since the next two "Adams" are farther apart,
you must cross your eyes MORE (converge instead of diverge your eyes) to
get the "Adams" to overlap.  This causes the next "Adam" in the image to
appear closer than the first one.

    Adam  Adam    Adam  Adam             <-- ACTUAL PICTURE (Flat, 2D)
           \      /
            \    /
         Adam\ / Adam                    <-- PERCEIVED IMAGE (3D)
             Adam
             /  \
           /      \                      <-- LINES OF SIGHT FROM EACH EYE
         /          \
       (*)           (*)                 <-- EYES

Whew.  Ascii graphics are a bit too tight to be very technical.  By the
way, each letter (or pixel) in the 3D image comes from two letters in
the picture.  Stereograms have blurry edges (right and left edges) 
because the line of sight from the one eye passes through the picture, 
but the line of sight from the other eye is off the picture.  Examine
the wall-eyed example below.

                     Adam
       Adam                       Adam     <-- PERCEIVED IMAGE (3D)
\               
  \ \
    \   \
       \   Adam  Adam   Adam  Adam         <-- ACTUAL PICTURE (Flat, 2D)
         \     \
            \       \                      <-- LINES OF SIGHT
              \           \          
              (*)           (*)            <-- EYES

Here, the line of sight for the right eye goes through first "Adam" 
in the picture, and the line of sight for the left eye is off the
picture.  (Everything to the left of the first "Adam" in the IMAGE 
is blurry.)


HOW TO GENERATE STEREOGRAMS

Random stereograms work the same way; they simple repeat random text or
pixels, instead of words like the "Adam" used above.  Below, the pattern, 
"ASDFGHJK", is repeated four times in each line.  (I duplicated it for
easier viewing.)

         ASDFGHJKASDFGHJKASDFGHJKASDFGHJK
         ASDFGHJKASDFGHJKASDFGHJKASDFGHJK
         ASDFGHJKASDFGHJKASDFGHJKASDFGHJK

As you might guess, the image consists of THREE repetitions of the 
pattern, set back behind the picture (wall-eyed).  To add some varying
depth to the image, we can simple add a space in the middle; or better,
we'll add a different letter, the letter Q.  I've also dropped the K
off the end to keep it suitable for framing. :-)

         ASDFGHJKASDFGHJKASDFGHJKASDFGHJK
         ASDFGHJKASDFGHJKASQDFGHJKASDFGHJ
         ASDFGHJKASDFGHJKASDFGHJKASDFGHJK

Adding the Q has the same effect as adding the space between "Adams"
in the previous example.  Here it is again for comparison.

         Adam Adam Adam Adam Adam Adam
         Adam Adam Adam  Adam Adam Ada
         Adam Adam Adam Adam Adam Adam

These two stereograms demonstrate going down a level (deeper, for wall-
eyed viewers) by adding a new letter where you want to go down.  The
image returns back to the original level because the added letter was
not repeated down the line; it was essentially deleted again.  Hence,
deleting a letter causes the image to come forward one level.  Lets 
look at this by deleting a letter before adding any.

         ASDFGHJKASDFGHJKASDFGHJKASDFGHJK
         ASDFGHJKASDFGJKASDFGHJKASDFGHJKA
         ASDFGHJKASDFGHJKASDFGHJKASDFGHJK

I deleted an H from the middle row, and added an A on the end to make
it flush again.  This causes the image to come up a level where the H
was deleted, then go back down where the H returns to the pattern.

To fully control the ups and downs of stereogram generation, you simply
keep track of what's repeating and add and delete letters when needed.
For example, start with the pattern ASDFGHJK.  If the input for the 3D
stereogram image is 00000000000011111222221111111110000, where the 
numbers represent the levels of the 3D image, you simply delete a letter
from the pattern when you go up a level (0 to 1, or 1 to 2), and add a
letter to the pattern when you go down a level (2 to 1, or 1 to 0).

If you want to go up multiple levels, e.g., from level 1 to 3, delete
2 letters from your pattern.  Adding two letters to the pattern likewise
causes a two-level drop in the image.

Start each line of the image by dumping the whole pattern.  Recall that
in the examples above, four "Adams" in the picture creates three "Adams" 
in the image.  By dumping the pattern to start, we are simple providing 
the first "Adam" to build the 3D image from.  Now, we start building the 
3D image.

        ASDFGHJK

Since the first 12 levels are at level 0, we do no adding nor deleting;
just dump 12 more letters from the pattern in order.

        ASDFGHJKASDFGHJKASDF
                ^image starts here

We now have our first transition, from level 0 to 1.  Which letter do we
delete?  Delete the next one in the pattern.  

        ASDFGHJK
            ^the next letter in the pattern

Since G is next, we delete it.  Our new pattern is ASDFHJK, and H is the
next letter to be used in the image.

        ASDFHJK
            ^the next letter to use in the image

Forget about the G.  Consider it gone forever.  The input now indicates 
five letters at level 1.  Since we made the transition to level one by 
deleting the G, we simply copy the next 5 letters from the pattern into
the image.  The next 5 letters in the pattern are HJKAS.  (You've noticed
by now that we wrap around when we get to the end of the pattern.) I'll 
lay the input next to our image to make it easier to see where we're at.

                00000000000011111222221111111110000
        ASDFGHJKASDFGHJKASDFHJKAS
        {      }{          }{   }
        initial  level 0    level
        pattern             1

To jump up to level 2 from level 1, we delete the next letter in the 
pattern, the letter D.  The new pattern is shown below.

        ASFHJK
          ^the next letter to use

We have 5 letters at level 2, so we copy the next 5 letters from the 
pattern, FHJKA, to the image.

                00000000000011111222221111111110000
        ASDFGHJKASDFGHJKASDFHJKASFHJKA
        {      }{          }{   }{   }
        initial  level 0    lev  level
        pattern             1    2

We must now move down a level, from 2 to 1, by ADDING a letter to our
pattern.  Where do we add it?  Add it as the next letter to use.  Let's
add an X (randomly chosen letters work better than previously used 
letters).  Since A was the last letter used, S is the next to be used.

        ASFHJK
         ^add X here

        AXSFHJK
         ^next letter to use

Since there are nine letters at level 1, we must copy nine letters 
from the pattern to the image (XSFHJKAXS).

                00000000000011111222221111111110000
        ASDFGHJKASDFGHJKASDFHJKASFHJKAXSFHJKAXS
        {      }{          }{   }{   }{       }
        initial  level 0    lev  level level 1
        pattern             1    2

Drop another level, from 1 to 0, by adding another letter to the pattern
at the current position.

        AXSFHJK
           ^add random letter (M) here

        AXSMFHJK
           ^next letter to use

Since there are four letters at level 0, we copy four letters from the
pattern to the image (MFHJ).

                00000000000011111222221111111110000
        ASDFGHJKASDFGHJKASDFHJKASFHJKAXSFHJKAXSMFHJ
        {      }{          }{   }{   }{       }{  }
        initial  level 0    lev  level level   lev
        pattern             1    2     1       0

WE'RE DONE.  Kinda anti-climatic, huh?  Let's duplicate the image line
to make it easier to view.

        ASDFGHJKASDFGHJKASDFHJKASFHJKAXSFHJKAXSMFHJ
        ASDFGHJKASDFGHJKASDFHJKASFHJKAXSFHJKAXSMFHJ
        ASDFGHJKASDFGHJKASDFHJKASFHJKAXSFHJKAXSMFHJ
        ASDFGHJKASDFGHJKASDFHJKASFHJKAXSFHJKAXSMFHJ
        ASDFGHJKASDFGHJKASDFHJKASFHJKAXSFHJKAXSMFHJ

For each new line in the image, start with a new random pattern, and
follow the steps above.  So, how are graphics stereograms made?  The
same way, using colored pixel values for input.  3drandot uses RED as
the color deepest in the image, with GREEN in the middle, and BLUE as
the highest color.

The pseudocode below follows this algorithm.  If you have any questions,
post them in the newsgroup.  Let me know if you are interested in C code 
that follows this algorithm.  (The C code here in the FAQ follows a 
different algorithm, the "lookback" algorithm.)

Enjoy!!
thale@novell.com


-----------------------------------------------------------------------
----- STEREOGRAM ALGORITHM --------------------------------------------
-----------------------------------------------------------------------

The following is an algorithm I developed for SIRDS generation.  It is 
functionally equivalent to the look back algorithms, without looking back. 
It can be used for graphic stereograms, as well as the text stereograms. 
It simply stores in PATTERN the values we would look back at.  The input 
file is depth data, or a z-buffer (see example input below).  The levels 
available in a picture are the maximum pattern size divided by two minus 
one.  Maximum pattern size should be equivalent to half the distance 
between the eyes (for easy viewing), which is about 1 1/4 inches.  So, for 
typical text stereograms on an 80 char display, that's about 10 characters 
for the maximum pattern size and 4 or 5 levels available.  However, since 
4 or 5 levels is unreasonable, we push the max pattern size to 16 (still 
less that the 20 character distance between the eyes).  This gives us about 
7 or 8 levels.

If we do allow more than 7 levels when the max pattern size is 16, the 
repeating pattern (of size max pattern - current level) grows so small that 
four of them in a row (e.g., of size 7) would also create two double 
patterns in a row (of size 14), causing floaties (aliasing).  

I hope I'm making some sense.  I'll try to spend some time rewriting this. 
In addition, I'll integrate answers to any questions that come as a result 
of this mess!


PL : Previous Level value
NL : Next Level value

INITIAL LEVEL SETTING
PL = 0

OPEN INPUT FILE FOR READING
WHILE NOT EOF (Y DIMENSION: FOR EACH LINE)

   GENERATE NEW PATTERN
   SET PATTERN PTR TO BEGINNING OF PATTERN
   OUTPUT FULL PATTERN

   WHILE NOT EOL (X DIMENSION: FOR EACH POSITION)

      NL = NEXT INPUT LEVEL VALUE
      IF NL != PL (IF WE'RE CHANGING LEVELS)

         IF NL > PL (IF WE'RE MOVING UP)
            DELETE NEXT NL-PL BITS IN PATTERN FROM PTR FORWARD
            (IF GOING FROM LEVEL 0 TO 2, DELETE 2 BITS IN PATTERN)

         ELSE (IF MOVING DOWN, AWAY)
            INSERT PL-NL RANDOM BITS INTO PATTERN AT PTR POSITION
            (IF GOING FROM LEVEL 3 TO 2, INSERT 1 BIT INTO PATTERN)

         PL = NL (UPDATE PL)
         OUTPUT NEXT VALUE IN PATTERN

      ELSE
         OUTPUT NEXT VALUE IN PATTERN

      ADVANCE PATTERN PTR (CIRCULAR PATTERN)
      ADVANCE INPUT PTR
            
(Redundancy exists to simplify readability.)

Assuming spaces translate to level 0, input like this (thanks, Dave 
Thomas):


   22222222222222222          11111111111111111111111
   2222222222222222222        11111111111111111111111
   22222222222222222222       11111111111111111111111
   22222          22222                11111
   22222          22222                11111
   22222          22222                11111
   22222          22222                11111
   22222          22222                11111
   22222          22222                11111
   22222222222222222222                11111
   2222222222222222222                 11111
   22222222222222222                   11111
                                                                        
                                                                        
Yields output like this:

Co6&`R(D(v"i`<$$Co6&`R(D(v"i`<$$Co6&`R(D(v"i`<$$Co6&`R(D(v"i`<$$Co6&`R(D
mwBy&>`,QFdZ<$wamwBy&>`,QFdZ<$wamwBy&>`,QFdZ<$wamwBy&>`,QFdZ<$wamwBy&>`,
7Z,o:.sw5[rHt&{:7Z,osw5[rHt&{:7Z,osw505[rHt&{:7Zosw505[rHt&{:7Zosw505[rR
g"EzQy{lW_3C&B[8g"Ez{lW_3C&B[8g"Ez{lW_3S3C&B[8g"z{lW_3S3C&B[8g"z{lW_3S3y
yiQ?fiVF!G{TAtrJyiQ?VF!G{TAtrJyiQ?VF!G{T]TAtrJyi?VF!G{T]TAtrJyi?VF!G{T]s
1`I|r?FLoB#<sf!Q1`I|FLoB#T#<sf!Q1`ILoB#TaT#<sf!Q1`ILoB#Ta#<sf!#Q1`ILoB#T
m$LuSD0hh7\qy5:nm$Lu0hh7\x\qy5:nm$Lhh7\x"x\qy5:nm$Lhh7\x"\qy5:-nm$Lhh7\x
[#7hrqKUm`/<bic$[#7hKUm`/7/<bic$[#7Um`/7r7/<bic$[#7Um`/7r/<bick$[#7Um`/7
L,'O)X\L&Xu)ZUw(L,'O\L&Xu|u)ZUw(L,'L&Xu|y|u)ZUw(L,'L&Xu|yu)ZUwy(L,'L&Xu|
3`#YPTdg:,;rmy9`3`#Ydg:,;(;rmy9`3`#g:,;(7(;rmy9`3`#g:,;(7;rmy94`3`#g:,;(
1w^N7d;f964U,yml1w^N;f964&4U,yml1w^f964&;&4U,yml1w^f964&;4U,ym{l1w^f964&
<>Y8igID(]?"A0+;<>Y8ID(]?"A0+;<>Y8ID(]?"?"A0+;<>Y8ID(]?"?A0+;<O>Y8ID(]?"
eRl5hfJx.cD0tscheRl5Jx.cD0tscheRl5Jx.cDeD0tscheRl5Jx.cDeDtscheiRl5Jx.cDe
v,r7f6%<)R-AaV^hv,r7%<)R-AaV^hv,r7%<)p)R-AaV^hv,r7%<)p)R-aV^hv>,r7%<)p)R
VbWqd^]qi(IRW)ytVbWqd^]qi(IRW)ytVbWqd^]qi(IRW)ytVbWqd^]qi(IRW)ytVbWqd^]q
`^Y-z8v=[gBX(Aqq`^Y-z8v=[gBX(Aqq`^Y-z8v=[gBX(Aqq`^Y-z8v=[gBX(Aqq`^Y-z8v=


This uses 16 as the Max pattern size.  Notice on the third line of the 
output (the first line with level changes), the pattern is "7Z ... &{:".
When we go from level 0 to level 2, we lose two characters (i.e., ":.").
When we go from level 2 back to level 0, we insert two new characters 
(i.e., "05" after the "osw5").

Any questions?  Or better yet, what did I leave out??  I do hope this helps 
someone!?!


-----------------------------------------------------------------------
----- C CODE TO GENERATE TEXT STEREOGRAMS -----------------------------
-----------------------------------------------------------------------

Also from Dave Thomas:

Now here's a hack of a hack I found on the net.  Basically it generates
stereograms from ascii diagrams.  Here's the program first (it uses the
lookback algorithm, not the stored-pattern algorithm described above):

##define DEPTH0  16
##define COLS    79

##include <stdio.h>

main()
   {
   long now;
   int col;
   char m[COLS+1],s[COLS+1];
   int i,e,c;

   /* seed random number generator */
   time (&now);
   srand (now);

   /* print fusion X's */
   for (col = 0; COLS - col >= DEPTH0; col += DEPTH0)
      {
      for (i = 0; i < DEPTH0-1; ++i)
         putchar (' ');
      putchar ('X');
      }
   putchar ('\n');

   /* process input image */
   while (memset(m,'\0',COLS+1),fgets (m, COLS+1, stdin))
      {
      e = 0;
      s[COLS] = 0;
      for(i=0; i<COLS; )
         {
         e = 0;
         while (i >= DEPTH0 && i < COLS && 
            (c = m[i - DEPTH0]) >= '0' && c <= '9')
            {
            e = 1;
            s[i] = s[i-DEPTH0+c-'0'];
            ++i;
            }
         s[i++] = (e || i < DEPTH0) ? randasc() : s[i-DEPTH0];
         }
      puts (s);
      }
}

randasc()
{
   /* large set of random characters */
   return ('!'+rand()%92);

   /* lowercase random letters */
   /* return ('a'+rand()%26); */
}


Try passing it this file as the standard input:
                                
           22222222222222222           11111111111111111111111
           2222222222222222222         11111111111111111111111
           22222222222222222222        11111111111111111111111
           22222          22222                 11111
           22222          22222                 11111
           22222          22222                 11111
           22222          22222                 11111
           22222          22222                 11111
           22222          22222                 11111
           22222222222222222222                 11111
           2222222222222222222                  11111
           22222222222222222                    11111
                                                                        
                                                                        
You'll get output like this:

               X               X               X              X
"i`<$$Co6&`R(D(v"i`<$$Co6&`R(D(v"i`<$$Co6&`R(D(v"i`<$$Co6&`R(D(v"i`<$$Co6&`R(D
dZ<$wamwBy&>`,QFdZ<$wamwBy&>`,QFdZ<$wamwBy&>`,QFdZ<$wamwBy&>`,QFdZ<$wamwBy&>`,
rHt&{:7Z,o:.sw5[rHt&{:7Z,osw5[rHt&{:7Z,osw505[rHt&{:7Zosw505[rHt&{:7Zosw505[rR
3C&B[8g"EzQy{lW_3C&B[8g"Ez{lW_3C&B[8g"Ez{lW_3S3C&B[8g"z{lW_3S3C&B[8g"z{lW_3S3y
{TAtrJyiQ?fiVF!G{TAtrJyiQ?VF!G{TAtrJyiQ?VF!G{T]TAtrJyi?VF!G{T]TAtrJyi?VF!G{T]s
##<sf!Q1`I|r?FLoB#<sf!Q1`I|FLoB#T#<sf!Q1`ILoB#TaT#<sf!Q1`ILoB#Ta#<sf!#Q1`ILoB#T
\qy5:nm$LuSD0hh7\qy5:nm$Lu0hh7\x\qy5:nm$Lhh7\x"x\qy5:nm$Lhh7\x"\qy5:-nm$Lhh7\x
/<bic$[#7hrqKUm`/<bic$[#7hKUm`/7/<bic$[#7Um`/7r7/<bic$[#7Um`/7r/<bick$[#7Um`/7
u)ZUw(L,'O)X\L&Xu)ZUw(L,'O\L&Xu|u)ZUw(L,'L&Xu|y|u)ZUw(L,'L&Xu|yu)ZUwy(L,'L&Xu|
;rmy9`3`#YPTdg:,;rmy9`3`#Ydg:,;(;rmy9`3`#g:,;(7(;rmy9`3`#g:,;(7;rmy94`3`#g:,;(
4U,yml1w^N7d;f964U,yml1w^N;f964&4U,yml1w^f964&;&4U,yml1w^f964&;4U,ym{l1w^f964&
?"A0+;<>Y8igID(]?"A0+;<>Y8ID(]?"A0+;<>Y8ID(]?"?"A0+;<>Y8ID(]?"?A0+;<O>Y8ID(]?"
D0tscheRl5hfJx.cD0tscheRl5Jx.cD0tscheRl5Jx.cDeD0tscheRl5Jx.cDeDtscheiRl5Jx.cDe
-AaV^hv,r7f6%<)R-AaV^hv,r7%<)R-AaV^hv,r7%<)p)R-AaV^hv,r7%<)p)R-aV^hv>,r7%<)p)R
IRW)ytVbWqd^]qi(IRW)ytVbWqd^]qi(IRW)ytVbWqd^]qi(IRW)ytVbWqd^]qi(IRW)ytVbWqd^]q
BX(Aqq`^Y-z8v=[gBX(Aqq`^Y-z8v=[gBX(Aqq`^Y-z8v=[gBX(Aqq`^Y-z8v=[gBX(Aqq`^Y-z8v=



-----------------------------------------------------------------------
----- HOPE FOR THE HOPELESS :-) ---------------------------------------
-----------------------------------------------------------------------

From: wchaga@vela.acs.oakland.edu (William C. Haga)

Being one who has used wide-eyed vision on chain link fences ever
since I was a kid, I was able to see the images in SIRDS right
away. But I've had difficulty explaining the technique to friends. 
Today I had the latest Games magazine with me at my parents house. 
Games is running another contest using SIRDS, so there are three in 
the latest issue. This time I thought of the reflection idea. So I 
opened mom's china cabinet, put the magazine against the glass in 
the door, and told mom to keep looking at her own reflection in the 
glass until the image appeared.

It took less than thirty seconds.

When she saw the 3d train engines, I was subjected to a squeal of
delight that I hadn't heard from her for a long time. "EEK! IT'S
COMING OUT AT ME! IS THIS EVER NEAT!".  Dad tried for about a minute
but gave up.

About an hour later, mom and I heard a shout. We went to
the dining area, and there was dad with the magazine against the
glass in the door. "Isn't that just the most amazing thing!", said he.

Later they were making jokes about teaching old dogs new tricks.


-----------------------------------------------------------------------
----- COMMERCIAL Stereogram Producers --------------------------------------
-----------------------------------------------------------------------

Infix Technologies
PO Box 381
Orem, UT 84057-0381
(801) 221-9233
contact: John M. Olsen, jolsen@nyx.cs.du.edu
18x24 Earth (mercator projection of the Earth's altitudes)
18x24 Salt Lake LDS Temple Centennial
18x24 Beethoven (300 DPI!  Very smooth.)
(others are coming soon, too.)
Retail price for the 18x24 inch prints is $20 plus $3 s/h.  Utah residents
add 6.25% sales tax.  Wholesale and distributor discounts are available.
Quotes for custom work are also available.  Cost and minimum order varies, 
based on content.

Altered States
92 Turnmill St,
Farringdon,
London, EC1, U.K.
+44 (0)71 490 2342
Paul Dale (P.A.Dale@bath.ac.uk)
tel: +44 (0)225 826 215

Send a catolog request to:
N.E. Thing Enterprises
19C Crosby Drive
Bedford, MA 01730
>Info from: Neal T. Leverenz (at802@yfn.ysu.edu)

Inner Dynamics, Inc.
The distributor: Privileged Traveler
                 4914 Brook Road
                 Lancaster, OH 43130
                 (614) 756-7406
Retail prices stated below plus $3 S&H. Ohio residents add 5.5% sales tax.
GLOW IN The DARK Poster Series - $23  (size: 18" X 24")
  "Knight Vision" - suspended chess board with chess pieces
  above the board in daylight viewing - also an area in the center that has
  a Knight chess piece - random dot pattern glows and is viewable in the dark!!
Premium Color Series - $16  (size: 18" X 24")
  "Gecko" - twin Gecko lizards
  "I Think Therefore I Am" - well known quote surrounded by stunning visuals
  "SoulMate" - hearts, spirals, and other symbols, for that special person
  "The Mighty Unicorn" - unicorn, mystical castle, wizard, and flying dragon
  "Excalibur" - legendary sword in the stone, castle, knights, etc.
  "Where's Wilbur?" - can you find him in the forrest?
Optimum Series - $15  (size: 24" X 36", black and white)
  "Beyond Reality" - hearts, spirals, other cool shapes - extremely detailed
  "20/20 Third Sight" - an eye chart done in 3D
  "Illusions" - a labyrinth, try to find your way out!
  "Meditation" - contains an ancient mandala, a real stress buster
  "DreamWeaver" - unusual geometric shapes, helps induce lucid dreaming and 
     dream remembrance
  "Icons" - the five symbols of life
  "Rainbows" - see color on a black and white poster (Not a 3D poster)
>Sam Weaver (sew@cblpd.att.com)


                                              *
Todd D. Hale                          * * * * 
thale@novell.com                      * *
halet@bert.cs.byu.edu