fengsp / color-thief-py Goto Github PK
View Code? Open in Web Editor NEWGrabs the dominant color or a representative color palette from an image. Uses Python and Pillow.
Home Page: http://lokeshdhakar.com/projects/color-thief/
License: Other
Grabs the dominant color or a representative color palette from an image. Uses Python and Pillow.
Home Page: http://lokeshdhakar.com/projects/color-thief/
License: Other
The results provided by the python wrapper seem to vary a lot as compared to the results provided by https://lokeshdhakar.com/projects/color-thief/#examples
For example, here's the result of the website as compared to the result of the py wrapper.
RGB: (219,210,202)
Whereas the python wrapper gives the RGB output as (61, 54, 40)
I tried alternating the quality from 10 to 1 but I can't get a result close to the original result.
Sometimes you already have the image as a PIL Image
object and re-reading as another Image
is a wasted of memory. Currently, I'm re-implementing ColorThief
like this:
# Overrides init of ColorThief to pass in the buffer from memory
class ColorThiefFromImage(ColorThief):
def __init__(self, image):
self.image = image
I think it could be super interesting to plot the source image with the obtained cluster colors!
Only passing a image file into the Colorthief method work, but I wish to input an array. How can I achieve the same?
Self explanatory
I tried color_thief = ColorThief(url) and it would not work
If this is not implemented, I'd take a stab at it
I am not storing images to disk. I want to use by directly passing Image object, how can I do that?
For a certain image the RBG value was (256, 252, 212)
This value for R should not exists as RGB values are 32 bit values [0-255]. Cant share the image for privacy reasons.
The repo files are looking like they are six to seven years old June 12 2015, and the last Pypi update was 2017 https://pypi.org/project/colorthief/
Color thief use rgb color space, is it possible to use lab space or customize distance function?
Though my install says
Requirement already satisfied: colorthief in /home/quinten/anaconda2/lib/python2.7/site-packages
Requirement already satisfied: Pillow in /home/quinten/anaconda2/lib/python2.7/site-packages (from colorthief)
Requirement already satisfied: olefile in /home/quinten/anaconda2/lib/python2.7/site-packages (from Pillow->colorthief)
We need to add method where we will be cleaning after themselves, eg closing Image
For now we can do this color_thief.image.close()
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?
This URL (screenshot)
resolves to this URL
which gives this error message:
Cannot proxy the given URL
Take the following image: https://ibb.co/R3dnBpz
Calling using: dominant_color = color_thief.get_color(quality=1)
The dominant color is clearly yellow (244, 237, 12) but it returns (28, 51, 49).
hi, i am calling get_palette() function to get dominant colors and i need to have percentage of each color i mean when i get 6 color from this function i need to know how many pixels of that color in the image. how can i get that info?
The code will not be able to detect complete dominant white images with values like (254,254,254)
.
Please modify the code of get_palette()
to:
r, g, b, a = pixels[i]
# If pixel is mostly opaque and not white
if a >= 125:
if not (r > 255 and g > 255 and b > 255):
valid_pixels.append((r, g, b))
Setting the threshold of 250
is causing the problem
I don't want to do this myself as I'm not too familiar with PyPi or exactly how this code works but someone with more experience should really make a fork where pull requests can actually get merged and issues fixed.
Another Python library provides the same functionality: haishoku.
However both libs do not return the same palette:
The first line of colored circles is the palette from colorthief
, the second line is the palette from haishoku
.
Why do they differ so much?
( Source image: doom slayer by tis1451 - CC BY-SA 3.0 )
Can you suggest how to get the score of the predicted color in a palette?
dominant_color = ColorThief(image).get_palette(color_count=3, quality=10)
returns
[(47, 36, 65), (171, 176, 180), (139, 153, 171), (122, 134, 165)]
(with this particular image).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.