Commit b6631527 authored by Barry Warsaw's avatar Barry Warsaw

triplet_to_brightness(): New function

parent 749cf344
......@@ -174,6 +174,15 @@ def triplet_to_fractional_rgb(rgbtuple):
return map(operator.__div__, rgbtuple, _maxtuple)
def triplet_to_brightness(rgbtuple):
# return the brightness (grey level) along the scale 0.0==black to
# 1.0==white
r = 0.299
g = 0.587
b = 0.114
return r*rgbtuple[0] + g*rgbtuple[1] + b*rgbtuple[2]
if __name__ == '__main__':
import string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment