Solved

Computer vision -- quantifying "similarity" of colors

Posted on 2014-02-07
14
354 Views
Last Modified: 2014-02-14
Hi, I'm experimenting a little with computer vision, image analysis, feature detection, etc.  This question is fairly involved and I've done all the googling/web research I can do, and it probably requires someone with at least little experience in this area -- maybe I'll get lucky (wish I could offer more than 500 points).  

I'm trying to analyze a photo and pick out the shapes/objects within the photo.  I've mixed and matched with the standard algorithms that are typically used for this (sobol, canny, others), and now I'm stepping back and crunching some basic numbers and just trying to apply some common sense.

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.  Like I said, I have already tried googling and web research, I probably need to hear from someone who has actually gone a little further down this road I'm *just* starting on.
ball.png
tabulated-RGB--HSL.png
0
Comment
Question by:RonMexico
  • 5
  • 3
  • 3
  • +2
14 Comments
 
LVL 17
Comment Utility
Too complex for me I'm afraid, but your comparing of colours did remind me of this which might be of interest:
 http://web.mit.edu/persci/people/adelson/checkershadow_illusion.html
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Here are some commonly used metrics: http://en.wikipedia.org/wiki/Color_difference
But it's actually much more complicated: http://people.virginia.edu/~smb3u/ColorVision2/ColorVision2.html
You may find this to be a practical approximation: http://en.wikipedia.org/wiki/Lab_color_space
0
 

Author Comment

by:RonMexico
Comment Utility
Yep, seen those links.  Played with most of the math it describes.  What do you mean a practical approximation?

To summarize, there must be a transform that groups my data in the desired fashion (orange vs beige vs white) regardless of brightness.  I thought it was hue or hue+saturation but apparently it is not.

And frankly the transform can't be much more complicated than hsv or hsi or hsl transforms because there's not that much input data.  There are some simple equations I could plug into the next excel cells that would make orange and dark orange numerically similar.  

There are a million things I could try, could really benefit from some experience here.
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 50 total points
Comment Utility
You might use L in L*a*b space, if you can calibrate your display device.
0
 

Author Comment

by:RonMexico
Comment Utility
Okay, I'll try that.
0
 
LVL 35

Expert Comment

by:mccarl
Comment Utility
Can't you just do a threshold on the Saturation channel? Pick an appropriate threshold level, say 100 maybe and then any pixel with saturation over that is the ball.
0
 
LVL 12

Assisted Solution

by:satsumo
satsumo earned 200 total points
Comment Utility
I was going to suggest what mccarl answered. The hue will change in the shade because it gets more colour from the diffuse light.

Another way to look at this problem is to consider the answer you want. You are looking for an orange ball in the image, rather than trying to decide where orange is. The typical method for doing this is to have a reference object, in this case that would be an orange circle. The matching process involves approximating the location of the ball by subtracting the reference object from the image. As long as the subtraction produces a result close enough to zero then you have a match. The shadow or a small object obstructing the view should not matter.

The trick is how do you locate the reference object in the first place. If you can find enough orange in the image (say a 8x8 square), you can start from there and fit the circle by expanding and centering. You could try testing in a circular pattern around the first guess. Another possibility, treat the image as 4x4 pixel tiles. Center the reference circle in each tile and score for matching. With that result, make an image where each pixel is the match score from a 4x4 tile. You know have a much smaller, monochrome image to test.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:RonMexico
Comment Utility
@satsumo

"The hue will change in the shade because it gets more colour from the diffuse light."

Thanks, this is the exact thing I didn't know, I thought "hue" was a property of the ball.   If two pixels are from the same object but are shaded differently, is there some calculable color property that does *not* change?  (I haven't tried the L in L*a*b lab space yet, but it's something to try... however you sound like you know something about this, would you suggest something different or do you know that there is no such property that is unaffected by the shade?)

