New submission from Mats Luspa: 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 ---------- components: Library (Lib) messages: 259659 nosy: Mats Luspa priority: normal severity: normal status: open title: colorys rgb_to_hls algorithm error _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26296> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com