color-thief icon indicating copy to clipboard operation
color-thief copied to clipboard

how to get a Picture color percentage?

Open cnvp opened this issue 6 years ago • 4 comments

Hello, can you get the percentage of the color value of the picture?

cnvp avatar Aug 15 '18 02:08 cnvp

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.

AlfredJKwack avatar Dec 02 '18 13:12 AlfredJKwack

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: download

phanirithvij avatar Mar 28 '19 20:03 phanirithvij

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.

eeerrrttty avatar May 02 '19 15:05 eeerrrttty

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.

eeerrrttty avatar May 02 '19 18:05 eeerrrttty