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

4 次查看(过去 30 天)
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 个评论
Rik
Rik 2018-2-26
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.

请先登录,再进行评论。

采纳的回答

Cam Salzberger
Cam Salzberger 2018-2-26
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 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by