I have an image with a car(only the car with a little background) in it. I need to find the color of the car. I tried getting the most frequent R, G, B values and combining them, but this may not guarantee the most frequent (R, G, B) pixel (can it?). I also tried making kmeans-clusters of (R, G, B) pixels and get the centroid of the biggest cluster. But I don't know what k to use. Which method do I use?
Asked
Active
Viewed 118 times
2
-
both and compare them if they are both say one color is the most common color then you know it is that color that is dominant for shure – Matthijs990 Apr 17 '19 at 11:55
-
It's kind of hard to answer this question because "dominant" doesn't have a single well-defined meaning. For example, you could sum each colour channel, or take the median, or use deep learning... – gmds Apr 17 '19 at 12:19
-
check [this](https://stackoverflow.com/a/35482205/5008845) – Miki Apr 17 '19 at 12:25
-
There is also a [similar question here](https://stackoverflow.com/q/3241929/190597). – unutbu Apr 17 '19 at 12:25
-
2If you choose to use the k-means clustering algorithm then there is no single correct choice for `k`. But there are a [number of proposed ways](https://en.wikipedia.org/wiki/Determining_the_number_of_clusters_in_a_data_set) to choose `k`. – unutbu Apr 17 '19 at 12:28
-
Here are about 40 similar questions: https://stackoverflow.com/search?q=%5Bopencv%5D+dominant+color+is%3Aq – beaker Apr 17 '19 at 15:02
-
Thanks @beaker. I found out this can be done using H-histogram from HSV value of the image. Is there a sensible way to convert this H to BGR? – Avinash Apr 17 '19 at 15:11