Stereogram Decoder Workbench block matching · semi-global smoothing

The SIRDS Workbench run backwards. Drop in an autostereogram and the page works out how far each part of the pattern has been shifted against its own repeat, which is the hidden depth map.

Starting…

Things to try

  • Round trip. Pause the SIRDS Workbench, screenshot the canvas, and paste it here. Its depth view should come back.
  • Smoothing off. Set smoothing to none and shrink the window. The speckle is what block matching alone gives you.
  • Wrong period. Click the plot at twice the period. The matcher locks onto every second repeat and the depth flattens.
  • Geometric. With the example loaded, the implied μ in the readout should be close to the 0.33 it was made with.

Keys: S side by side, X cross-eyed, D download, F full screen.

Pipeline

  1. The image is drawn to a canvas, at most 960 pixels wide, and split into luminance or RGB planes.
  2. Every row is compared with itself shifted by s, for shifts from 5% to 35% of the width. The deepest dip in that curve is the pattern period, the separation of the far plane.
  3. For each shift near the period, the absolute difference between the two half-shifted copies is box-filtered over the window, giving a cost for every pixel and shift.
  4. Each pixel takes the cheapest shift, either directly or after semi-global aggregation along four directions, refined to a fraction of a pixel.
  5. Shift becomes depth. Smaller separation is nearer, and so brighter.

Matching

C(x, y, s) = Σ |I(x − s/2, y) − I(x + s/2, y)|
s(x, y)    = argmin over s of C(x, y, s)
μz         = 2 (p − s) / (2p − s)

The sum runs over the window, and p is the period. The last line is the SIRDS Workbench formula s = (1 − μz) · E / (2 − μz) solved for depth, with E = 2p.

Semi-global smoothing adds a small penalty when neighbours differ by one pixel of shift and a larger one for any bigger jump, summed along rows and columns in both directions. A strip half a period wide at each side has no partner to compare against, so it copies its neighbour.