Link to home
Start Free TrialLog in
Avatar of rafaelrgl
rafaelrgl

asked on

how to know which color is predominant on jpg, bmp files

Hi, I want to see if it is possible to have one function that check one jpg file that is upload on my website and return the most predominant colors used on one jpg or bmp file.

Is this possible.
ASKER CERTIFIED SOLUTION
Avatar of Brad Groux
Brad Groux
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Paul MacDonald
A histogram is what you're referring to, and there are several graphics programs that will provide one of an image you have loaded in them, but I'm not aware of any web capability (.Net or otherwise) that will do this programatically.  That doesn't mean something like that doesn't exist.

I'll see what I can turn up for you.
Avatar of rafaelrgl
rafaelrgl

ASKER

Ok, lets say we read all pixels one by one in the image and store inside one list with the color and the number of times it found the color. so we could get some table like this below, then we would know witch color is predominant.

color         count

#ffffff       1005
#894585        256
#70b23f        3345
#d4ffff        6345
#65ab7c        747
#952e8f        9345
#fcfc81        134
#a5a391        8345
Yes, you could do that.  It's worth noting there's more to it than that, though, I think, unless you're literally after the most frequent color.  #FFFFFF, #FEFFFF, #FFFEFF, #FFFFFE will all look white to the human eye, but would be counted separately.    If that's close enough, then that might be an approach to take.