Results 1 to 2 of 2

Thread: How detect dominant color in a picture?

  1. #1
    Join Date
    Mar 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How detect dominant color in a picture?

    I have to detect dominant color in a picture, have any idea about?
    This is why I want to draw a shadow with the dominant color of my app background.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How detect dominant color in a picture?

    This is a tricky problem without some constraints placed on it. If you're working with screen images of a GUI, it may be as simple as counting pixels of a handful of screen colors to see which is most prevalent. If you're working with continuous-tone photographs, you'll have to do something like bin each pixel into a histogram based on Hue in HSV space, then (maybe) take the average of HSV in the bin with the most pixels.

    Even then, you may have to account for "blobs", areas in the picture where a particular color is dominant, while other colors which may be more numerically prevalent will be ignored because they are disconnected or diffused throughout the image.

    A simple, not very accurate approach might be to reduce the image to the size of a single pixel using one of the more rigorous interpolation techniques, then measure the value of that single pixel. Faster and less work than doing it right, and it might even work.

    Another approach would be a modified Median Cut algorithm, looking for the largest partitioned volume in whatever color space is used. Again, HSV would probably be best here.

Similar Threads

  1. Replies: 3
    Last Post: 22nd January 2010, 16:46
  2. Display Label Color by selecting Color Picker
    By sosanjay in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2009, 06:11
  3. can't load picture
    By aoo7wangyan in forum Qt Programming
    Replies: 9
    Last Post: 13th July 2009, 14:59
  4. Picture on a button
    By zgulser in forum Qt Tools
    Replies: 4
    Last Post: 13th January 2009, 04:03
  5. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.