Last active
August 29, 2015 14:08
-
-
Save godber/2beaccd01a4519e0c701 to your computer and use it in GitHub Desktop.
Splits Red/Cyan Anaglyph into Left and Right Images and writes those images out into files with the same filename with '-left' or '-right' appended.
This file contains hidden or 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
import os | |
from scipy import misc | |
def split_anaglyph_file(infile): | |
""" | |
Splits Red/Cyan Anaglyph into Left and Right Images and writes those images | |
out into files with the same filename with '-left' or '-right' appended. | |
""" | |
image = misc.imread(infile) | |
if len(image.shape) == 3: | |
h, w, b = image.shape | |
filename, extension = os.path.splitext(infile) | |
left_outfile = filename + "-left" + extension | |
right_outfile = filename + "-right" + extension | |
misc.imsave(left_outfile, image[:,:,0]) | |
misc.imsave(right_outfile, image[:,:,1]) | |
print "Images written: %s, %s" % (left_outfile, right_outfile) | |
else: | |
print 'WARNING: Input image does not have 3 bands: %s (skipped)' % infile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The choice of using
image[:,:,1]
was made arbitrarily, it could have beenimage[:,:,2]
, or perhaps it depends on how the anaglyph is made. This is for grayscale anaglyphs only.