We first find out the correlation between $f$ and $g$ by constructing a graph and calculate its connected components. Where $f$ and $g$ are pixel value on the object and on the image plane, $\alpha$ is the difference of viewing angle of two eyes, and $h(x,y)$ are the depth of the image. Then we start to create the stereogram using the following equation: Input are a texture image img, a corresponding depth image depth, and a background image bg.įirst three lines of code are responsible for formatting the image to the same scale. The fourth optional argument is the maximum pixel shift in the upsampled image - this is also the number of distinct depth planes. The final function stereogram takes as arguments the pattern image, the depth image and the desired number of tiles in width and height. I have used compilation to C but for those without a C compiler it will work just as well (but a bit slower) using the WVM. This is to allow a greater number of depth planes without having to explicitly interpolate to get sub-pixel shifts.įor better performance I use a compiled function to do the actual pixel-copying core of the algorithm. I upsample the pattern image and depth map before creating the stereogram, and afterwards downsample the result back to the correct size. This version is based on the description here. This is a complete change from my original code - my apologies for doing such a major edit after receiving so many upvotes but it was not quite right before (there were artifacts in the 3D view). Here's an alternative method which takes a depth map.
0 Comments
Leave a Reply. |