Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A Python script to make red/cyan 3D photos
from PIL import Image
import sys
# Check arguments
if len(sys.argv) < 3:
print "Usage: python make3d.py <leftimage> <rightimage> <3doutputname>"
quit()
# Open the left and right images
imLeft = Image.open(sys.argv[1])
imRight = Image.open(sys.argv[2])
# Split the images into Red, Green, and Blue
lRed, lGreen, lBlue = imLeft.split()
rRed, rGreen, rBlue = imRight.split()
# The 3D image is the Red from the Right image
# And the Green and Blue from the Left one
im3D = Image.merge('RGB', [rRed, lGreen, lBlue])
# Show it
im3D.show()
# Save it if we have an output filename
if len(sys.argv) > 3:
im3D.save(sys.argv[3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment