calculating centroids of multiple ROIs at a time

조회 수: 9 (최근 30일)
Sunetra Banerjee
Sunetra Banerjee 2021년 6월 15일
댓글: Sunetra Banerjee 2021년 6월 16일
Hi,
I have segmented my ROIs, which are circles/ellipses. I need to calculate the centroids of all ROIs at a time and save those values in Excel file for further processing. I am not able to figure out how to do that.
I am attaching my segmented image with multiple ROIs.
Thanks in advance.

채택된 답변

DGM
DGM 2021년 6월 15일
편집: DGM 2021년 6월 15일
If you have the binarized image, just use regionprops.
inpict = imread('blobs.png'); % standard test image
S = regionprops(inpict,'centroid')
S = 28×1 struct array with fields:
Centroid
vertcat(S.Centroid)
ans = 28×2
7.2857 7.2857 5.0102 130.9389 28.0000 19.5263 48.2878 111.2950 38.0556 44.5556 42.5345 246.2414 51.7201 180.0177 52.6038 31.5094 35.5000 69.5000 36.5000 65.5000
Note that I'm not using your image in this example. I don't want to deal with cropping all the padding off, and the size (and thus the coordinates) are probably altered now anyway. Don't save images by saving the displayed figure. There's rarely a good reason to degrade images by doing that. Just use imwrite().
  댓글 수: 5
Sunetra Banerjee
Sunetra Banerjee 2021년 6월 16일
Hi,
For my work I need the centroids in ascending order of Y axis. If you have any advice, I would really appreciate it.
Thanks
Sunetra Banerjee
Sunetra Banerjee 2021년 6월 16일
Thanks a lot. I am able to sort it as i need. I followed this link: https://www.mathworks.com/matlabcentral/answers/342893-how-regionprops-orders-the-regions

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by