local period → disparity → depth
Drop an autostereogram here, paste one, or load a file.
No image handy? Build a test image.
Red is the image, cyan is the same image slid left by the shift. Where the pattern matches they cancel to grey; only the hidden surface breaks colour.
The image is slid over itself one pixel at a time, up to half its width. For every shift, the RMS difference over the overlapping region is measured — an area-normalised L2 distance, so wide and narrow overlaps compare fairly. The first prominent dip is the pattern period.
At that shift the background pattern cancels out. The residual |I(x) − I(x−s)| is taken across RGB, min-max normalised, pushed through a sigmoid, blurred, then opened and closed.
One shift only separates near from far. For the levels between, the dip search runs again in a grid of square cells. Each cell is matched at its own size — the summation region is the cell while the lag reaches across the row, so a cell never has to be as wide as a period.
Depth at scene point X is carried by the pair (X − sep/2, X + sep/2), so every reading is placed at that pair's midpoint. The texture overlay is pulled back by half a shift for the same reason: the pixel above a surface is not the pixel that encodes it.