Mantuik.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import getpass
  2. import os
  3. import subprocess
  4. import shutil
  5. from HDR.Methods import Method
  6. from Tool import Property
  7. class Mantuik06(Method):
  8. def stack(self, files):
  9. if(not os.path.exists("/tmp/hdr-%s" % getpass.getuser())):
  10. os.mkdir("/tmp/hdr-%s" % getpass.getuser())
  11. command = ["align_image_stack", "--gpu", "-a", "/tmp/hdr-%s/OUT_" % getpass.getuser(), "-o",
  12. "/tmp/hdr-%s/OUT" % getpass.getuser()] + files
  13. print(command)
  14. subprocess.call(command)
  15. return ["/tmp/hdr-%s/OUT.hdr" % getpass.getuser(),]
  16. def run(self, files, output, full_width, full_height):
  17. command = "pfsin --radiance '%s' | pfstmo_mantiuk06 -f %.2f -s %.2f | pfsgamma --gamma %.2f | pfsout '%s'" % \
  18. (files[0], self.props["contrast"].get_value(), self.props["saturation"].get_value(),
  19. self.props["gamma"].get_value(), output)
  20. print(command)
  21. os.system(command)
  22. shutil.rmtree("/tmp/hdr-%s" % getpass.getuser())
  23. def on_init(self):
  24. self.id = "Mantuik06"
  25. self.name = "Mantuik '06"
  26. self.properties = [
  27. Property("contrast", "Contrast", "Slider", 0.1, min=0, max=1),
  28. Property("saturation", "Saturation", "Slider", 0.8, min=0, max=2),
  29. Property("gamma", "Gamma", "Slider", 2.0, min=0, max=3)
  30. ]
  31. class Mantuik08(Method):
  32. def stack(self, files):
  33. if(not os.path.exists("/tmp/hdr-%s" % getpass.getuser())):
  34. os.mkdir("/tmp/hdr-%s" % getpass.getuser())
  35. command = ["align_image_stack", "--gpu", "-a", "/tmp/hdr-%s/OUT_" % getpass.getuser(), "-o",
  36. "/tmp/hdr-%s/OUT" % getpass.getuser()] + files
  37. print(command)
  38. subprocess.call(command)
  39. return ["/tmp/hdr-%s/OUT.hdr" % getpass.getuser(),]
  40. def run(self, files, output, full_width, full_height):
  41. display = self.props["display"].options[self.props["display"].get_value()].lower().replace(" ", "_")
  42. saturation = self.props["saturation"].get_value()
  43. contrast = self.props["contrast"].get_value()
  44. command = "pfsin --radiance '%s' | pfstmo_mantiuk08 --display-function pd=%s -c%.2f -e%.2f | pfsout '%s'" % \
  45. (files[0], display, saturation, contrast, output)
  46. print(command)
  47. os.system(command)
  48. shutil.rmtree("/tmp/hdr-%s" % getpass.getuser())
  49. def on_init(self):
  50. self.id = "Mantuik08"
  51. self.name = "Mantuik '08"
  52. self.properties = [
  53. Property("display", "Display", "Combo", 0, options=[
  54. "LCD",
  55. "LCD Office",
  56. "LCD Bright",
  57. "CRT"
  58. ]),
  59. Property("saturation", "Saturation", "Slider", 1, min=0, max=2),
  60. Property("contrast", "Contrast", "Slider", 1, min=0, max=10)
  61. ]