wswartzendruber

HLG EOTF

Jul 5th, 2022 (edited)
167
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.44 KB | None
  1. #!/usr/bin/env groovy
  2.  
  3. int range = 940 - 64;
  4.  
  5. for (r in 0..range) {
  6.  
  7.     def e = (double)r / (double)range;
  8.     def o = new BigDecimal(eotf(e))
  9.  
  10.     println("${r + 64}: ${o.toPlainString()}")
  11. }
  12.  
  13. double eotf(double o) {
  14.  
  15.     def y = ioetf(o)
  16.  
  17.     return 1_000.0 * Math.pow(y, 1.2 - 1.0) * y
  18. }
  19.  
  20. double ioetf(double e) {
  21.  
  22.     return e < 0.5 ? Math.pow(e, 2.0) / 3.0 : (Math.exp(((e - 0.55991073) / 0.17883277)) + 0.28466892) / 12
  23. }
RAW Paste Data Copied