フィルターのクリア

"regionprops" detecting one line only

2 ビュー (過去 30 日間)
Abdul Hannan Qureshi
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 Center および File ExchangeGet 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