Skip to content
Advertisement

How to find the Dominant color in image?

i want to find the dominant color in image, how can i do it ?

it would be great if i can get this in HEX code (exm: #eeeeee)

Advertisement

Answer

To find the most “dominant” color in an image, meaning the color that is most prevalent in the image: you’d need to create a histogram of the image.

Here is an the code from this article on how to create a histogram in PHP. (Website has gone off line several times)

JavaScript

In that example $max is your most “dominant” color.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement