🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

  1. import OpenEXR
  2. import Imath
  3. import numpy as np
  4. import simpleimageio as sio
  5. width = 420
  6. height = 32
  7. border_left = 0
  8. border_right = 420 - 80
  9. num_splats = 10000
  10. red = np.zeros((height, width), dtype=np.float32)
  11. green = np.zeros((height, width), dtype=np.float32)
  12. blue = np.zeros((height, width), dtype=np.float32)
  13. # splat random color values
  14. rng = np.random.default_rng()
  15. row = rng.integers(low=0, high=height, size=num_splats)
  16. col = rng.integers(low=border_left, high=border_right, size=num_splats)
  17. # if any of the three channels has a fixed value, the problem goes away!
  18. red[row, col] = rng.random(num_splats)
  19. green[row, col] = rng.random(num_splats)
  20. blue[row, col] = rng.random(num_splats)
  21. # add a bunch of test pixels
  22. red[-8, -10] = 1
  23. green[-8, -10] = 1
  24. blue[-8, -10] = 1
  25. red[-4, -8] = 1
  26. green[-4, -8] = 1
  27. blue[-4, -8] = 1
  28. red[-4, -2] = 1
  29. green[-4, -2] = 1
  30. blue[-4, -2] = 1
  31. red[-2, -3] = 0 # setting this to anything other than 0 fixes the problem
  32. green[-2, -3] = 1
  33. blue[-2, -3] = 1
  34. # fill in all of the black region with 0-red color
  35. # red[:,border_right:] = 0
  36. # green[:,border_right:] = 1
  37. # blue[:,border_right:] = 1
  38. # write PIZ compressed via OpenEXR
  39. header = OpenEXR.Header(width, height)
  40. header['compression'] = Imath.Compression(Imath.Compression.PIZ_COMPRESSION)
  41. exr = OpenEXR.OutputFile("gen.exr", header)
  42. exr.writePixels({'R': red.tobytes(), 'G': green.tobytes(), 'B': blue.tobytes()})
  43. exr.close()
  44. # read back in via tinyexr (used internally by simpleimageio)
  45. tinyresult = sio.read("gen.exr")
  46. sio.write("test2.exr", tinyresult)