mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-01 13:25:46 -04:00
colormap: use a crispier grayscale algorithm
Instead of averaging the RGB values, use a formula that better approximates how the human eye sees color. Formula was taken from this page: http://www.tannerhelland.com/3643/grayscale-image-algorithm-vb6/
This commit is contained in:
parent
6566845f05
commit
4ccdc785d0
1 changed files with 3 additions and 2 deletions
|
@ -132,8 +132,9 @@ def invert_colors(colors):
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
for color in colors:
|
for color in colors:
|
||||||
average = (color[0] + color[1] + color[2]) // 3
|
# Formula comes from ITU-R recommendation BT.709
|
||||||
inverse = 255 - average
|
gray = round(color[0]*0.2126 + color[1]*0.7152 + color[2]*0.0722)
|
||||||
|
inverse = 255 - gray
|
||||||
|
|
||||||
result.append((inverse, inverse, inverse))
|
result.append((inverse, inverse, inverse))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue