Shopping Cart (0)

Creating Depthmap Based Stereoscopic Anaglyphs in Apple Shake.

In this article I will show a technique that I use to create greyscale depthmap based stereoscopic anaglyphs in Apple Shake. The image used was taken under a microscope. The depthmap was extracted from the depth values output from the DOF stacking process done in a separate program.

DOF Stacking (Depth of Field Stacking) is a process where multiple images are taken of an object at different focus levels. The DOF stacking software then chooses the most in-focus sections from each image and makes a composite image which is clearer to view.

Here is a screenshot of the finished process tree in Shake.

Velcro at low magnification

The object we will be using for this lesson is a photograph of velcro taken at 90X magnification under the microscope.

Click on the image below for the full size starting image. Save it as velcro.jpg

Here is the matching greyscale depthmap. Save it as greymap.png

Copy and paste the following code into your Shake node view:

FileIn = SFileIn("$HOME/Desktop/velcro.jpg", "Auto", 0, 0, "v1.1",
"0", "");
greymap = SFileIn("$HOME/Desktop/greymap.png", "Auto", 0, 0,
"v1.1", "0", "");
Resize1 = Resize(greymap, 3072, 2048, "default", 0);
Sharpen1 = Sharpen(FileIn, 100, 20, xPixels/GetDefaultAspect(),
Expand1 = Expand(Resize1, 0.3, 0.3, 0.3, 0, 0.75, 0.75, 0.75,
Saturation1 = Saturation(Sharpen1, 0.2);
Gamma1 = Gamma(Saturation1, 0.4, rGamma, rGamma, 1);
Brightness1 = Brightness(Gamma1, 1.84820426);
IDisplace1 = IDisplace(Brightness1, Expand1, 60, 0, 0.3, 0, "R",
"n", 0, xDelta);
Copy1 = Copy(IDisplace1, Brightness1, 1, "ngbn", 0);
Copy2 = Copy(IDisplace1, Brightness1, 1, "nnb", 0);
CCrop1 = CCrop(Copy1, 247, 0, 3072, 2048);
CCrop2 = CCrop(Copy2, 247, 0, 3072, 2048);
Anaglyph = FileOut(CCrop1, "$HOME/Desktop/anaglyph.png", "Png");
ColorCode3D = FileOut(CCrop2, "$HOME/Desktop/colorcode.png",
"Png");// User Interface settings

The process tree imports the two images. Then the color image is sharpened, and desaturated. Next gamma adjustment and brightness are run on the color image to make the colors pop.

The greyscale depthmap is resized to match the color image. An expand node is used to boost the contrast of the greyscale depthmap. (If you are using greyscale shaded rotoshapes for the depthmap you may have to apply a medium intensity blur to the depthmap so the displacement effect doesn’t cause tearing. ) Then the color image is sent into the foreground input of the displace node. The greyscale depthmap is fed into the background input of the displace node.

The scale and dOffset values will be tuned in the displace node for adjusting the stereoscopic parallax and convergence and will be different for each image. In the displace node for this image I am using a scale of 60 on X and 0 on Y. I use a dOffset of 0.3 on the x. The xChannel is R (red) and the yChannel is n (none).

The copy node is an easy way to make a red / cyan anaglyph. I copy the green and blue channels from the right image (background input) and merge it with the red channel from the left image (foreground input). Type ngbn into the channels field.

To make a Color Code compatible amber / blue image type nnbn into the channels field.

Insert a crop node to crop off the edges of the frame that don’t contain both left and right image data.

Below is the final output from the Shake process tree. Red / Cyan Anaglyph:

ColorCode3D compatible Amber / Blue: