Comments (6)
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.
I'm also interested in this data. Is there another library that can do it?
from color-thief-py.
I am also interested in the same data @jyotiska @richardcornish
Please let me know if it's possible
from color-thief-py.
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.
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.
Is is comming to the main package or do I need to make a fork myself?
from color-thief-py.
Related Issues (20)
- Add mehotd to recover original image replaced with clustered colors
- We need to close Image at some point
- Pass in image to __init__ instead of filename HOT 1
- sample image URL is invalid HOT 1
- Anyone know how you can instantiate a colorthief class with a url?
- Dominant color not working properly HOT 1
- Inaccurate results HOT 1
- get_palette crashing on one image
- Creating a fork
- ImportError: cannot import name 'ColorThief'
- How can I pass Image Object of PIL to initialize? HOT 1
- About complete white image having values (254,254,254) HOT 2
- How to pass an array and get the corresponding dominent RGB color results?
- is it possible to customize color space or distance function?
- Question: comparison with haishoku HOT 1
- The RGB values get_palette is > 255
- Does this still work HOT 1
- how do i get color count percentage?
- ImportError: cannot import name ColorThief HOT 2
- Get the score of the color_palette HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from color-thief-py.