Message259659
In the colorsys library function rgb_to_hls the algorithm is not implemented quite correctly.
According to algorithm the correct implementation should be (the error is in the condition r == maxc). In the current code g<b is not tested:
def rgb_to_hls(r, g, b):
maxc = max(r, g, b)
minc = min(r, g, b)
# XXX Can optimize (maxc+minc) and (maxc-minc)
l = (minc+maxc)/2.0
if minc == maxc:
return 0.0, l, 0.0
if l <= 0.5:
s = (maxc-minc) / (maxc+minc)
else:
s = (maxc-minc) / (2.0-maxc-minc)
rc = (maxc-r) / (maxc-minc)
gc = (maxc-g) / (maxc-minc)
bc = (maxc-b) / (maxc-minc)
if r == maxc:
if (g<b):
h = bc-gc+6
else:
h = bc-gc
elif g == maxc:
h = 2.0+rc-bc
else:
h = 4.0+gc-rc
h = (h/6.0) % 1.0
return h, l, s |
|
Date |
User |
Action |
Args |
2016-02-05 14:00:12 | Mats Luspa | set | recipients:
+ Mats Luspa |
2016-02-05 14:00:12 | Mats Luspa | set | messageid: <1454680812.05.0.172060571572.issue26296@psf.upfronthosting.co.za> |
2016-02-05 14:00:12 | Mats Luspa | link | issue26296 messages |
2016-02-05 14:00:11 | Mats Luspa | create | |
|