color-thief
color-thief copied to clipboard
how to get a Picture color percentage?
Hello, can you get the percentage of the color value of the picture?
Hi,
Not sure what you're after here. Are you looking to know how many pixels have the exact RGB value returned by color-thief? What about similar colors, ie. colors that are 1, 2 or 3 values off from the RGB value returned?
When it comes to the palette, this is also an arbitrary construct which uses the median cut algorithm provided by quantize.js to cluster similar colors. So the below code, which returns 8 colors, might actually return colors that have little 'real' representation in the image.
var colorThief = new ColorThief();
colorThief.getPalette(sourceImage, 8);
I hope that clarifies things.
I think he means he wants to know which color occurs more and which are the ones that occur less.
And Google vision API has it.
You can look at a demo here Vision
Screenshot:
Up. I also want to know this. Because i'm using 7 colors on my pallet, but imagine i have a big cluster with 80% of dominant color, 15% of secondary color and 5% a mix of the others, dominant and secondary must have priorites and identification of.
I think quantize.js does show the cluster size of some color, so, we can compare the cluster size with the picture size to get % of that.