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

Posted on 2014-08-15
Last Modified: 2015-09-05
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.
Question by:rafaelrgl
    LVL 14

    Accepted Solution

    It isn't possible with any out of box solution that I know of, if it is possible it would have to be a custom application. Online editing apps like Pixlr have the ability to identify the color with the color selector tool so it isn't difficult to have a web app identify a color from an image or selection... however, the added complexity of scanning every pixel in an image and then determining which color is the most predominant would take some pretty difficult logic programming.

    Long story short, it should be possible - but it probably won't be easy.
    LVL 33

    Expert Comment

    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.
    LVL 1

    Author Comment

    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
    LVL 33

    Expert Comment

    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.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now