Created
July 17, 2017 12:41
-
-
Save loufranco/61d86e7392342c40f9021024387a5dd1 to your computer and use it in GitHub Desktop.
A Python script to make red/cyan 3D photos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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