MATLAB: Getting the coordinates of green colored portion.

coordinate extractionImage Processing Toolboxrgb

i have an image. i have extracted out the green coloured portion from it. now i want the coordinates of that green area. how can i do that?

Best Answer

So you have a binary image, because you say you've already extracted locations of the green pixels. So simply label and call regionprops if you want the centroid
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Centroid');
or if you want the x,y coordinates of each pixel, on a blob-by-blob basis, do this:
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'PixelList');
If you don't want coordinates on a blob-by-blob basis and just want everything all in one giant list, you can use find():
[rows, columns] = find(binaryImage);