Open jyotiska opened 9 years ago
I'm also interested in this data. Is there another library that can do it?
I am also interested in the same data @jyotiska @richardcornish Please let me know if it's possible
If @jyotiska, @amitmadan18, or anybody else needs this information, I figured it out with the help of an issue at the original color-thief repo.
Change the palette
method at line 356 in colorthief.py from:
def palette(self):
return self.vboxes.map(lambda x: x['color'])
to:
def palette(self):
total = sum(self.vboxes.map(lambda x: x['vbox'].count))
return self.vboxes.map(lambda x: x['color'] + (x['vbox'].count, total, int(x['vbox'].count / float(total) * 100)))
I simply added additional members to each RGB tuple:
Now palette = color_thief.get_palette(color_count=3)
will return something like [(236, 70, 70, 1875, 1000, 18), (4, 4, 252, 625, 1000, 6), (4, 4, 4, 7500, 1000, 75)]
, giving 18%, 6%, and 75%. Tweak to your liking. Fork the repo to make your change.
Correct. If I remember correctly, I also came up with my own hack something like this to print out the histogram.
Thanks. Even I had came up with the same solution :) On 14 Jun 2016 11:34, "Jyotiska Khasnabish" notifications@github.com wrote:
Correct. If I remember correctly, I also came up with my own hack something like this to print out the histogram.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fengsp/color-thief-py/issues/1#issuecomment-225787844, or mute the thread https://github.com/notifications/unsubscribe/AHC3hFI2OnmsJS8iskJNADXIIsJNEbpyks5qLkRWgaJpZM4Eepfi .
Is is comming to the main package or do I need to make a fork myself?
Hi,
I am playing with this for a last couple of days. Is it possible to return the percentage each color covers in a given image?