Filter löschen
Filter löschen

Color finding on RGB image

3 Ansichten (letzte 30 Tage)
sam  CP
sam CP am 25 Jun. 2018
Kommentiert: Walter Roberson am 28 Jun. 2018
I have an RGB image ,i have to find the dominant color from this image. Dominant color means the highlighting color. (That will be red,blue,green, yellow etc.). What all are the steps that can be implemented in this process?
  26 Kommentare
Walter Roberson
Walter Roberson am 25 Jun. 2018
Hmmm, that link at least gives more information to go with, but I can't say I am inspired with any ideas as to how one might program the concept.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Jun. 2018
I took the actionable ideas from the paper that OCDER linked to, and developed some code.
The paper talked in terms of purity of primary color, and it talked in terms of contrast, and it talked in terms of portion of the image occupied. So my code calculates though three factors, normalizes them each to 1, and then comes up with an aggregate statistic by taking the geometric mean (geometric mean is less likely to favor a location that ranks high in only one of the three.)
What I found is that if the image has black, then the measure is likely to pick out the black as being the most dominant. This is because:
  • black often occupies a large total fraction of the area (even if only in ones and twos in the background.)
  • black is pure primary color
  • isolated black pixels surrounded by non-black pixels have a high contrast
So when the three measures are used together, it is not uncommon for black to be declared most dominant.
data.jpg and data6.jpg both have black pixels selected as most dominant. The standard demo image "peppers" picks out a yellow pixel though.
  8 Kommentare
Stephen23 am 28 Jun. 2018
Would it be worth using Lab to make it slightly more perceptually uniform?
Walter Roberson
Walter Roberson am 28 Jun. 2018
Defining distance in L*a*b* is a bit tricky, as you have to figure out whether the three components should be treated as being on the same scale. I got sidetracked for a bit trying to figure out what the ranges of values were, got sidetracked from that, ended up calculating as if they were all equal.
With the test images I ran through, it ended up not making any difference as to which pixel was selected, but it did make a difference in the details of the pattern. I suppose that would mean that if there was an image with more neutral colors, then it might pick out a different neutral color.
However, along with the changes needed to determine distance in L*a*b* space, I took the opportunity to disqualify black from the list of eligible pure colors. That did make a difference, leading to the selection of an olive yellow pixel in the waterfall image (instead of the large black background); a red pixel in the lantern image (instead of the more subtle black mixed in with the green); and a white pixel on the peppers image (instead of a yellow pixel.)
In all three cases, the exact pixel selected ends up being driven mostly by the contrast calculation, and ends up being a pixel on the boundary of a similar area (that might be quite small), because boundaries establish contrast.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by