- commit
- b61b586b2649c9b92496741e857a0f1dc4b1c867
- parent
- 4f761ed3625fa9dc304c8d7f206869bc719442be
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-08-04 04:14
plots: add lightness comparison
Diffstat
| A | plots/lightness_comparison.png | 0 | |
| A | plots/lightness_comparison.py | 32 | ++++++++++++++++++++++++++++++++ |
2 files changed, 32 insertions, 0 deletions
diff --git a/plots/lightness_comparison.png b/plots/lightness_comparison.png
Binary files differ.diff --git a/plots/lightness_comparison.py b/plots/lightness_comparison.py
@@ -0,0 +1,32 @@
-1 1 from matplotlib import pyplot as plt
-1 2 import numpy as np
-1 3
-1 4
-1 5 def norm(x, f):
-1 6 return (f(x) - f(0)) / (f(1) - f(0))
-1 7
-1 8
-1 9 if __name__ == '__main__':
-1 10 plt.xlabel('luminance of screen (Y)')
-1 11 plt.ylabel('predicted perceived lightness (L)')
-1 12
-1 13 x = np.linspace(0, 1) ** 2
-1 14 legend = []
-1 15
-1 16 def weber(flare):
-1 17 plt.plot(x, norm(x, lambda y: np.log(y + flare)))
-1 18 legend.append(f'log(x + {flare})')
-1 19
-1 20 def stevenson(flare, alpha):
-1 21 plt.plot(x, norm(x, lambda y: (y + flare) ** alpha))
-1 22 legend.append(f'pow(x + {flare}, {alpha})')
-1 23
-1 24 weber(0.05)
-1 25 weber(0.4)
-1 26 stevenson(0, 0.333)
-1 27 stevenson(0.025, 0.333)
-1 28 stevenson(0, 0.56)
-1 29 stevenson(0, 0.68)
-1 30
-1 31 plt.legend(legend)
-1 32 plt.savefig('lightness_comparison.png')