Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. from glob import glob
  2. import sys
  3. import array
  4. import OpenEXR
  5. import Imath
  6. import scipy.io
  7. import scipy.misc
  8. import numpy as np
  9.  
  10. # This could eventualy be useful
  11. sA = scipy.io.loadmat('solidAngles')
  12. d = np.dstack((sA['solidAngles'], sA['solidAngles'], sA['solidAngles']))
  13.  
  14. for f in glob('*-img.exr'):
  15. print(f)
  16. f_mask = f.rsplit("-", 1)[0] + "-mask.exr"
  17. f_mask_hdl = OpenEXR.InputFile(f_mask)
  18. FLOAT = Imath.PixelType(Imath.PixelType.FLOAT)
  19. Y = np.array(array.array('f', f_mask_hdl.channel("Y", FLOAT)).tolist())
  20.  
  21. f_hdl = OpenEXR.InputFile(f)
  22.  
  23. # Read the three color channels as 32-bit floats
  24. FLOAT = Imath.PixelType(Imath.PixelType.FLOAT)
  25. (R,G,B) = [array.array('f', f_hdl.channel(Chan, FLOAT)).tolist() for Chan in ("R", "G", "B")]
  26. R = np.array(R)
  27. G = np.array(G)
  28. B = np.array(B)
  29. #import pdb; pdb.set_trace()
  30.  
  31. # Apply mask (Is that what we want?)
  32. #R, G, B = [X[Y>0.5] for X in (R, G, B)]
  33.  
  34. # Set masked zones to black
  35. R[Y<0.5] = 0
  36.  
  37. # Display example
  38. R = R.reshape(256,256)
  39. scipy.misc.imsave('r.png', R)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement