Color finding on RGB image
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sam CP
el 25 de Jun. de 2018
Comentada: Walter Roberson
el 28 de Jun. de 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 comentarios
Walter Roberson
el 25 de Jun. de 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.
Walter Roberson
el 28 de Jun. de 2018
(This discussion carries on from https://www.mathworks.com/matlabcentral/answers/407086-can-i-use-color-map-to-find-which-color-is-the-most-used-color-in-an-image)
Respuesta aceptada
Walter Roberson
el 27 de Jun. de 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 comentarios
Stephen23
el 28 de Jun. de 2018
Would it be worth using Lab to make it slightly more perceptually uniform?
Walter Roberson
el 28 de Jun. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Filtering and Enhancement en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!