下の画像の白いブロブの周りにバウンディングボックスを描画しようとしています。
私はこれが好きでした:
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の答えは実際に問題を正確に解決しました。