Skip to content

Instantly share code, notes, and snippets.

@loufranco
Created July 17, 2017 12:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loufranco/61d86e7392342c40f9021024387a5dd1 to your computer and use it in GitHub Desktop.
Save loufranco/61d86e7392342c40f9021024387a5dd1 to your computer and use it in GitHub Desktop.
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