fengsp / color-thief-py

Grabs the dominant color or a representative color palette from an image. Uses Python and Pillow.
http://lokeshdhakar.com/projects/color-thief/
Other
1.04k stars 125 forks source link

Changed RGB from 250 to 255 #9

Open UnKn0wn27 opened 6 years ago

UnKn0wn27 commented 6 years ago

This is an awesome project! Works the way it is intended. The only thing I don't understand is why ignore white color RBG that is higher than 250? I would understand if it was just mono-color images but it is only focused on images that are white and gives me an error. Could you please explain?

Here are a few of the images that gave me the errors.

https://user-images.githubusercontent.com/29236212/35098291-40acd384-fc5c-11e7-9407-e0595f7a2df8.png

https://user-images.githubusercontent.com/29236212/35098299-4536df1c-fc5c-11e7-9878-3f2c30c7f9d9.png

Krzysiu commented 2 years ago

JPEG compression gets crazy with extreme values. While this is barely noticeable by eyes/our perception, it's a pain when I'm doing tools that depends on color statistics. Often the most reliable and fastest way is to ignore these values. This library could provide some optional parameter to override it, but for most cases 250 is much better than 255.

The other reason I can think of is that photo with overexposed parts would give wrong main color - because overexposed blue and red would turn into white and white. While our perception will be able to rebuild missing color information, computer algorithms can't do much. Alas, this point is probably not the reason, as in this case we should ignore also very low values.