How to adjust TEXT in "regionprops" ?

2 次查看(过去 30 天)
I am using "regionprops" with "Perimeter" property. The following outcome I have achieved:
How I can move these texts below each related white line and add unit to it, i.e., 283.04 cm.
Mentioned below is the used code:
j=regionprops(binaryImage,'Perimeter','Centroid');
score= ([j.Perimeter]/(2*3.7));
figure, imshow(binaryImage);
for cnt = 1:length(j)
text(j(cnt).Centroid(1),j(cnt).Centroid(2),num2str(score(cnt)),'FontSize',12,'color','red');
end
Kindly guide.

采纳的回答

Matt J
Matt J 2022-4-19
编辑:Matt J 2022-4-19
The question doesn't seem to have anything to do with regionprops really, just with your call to text().
morespace=5;
figure, imshow(binaryImage);
for cnt = 1:length(j)
text(j(cnt).Centroid(1),j(cnt).Centroid(2)+morespace,...
num2str(score(cnt))+" cm",'FontSize',12,'color','red');
end
  1 个评论
Abdul Hannan Qureshi
编辑:Abdul Hannan Qureshi 2022-4-19
I apologize, I dont have programming background, so missed that technical aspect. Thank you for correcting me.
Issue resolved.
Thanks.

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2022-4-19
For what it's worth, see the attached demo. It explains how the blobs are numbered (labeled), which is a confusing topic for many people.

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by