mirror of
https://github.com/freedoom/freedoom.git
synced 2025-08-31 02:16:55 -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 = []
|
||||
|
||||
for color in colors:
|
||||
average = (color[0] + color[1] + color[2]) // 3
|
||||
inverse = 255 - average
|
||||
# Formula comes from ITU-R recommendation BT.709
|
||||
gray = round(color[0]*0.2126 + color[1]*0.7152 + color[2]*0.0722)
|
||||
inverse = 255 - gray
|
||||
|
||||
result.append((inverse, inverse, inverse))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue