Back to posts

Computer Vision

Recovering 3D Structure from Autostereograms

An automated pipeline for recovering the three-dimensional surface that is encoded within a single-image autostereogram, commonly known as a “Magic Eye” image.

By 0cool Project report Repository: stereogram-analyzer Live: demonstration

Background

An autostereogram is a single two-dimensional image that encodes a three-dimensional surface. The encoding is produced by repeating a narrow pattern horizontally while varying the repetition period slightly from one column to the next. When an observer diverges the optical axes so that two adjacent copies of the pattern are fused by the visual system, the local variations in period are interpreted as binocular disparity, and a depth percept is produced.

It follows that the depth information is physically present in the pixel data, represented as spatial variation in the local horizontal period. Because the human visual system is able to decode this representation, the same information is recoverable by computational means. The present tool implements that recovery.

Method

Given a single autostereogram, the analysis proceeds in four stages:

Implementation

The reference implementation is a desktop application written in Python using NumPy, Pillow, and Matplotlib, with a PyQt5 interface. The complete pipeline was subsequently ported to JavaScript and deployed as a browser application that executes entirely on the client, so that images are not transmitted to any server. The computationally intensive analysis is performed in a Web Worker in order to keep the interface responsive, and the recovered surface is rendered using three.js. A random-dot stereogram generator is included so that the system can be evaluated without external input.

# serve the web application locally
cd docs
python -m http.server 8000
# then open http://localhost:8000

In the live application the procedure is as follows: a sample is generated, or a user-supplied stereogram is provided; parameters are adjusted; analysis is performed; and the base texture, depth map, and interactive three-dimensional surface are inspected and, if required, exported.

← Back to all posts