Ask Your Question
0

quantifying "similarity" of colors

asked 2014-02-07 02:12:49 -0600

Hi, this isn't a question about opencv itself, but a question that I came across while using it and I am sure you are the correct audience for it.

I'm just starting out with computer vision, trying to analyze a photo and pick out the shapes/objects within the photo. I've mixed and matched with a couple of the standard algorithms that come with opencv, and now I'm stepping back and crunching some basic numbers and just trying to apply some common sense, getting a little more fundamental.

I took a photo of a ball on a table (attached) and tried to imagine an algorithm to find the ball. It is the big region of orange in the middle, but the first problem is that it is not perfectly uniform orange, it has a shadow across it so that it is brightest at the upper left and darker at the lower right. It's all the same color but varying brightness.

So I thought, how do I normalize on brightness so that the computer sees a blob of uniform orange in the middle? Well, if I take the RGB data and transform it to HSL, well then perhaps I should see the "luminance" (L) change across the ball and the H+S will stay the same. Then the computer could just modify all the colors to have the same "L" of the HSL and then we will see a relatively uniform orange.

So I sampled some pixels and did the RGB->HSL transform by hand (tabulated and color coded, also attached), and found that it does not work like that. I thought hue and saturation, or at LEAST the hue, would be uniform across the ball. It is not, the saturation and hue both drop significantly as the shadow increases.

Out of curiosity I sampled some points from the regions of the picture from the back wall (gray-ish) and the table it's sitting on (beige). I started to realize that I couldn't pick out anything numerically similar between the groups of colors (orange ball, gray wall, beige table). I would have thought that the hue, or hue+saturation stayed the same while maybe the luminance changes with the brightness.

So... if that is not the rule, what IS the rule? What is the math that would group these sets of points together? Maybe there is some other transform other than RGB-HSL that makes it apparent? Obviously there is something, since it is IMMEDIATELY obvious to our eyes: those are orange, those are gray, and those are beige (of varying brightnesses).

Thanks very much for reading this far, and any thoughts.

ball.png

tabulated RGB, HSL.png

edit retag flag offensive close merge delete

Comments

Perhaps you should use the LAB color space.

GilLevi gravatar imageGilLevi ( 2014-02-18 08:39:35 -0600 )edit

"I took a photo of a ball on a table (attached) and tried to imagine an algorithm to find the balll". How about training a classifier / or model which will figure out the algorithm for detection by itself. That's called deep learning. Let the neuronal network figure a way how to detect your ball.

holger gravatar imageholger ( 2018-06-29 06:54:26 -0600 )edit

@holger please pay attention of post date

LBerger gravatar imageLBerger ( 2018-06-29 07:14:51 -0600 )edit
1

Oohhh i see - this was 4 years ago. I will pay attention to this in the future. So this was a zombie post from me.

holger gravatar imageholger ( 2018-06-29 07:17:21 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-02-17 22:48:25 -0600

prakharmohan gravatar image

Considering the question regarding identification of the ball, have you thought of edge detection as a possible way of detecting the ball?

Also, as your background is completely white, why not go for contour detection? It might pose a problem because you are using a basketball and it has dots on the surface for gripping the ball, but I think you can decide the size of the contours too, in that case you can use Contour detection as another method for detecting the ball. (Not too sure about this)

And Lastly, color detection, since your ball is orange and the color is not similar to any other color in the image you can use color detection, and once you have detected/identified the color you can apply edge detection for better detection of the ball. I came up with these three methods. Please not that the methods are computationally expensive.

Hope this helps :)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-02-07 02:12:49 -0600

Seen: 1,056 times

Last updated: Feb 17 '14