Stereograms – I love them!

I can still remember the first time I managed to see a sterogram properly. I’d bought two posters – one f Bugs Bunny and one of and eagle against a mountainous landscape – or at least thats what they claimed they were. All I could see was a lot of coloured dots – no pictures.
Those posters were hung up on my work office wall and to my total disgust, various work collegues would casually stroll up, look at the picture and take great delight in telling me how amazing it looked. But could I see them – could I heck.
However, after about 3 months I wandered over, and looked at one slightly differently and it just suddenly came into focus and I was totally blown away. They still fascinate me and over time, I’ve http://www.buyambienmed.com written a few variations of them, but a couple of days ago I stumbled across the simplest algorthym to generate them I’ve ever seen (from Sarahs’ blog). I’ve shown the relevant bit of code below (C#) just in case I lose the bookmark or the page goes offline.


void RDS(Bitmap bitmap,int stripWidth)
{
    Random rnd = new Random();
    int rndDotColour;
    float scaling;
    int width=bitmap.Width;
    int height=bitmap.Height;

    // This makes sure full white (high points are white and
    // have a value of 255) are always 1/5th the width of
    // the image strip.
    scaling=((float)stripWidth/(float)5)/(float)255; 

    //Draw the random strip
    for(int y=0;y

Call it using something like:

Bitmap bitmap = new Bitmap("c:/shark.png"); // http://rdc.untamed.co.uk/rds/shark.png
RDS(bitmap,90);

Now thats pretty amazing. I've also started to make it into an iPhone application (why not) and the plan is to be able to draw and create your own. Why? why not I say. Note, its somewhat more complicated on the iPhone as bitmap drawing is pretty much non-existant, but its working.

Slight update - its now working with images as well as dots (Single-Image Stereogram)

Downside - its very slow (36 secs on the iPhone to generate an image). Booo - not the iPhones fault here note - most certainly my lack of Cocoa drawing.

As always, screenshots once the NDA is lifted.

Leave a Reply