我正在尝试在下图中的白色斑点周围绘制一个边界框:
我确实喜欢这样:
bw = imread('box.jpg');
bw=im2bw(bw);
imshow(bw)
L = bwlabel(bw);
s = regionprops(L, 'Area', 'BoundingBox');
s(1);
area_values = [s.Area];
idx = find((100 <= area_values) & (area_values <= 1000)); % list of all the objects
%whose area is between 100 and 1000
bw2 = ismember(L, idx); %construct a binary image containing all the objects whose
%area is between 100 and 1000 by passing L and idx to ismember.
imshow(bw2)
到目前为止,输出 bw2 是:
有人能告诉我如何在这个斑点(白色)周围画一个边界框吗?
更新 Wajih 的答案实际上准确地解决了这个问题。