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.
Is this possible.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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.
I'll see what I can turn up for you.