Depth map example derived from stereoscopic image pairsWritten by Paul Bourke
A number of approaches exist for creating depth map. Some, such as AI methods and manual painting are based upon single images. Others attempt to recreate a depth map by measuring local disparity in a stereoscopic image pair. An example of this will be presented here for a cylindrical panorama. The left and right panoramas are presented below, note that these are captured using rotating slit cameras and as such are "perfect", that is, there are no radial depth variations that often arise from stitching a small number of photographs.
Note that these are just low resolution representations, the originals are 20,000+ pixels wide.
One of the algorithms is called DMAG, standing for Depth Map Automatic Generator, an implementation of the "Fast Cost-Volume Filtering for Visual Correspondence and Beyond" originally described by Christoph Rhemann, Asmaa Hosni, Michael Bleyer, Carsten Rother, and Margrit Gelautz.
The first depth map below is from variant 5 of this approach, often referred to as dmag5. This is often followed by a pass through dmag9, the most common implementation being: "The Fast Bilateral Solver" by Jonathan Barron and Ben Poole.
While not always necessary, or desirable, for interactive applications one often applies a Gaussian smooth in order to avoid the sharp corners and visual defects they introduce.
The application explored here for depth maps is to use them to allow slight left/right/up/down/forward/back movement within panoramas, in addition to the normal pan left/right/up/down. The implementation here creates a 3D textured mesh from the depth map, this can be explored in Sketchfab. While the perspective image below of the mesh looks "funky", the scene looks correct when viewed from the origin.
The grey scale depth maps are converted to a 3D textured mesh using software by the author. The distance corresponding to white and black are defined by command line arguments, in this case they are 1m and 20m, the actual distances of the respective depths in the scene.
Usage: depth2obj [options] depthfilename Options: -z0 n closest depth, default: 1 -z1 n furthest depth, default: 10 -s n subsample depth map resolution, default: 4