what is the ideal solution to find a color in an image?

11 views (last 30 days)
Hi, what is the ideal solution to find a color in an image? knowing that I have used these lines with matlab but I didn't come to make clear the correct RGB values of colors. Every time I find a value for example light brown I found that: R = 173, G = 129, B = 80 and on other sites I found that: R = 181, G = 101, B = 29
idx = I(:,:,1) == ?? & I(:,:,2) == ?? & I(:,:,3) == ??;
C = any( idx(:) );
thanks

Answers (2)

Image Analyst
Image Analyst on 15 Oct 2012
Guess what? They're both light brown. Did you think that light brown was only 1 of the 16 million possible colors, and not, say tens of thousands of possible values? Actually colors are a continuum and where in color space you say one color stops and the other takes over is a matter of opinion - a judgment call. What you call a color can span a range of RGB values - it's not just one single value.
You might want to look over my color segmentation tutorials: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
  37 Comments
Pamela Paolo
Pamela Paolo on 3 Nov 2012
Moved: DGM on 30 Dec 2023
To find a specific color (blue-grey) in an image we can't use:
idx = I(:,:,1) == ?? & I(:,:,2) == ?? & I(:,:,3) == ??;
C = any( idx(:) );
Because every color has many R, G and B values. So how i can find this color without using a uniform image?
Image Analyst
Image Analyst on 4 Nov 2012
Moved: DGM on 30 Dec 2023
Right. And I know you've seen my color classification tutorials in my File Exchange, so......why can't you use one of them? What colors you get around blue-gray depends on what method you use. The delta E mathod carves out a sphere out of the gamut in LAB space, while the HSV method carves out a sector in HSV space. So, while similar, they may get different colors out near the extremes of the range you're extracting.

Sign in to comment.


Pamela Paolo
Pamela Paolo on 5 Nov 2012
The delta E method allows the user to pick a color as an example from the image and then it will find all the other pixels with similar color to that in the image while this isn't the case in my project. The code should allow to find a specific color from the beginning (blue-grey) without user intervention. As you said, to adapt this code to our situation, we can use it to find the mean LAB or HSV color of blue-grey. How? What is the image used to find this mean Lab or HSV color of blue-grey?
This code <https://www.mathworks.com/matlabcentral/fileexchange/28512-simple-color-detection-by-hue/content/SimpleColorDetectionByHue.m> detect yellow regions using a given low and high thresholds. In my case i don't have the low and high thresholds of blue-grey. How can I do this?
  6 Comments
Image Analyst
Image Analyst on 6 Nov 2012
Moved: DGM on 30 Dec 2023
I do understand your question. I know you don't know the values - yet - that's why I said " just look at the h, s, and v values at some particular pixel location that has a blue-gray pixel to discover what the h, s, and v values actually are". Then you know what the values are, then you hard code it into your program. Why will that not work?
Image Analyst
Image Analyst on 15 Nov 2012
Moved: DGM on 30 Dec 2023
Pick your color values from one of these web sites:
http://ivrg.epfl.ch/files/content/sites/ivrg/files/research/alindner/CIC2012/www/ColorThesaurus.html Type blue-grey (using the UK spelling of gray) into the search field. You can type any color in any language in and get the color. Or, pick a color from a color picker and find out the names in 9 or 10 different languages for that color.

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!