"regionprops" detecting one line only

조회 수: 5 (최근 30일)
Abdul Hannan Qureshi
Abdul Hannan Qureshi 2022년 6월 6일
댓글: Abdul Hannan Qureshi 2022년 6월 6일
If anyone can identify why I am getting width of one line only.
L1 = bwlabel(s);
vislabels(L1)
k=regionprops(L1,'Area','Perimeter','Centroid');
score= (([k.Area])/([k.Perimeter]/2))
figure, imshow(s);
morespace=10;
for cnt = 1:width(k)
text(k(cnt).Centroid(1),k(cnt).Centroid(2)+morespace,...
num2str(score(cnt))+" sq cm",'FontSize',12,'color','red');
end
s.mat is attached. Kindly advise.

채택된 답변

Simon Chan
Simon Chan 2022년 6월 6일
load('s.mat')
L1 = bwlabel(s);
%vislabels(L1); % Ignore the user created function
k=regionprops(L1,'Area','Perimeter','Centroid');
score= (([k.Area])./([k.Perimeter]/2)); % Use ./ instead of /
figure, imshow(s);
morespace=10;
for cnt = 1:length(k) % Use length instead of width
text(k(cnt).Centroid(1),k(cnt).Centroid(2)+morespace,...
num2str(score(cnt))+" sq cm",'FontSize',12,'color','red');
end
  댓글 수: 1
Abdul Hannan Qureshi
Abdul Hannan Qureshi 2022년 6월 6일
Thank you for quick response. working perfect.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Image Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by