I can't subtract a known reference object because my actual problem is to find any object.  So all I'm trying to do at the moment as step 0 is to find regions of similar color that might represent an object in space.  And my immediate problem is simply that "similar" should disregard shading/shadows.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Object recognition involves a lot more than quantifying "similarity" of colors.
One way to reduce the effect of differences in illumination is to suppress the low frequencies in the log domain
http://www.cs.sfu.ca/~stella/papers/blairthesis/main/node35.html
0
 
LVL 35

Accepted Solution

by:
mccarl earned 250 total points
Comment Utility
If two pixels are from the same object but are shaded differently, is there some calculable color property that does *not* change?
In a word no! The problem is, as you say, "shaded differently". The different shades are due to different proportions/amounts of the different types of light (direct, diffuse, etc) falling on the ball. Take this extreme example, if you had the same setup as in the image above, but you get a torch that can make a tight spot light and you put a blue filter on it. Now shine that on the top of the ball, what will happen? The top of the ball will look bluish orange where the spot light falls, but the bottom/shaded side will look orange exactly as it does in the above image because it gets none of that spot light.

Now the above image is not that extreme, but still the top of the ball is primarly lit by the direct light hitting it and is affected by its colour. Whereas, the bottom of the ball is lit by the light that has bounced off all the walls and the objects in the room and the colour of that light has been affected by all those objects, and so when it hits the ball it can/will be different colour to that of the direct light on the top.



I can't subtract a known reference object because my actual problem is to find any object
Is the problem, to also be able to find this "any object" against any background, or will it always be this same background? (ie. the camera is fixed and you just need to find objects that come into it's field of view)   If this is ok, you can go the other way and substract an image of the background with no object in it from the image above, which will leave most of the background pixel values around 0 and any pixels where the ball is should be significantly NON-zero. Just a thought?
0
 

Author Comment

by:RonMexico
Comment Utility
"Object recognition involves a lot more than quantifying "similarity" of colors."

Obviously.
0
 

Author Comment

by:RonMexico
Comment Utility
Thanks mccarl, that helps a lot -- I understand (belatedly, perhaps) from what you're saying that the color of light bouncing off the ball and towards the camera is a function of both the ball and -- significantly -- the light source(s), so it is quite possible the shaded area appears quite different in these numbers available to me.  I won't waste time looking for a magic discriminator then, and fall back to fuzzier/tuned techniques.

Different backgrounds too, but otherwise that's a nice suggestion.  I'm biting off more than I can chew, but I like to do that sometimes.
0
 
LVL 35

Expert Comment

by:mccarl
Comment Utility
Glad to help & good luck! :)
0
 
LVL 12

Expert Comment

by:satsumo
Comment Utility
Something you might try something like the PlayStation EyeToy does. It assumes the camera is not moving. So it can compare one image to the previous image, any difference is movement. In your case, the background may be different but it does not change between frames. As long as the target objects move enough to give you a reference you should be able to detect the difference.

However, identifying non-specific objects without a reference is a very difficult problem. The best solution I've seen for that was by Google. They used their image search data to match objects against. To locate a static object against static background is similarly tricky, because the program has no idea what the object is. This is why early computer vision research used things like colored balls.

Thanks for the points.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

I. Introduction In a previous article (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_6537-PaperPort-Upgrade-How-to-download-and-install-updated-versions-of-PaperPort-11-and-12.html) (now deprecated), I discussed how to upgrad…
This article shows how to convert a multi-page PDF file into multiple image files, with one image file created for each page of the PDF. It does this by utilizing an excellent, free software package called GraphicsMagick. The solution is amazingly s…
The goal of the tutorial is to teach the user how to use the cropping tool and to straighten there photos so it does not look tilted. You will choose which photo you want to edit, crop it to you liking and make it straight.
The goal of the tutorial is to teach the user what gradient filters are and how to use them. When you have a photo and some part of the photo is either over exposed or under exposed, you use a gradient filter to help mask the need to touch up th…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now