How can i detect Green and Blue color from an image?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
odai kiwan
le 26 Fév 2018
Réponse apportée : Cam Salzberger
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.
Réponse acceptée
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
0 commentaires
Plus de réponses (0)
Voir également
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!