How can i detect Green and Blue color from an image?

4 vues (au cours des 30 derniers jours)
odai kiwan
odai kiwan le 26 Fév 2018
My project is about colors and shapes detection. I detected what the shape is, But my problem is how to detect the color in this case? like this image for example.
  2 commentaires
Rik
Rik le 26 Fév 2018
This question is impossible to answer without an example and/or a description. Have a read here and here. It will greatly improve your chances of getting an answer.
odai kiwan
odai kiwan le 26 Fév 2018
like this pic

Connectez-vous pour commenter.

Réponse acceptée

Cam Salzberger
Cam Salzberger le 26 Fév 2018
Hello Odai,
If you are able to determine the shape of objects in the image, then you likely have the location of the item as well - (row, col) of centroid, or maybe even dimensions or bounding box. If you are simply trying to answer an "is this object red or blue?", you could simply pick a pixel or a patch and check the greatest color channel:
if I(row, col, 1) > I(row, col, 2) && I(row, col, 1) > I(row, col, 3)
disp('Red!')
elseif I(row, col, 2) > I(row, col, 3)
disp('Green!')
else
disp('Blue!')
end
Of course, that's pretty suboptimal and naive, but it serves to illustrate. You can do something smarter by doing the average over the whole shape, or compare the average's RGB vector to some known colors to find what it is "closest" to.
Hope that helps!
-Cam

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by