How can i detect Green and Blue color from an image?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
odai kiwan
el 26 de Feb. de 2018
Respondida: Cam Salzberger
el 26 de Feb. de 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 comentarios
Respuesta aceptada
Cam Salzberger
el 26 de Feb. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!