getting the coordinates of green colored portion.

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?

 Accepted 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);

More Answers (1)

If you have matrix X of zeros and ones, where the ones mark the the pixels of the green object, you can extract its x and y coordinates using
[y, x] = find(X);

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!