Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I can to get dominant color for image? #9

Open
indapublic opened this issue Apr 8, 2017 · 9 comments
Open

How I can to get dominant color for image? #9

indapublic opened this issue Apr 8, 2017 · 9 comments

Comments

@indapublic
Copy link

I need to get dominant color for specific image (or color frequency).
For example, Color Thief can do it.
Is it possible with get-image-colors?
Thanks

@zeke
Copy link
Member

zeke commented May 3, 2017

This library does not provide a way to get the dominant color.

Is there a reason you don't want to use color thief?

I found dominant-color but it has a dependency on ImageMagick, which is not ideal.

Maybe @mattdesl or @hughskennedy know of a good module for this.

@mattdesl
Copy link

mattdesl commented May 3, 2017

Hmm last I checked color thief was basically using the same library underneath (for quantizing).

This lib should sort the results based on color frequency, so typically I just take the first color and assume it's the most dominant (ie: frequent). So it might already be what you want?

@zeke
Copy link
Member

zeke commented May 4, 2017

Wondering what "dominant" really means. 🤔

@idoo
Copy link

idoo commented Aug 13, 2019

@zeke for me it means that the average color of this image is black and blue (not semi-tones of them)

image

@issuefiler
Copy link

Wondering what "dominant" really means. 🤔

It means: “most important, powerful, or influential.”
In other words: of the largest coverage.

This lib should sort the results based on color frequency

Agreed.

@issuefiler
Copy link

domcolor

@issuefiler
Copy link

But― this might be not a good way to get a dominant color.
Reddish area can be quantized (merged) into Red and Orange instead of Red alone, in which case it’ll split the largest area up into two and ends up choosing less-covering color as the dominant.
Or reddish and blue-ish area can be quantized into Magenta (unlikely though), and produce undesired results.

@ijambro
Copy link
Contributor

ijambro commented Mar 29, 2020

get-rgba-palette, which this module depends on, has a function palette.bins, which returns the relative percentage of each color. It would seem possible to use this to sort the colors returned by the bins "amount" value.

https://github.com/mattdesl/get-rgba-palette

@zeke
Copy link
Member

zeke commented Mar 29, 2020

That's interesting @ijambro. Do you want to take a shot at that in a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants