EyalAr / lwip

Light Weight Image Processor for NodeJS
MIT License
2.37k stars 230 forks source link

Extract dominant color from an image? #244

Open palmerabollo opened 8 years ago

palmerabollo commented 8 years ago

Is it possible to get the dominant color or, even better, a representative color palette from an image with lwip? I've not seen that option in the API. Thanks.

MarkOtten commented 8 years ago

I added the function dominateColor to my fork. I think it's what you're looking for. You can check it out here

palmerabollo commented 8 years ago

Thanks @MarkOtten. Thats a good starting point. If I understand it well, in a 3x2 image with the following pixels, your function would return blue instead of "red". Is that right?

pixel 0 : (255, 0, 0) pixel 1 : (254, 0, 0) pixel 2 : (253, 0, 0) pixel 3 : (252, 0, 0) pixel 4 : (0, 0, 255) pixel 5 : (0, 0, 255)

MarkOtten commented 8 years ago

That is correct. It looks for an exact match, not a range of colors