99designs / colorific

Automatic color palette detection
ISC License
700 stars 55 forks source link

Conversion to LAB #9

Closed 00hello closed 12 years ago

00hello commented 12 years ago

I may be mistaken but how come you don't convert to the LAB color space as you state in this article? Perhaps, I'm not clear on it but it looks like the only one you're converting to is RGB on line 126.

dhotson commented 12 years ago

This distance function takes care of this: https://github.com/99designs/colorific/blob/master/colorific.py#L102-L104

The delta_e function takes care of the conversion I believe.

larsyencken commented 12 years ago

Good question!

Amongst all that we're doing, the important part where we use the LAB color space is in comparing the distance between two colors, or Delta-E. This happens [here](happens https://github.com/99designs/colorific/blob/master/colorific.py#L104), on line 104. In other versions, we explicitly converted from RGB to LAB space, then calculated the Delta-E. But it turns out that the colormath library does this for you automatically, so in our case the conversion to LAB space is done inside the call to delta_e().

That's why you couldn't see it in the code.