Given a tiled background and a depth map, both of the same dimension, I tried to produce a stereogram using the following codes which was adopted from the method given by Simon Woods, but in a simplified way. However, there are defects in the outcomes. What is wrong in the codes?
depMap = Import["https://i.sstatic.net/RvZZT.jpg"];
flower = Import["https://i.sstatic.net/9vmBl.jpg"];
{wid, hei} = ImageDimensions[flower]
imData = ConstantArray[{0, 0, 0}, {hei, wid}];
imc = ImageCrop[flower, {32, hei}, Right];
exflower = ImageData[ImageAssemble[{flower, imc}]];
shift = Round[32 ImageData[depMap]] ;
For[r = 1, r <= hei, r++,
For[c = 1, c <= wid, c++,
imData[[r, c]] = exflower[[r, c + shift[[r, c]]]]]];
Image[imData]
Depth map: (800x632)
Tiled background: (800x632)
Outcome: A pyramid of flowers is expected, but instead there are a triangular stack and a triangular hole.
Accumulate
which I don't see in your implementation. $\endgroup$Accumulate
seems for they position
shifting, but the outcome was much unexpected when I put it on theshift
calculation. $\endgroup$Accumulate
was there. In your code here you are shifting each pixel relative to the background, so for every "hill" in the 3D profile you will get a matching "hole" one tile to the right. $\endgroup$