フィルターのクリア

How to measure dimensions of region boundary plot?

5 ビュー (過去 30 日間)
Mohsina Zafar
Mohsina Zafar 2017 年 12 月 11 日
コメント済み: Image Analyst 2018 年 4 月 1 日
Hello,
I have an image (from MATLab example) and I want to know the number of pixels in/dimensions of the green boundary. As according to the code, the green boundary is overlaid on the image and is not a part of the image, I am unable to calculate its length or the number of pixels it has.
BW = imread('blobs.png');
Calculate boundaries.
[B,L,N] = bwboundaries(BW);
Display object boundaries in red and hole boundaries in green.
imshow(BW); hold on;
for k=1:length(B),
boundary = B{k};
if(k > N)
plot(boundary(:,2), boundary(:,1), 'g','LineWidth',2);
else
plot(boundary(:,2), boundary(:,1), 'r','LineWidth',2);
end
end
I want to make the green boundary a part of the image so that I can count its number of pixels too. Or any other way to do just that (measure the length of the green region).
Please help me in this regard.
Regards.

採用された回答

Image Analyst
Image Analyst 2017 年 12 月 12 日
Just get the size of boundary in the loop:
numPixels(k) = size(boundary, 1); % Count rows.
  3 件のコメント
Antonio Morales
Antonio Morales 2018 年 3 月 31 日
How could it be possible to get the area of the detected boundary? I am particularly interested in calculating the area to length ratio of all detected boundaries.
Thanks
Image Analyst
Image Analyst 2018 年 4 月 1 日
Use polyarea(x, y)
area = polyarea(x, y);

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by