MATLAB: Find an object in an image by color

colorcolor segmentationdetectionimage processingImage Processing Toolbox

So I'm using a webcam to take a color picture of an area. In that area there is a red thing and a green thing among a bunch of other things. Basically I need to return the location of the center of the red thing and the green thing. The exact shape of the objects is not known in advance.
Basically I just need to tell matlab to find the color thing and have it give me coordinates from a color image

Best Answer

See my attached demo where I track a green thing in the video. It's a simple matter to add a check for red things.