1

Let's say we have one guy wearing a blue shirt. I built haarcascade classifier which detect the shirt object. Once it detect the blue shirt object, how can I get the hexadecimal color value of the blue shirt?

input: image -> output: #0000FF (output can be multiple colors if it's possible)

I want to get this result using OpenCV with python or C++. Any useful link or paper? (I've googled it more than an hours but can't find what I want)

Thanks.!!

merry-go-round
  • 4,533
  • 10
  • 54
  • 102
  • hexcode for color is just 3 hex encoded byte values concatenated, so read the red-channel, the green-channel and the blue-channel, convert the byte value to hex-string and combine them all in a single string. In which of those steps do you have problems to solve it yourself? Here are some examples: http://www.rapidtables.com/convert/color/hex-to-rgb.htm – Micka Aug 25 '17 at 10:33
  • Yes but how can it decide it? do we take an average of the certain region? How do we do that? – merry-go-round Aug 25 '17 at 10:44
  • 1
    so your question instead is "How to evaluate the color of a pixel region?" or "How to assign a single color to a pixel region?". I would try the median of all the pixel in your mask/roi region. – Micka Aug 25 '17 at 10:47
  • Perfect..!! If you want, you can answer it with little more detail to get a reputation credits. But your reputation is over 10,000... :P – merry-go-round Aug 25 '17 at 11:34

1 Answers1

1

Converting hex color to RGB and vice-versa

If you already have the shirt segmented, you can take the mean/median rgb prior to hex conversion. If you are using this for recognition, I would also set up the primary axes of your color ellipsoid for specificity. ie establish range and distribution on each of rgb channels. you could do center point and sphere (simple color distance) if you are lazy/ it is a simple enough problem

Sneaky Polar Bear
  • 1,611
  • 2
  • 17
  • 29