Giter VIP home page Giter VIP logo

Comments (6)

richardcornish avatar richardcornish commented on July 29, 2024 5

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:

  • The pixel count of each color
  • The total sum of all pixels, which will always be the same
  • The integer percentage of each color

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.

from color-thief-py.

richardcornish avatar richardcornish commented on July 29, 2024

I'm also interested in this data. Is there another library that can do it?

from color-thief-py.

amitmadan18 avatar amitmadan18 commented on July 29, 2024

I am also interested in the same data @jyotiska @richardcornish
Please let me know if it's possible

from color-thief-py.

jyotiska avatar jyotiska commented on July 29, 2024

Correct. If I remember correctly, I also came up with my own hack something like this to print out the histogram.

from color-thief-py.

amitmadan18 avatar amitmadan18 commented on July 29, 2024

Thanks. Even I had came up with the same solution :)
On 14 Jun 2016 11:34, "Jyotiska Khasnabish" [email protected]
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
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AHC3hFI2OnmsJS8iskJNADXIIsJNEbpyks5qLkRWgaJpZM4Eepfi
.

from color-thief-py.

raoulspronck avatar raoulspronck commented on July 29, 2024

Is is comming to the main package or do I need to make a fork myself?

from color-thief-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.