v 0. Pasted by _W as python at 2008-12-06 19:22:28 MSK and set expiration to never.

Paste will expire never.

  1. import Image
  2. import sys
  3.  
  4.  
  5. def img_resized(in_filename):
  6.     img = Image.open(in_filename)
  7.     w, h = img.size
  8.     img = img.resize((w/4, h/4), Image.ANTIALIAS)
  9.     return img
  10.  
  11. def colorize_red_cyan(img_l, img_r):
  12.     r1,g1,b1 = img_l.split()
  13.     r2,g2,b2 = img_r.split()
  14.     return Image.merge("RGB", (r1, g2, b2))
  15.  
  16.    
  17. def merge_for_red_cyan_stereo(img_l_fn, img_r_fn, out_fn):
  18.     img_l, img_r = img_resized(img_l_fn), img_resized(img_r_fn)
  19.     colorize_red_cyan(img_l, img_r).save(out_fn)
  20.  
  21. in_left, in_right = sys.argv[1], sys.argv[2]
  22. merge_for_red_cyan_stereo(in_left, in_right, 'out.png')


Editing is locked.