我创建了一个 matlab 代码,它计算图像中所有矩形的长度和宽度,
结果出现在命令窗口中。
但我希望结果应该出现在图像本身中,每个矩形旁边都有长度和宽度。
我的代码是
I = imread('F:\h.png');
info = imfinfo('F:\h.png');
I1 = ~im2bw(I);
I2 = bwlabel(I1);
S = regionprops(I2, {'BoundingBox'});
[m,n] = size(S);
for a=1:m
for b=1:n
width = S(a,b).BoundingBox(3);
height = S(a,b).BoundingBox(4);
if width==height
display('square');
else
display('rectangle');
end
display(width);
display(height);
pause(2)
end
end