複数画像の切り出しと​ワークスペースにエク​スポートする方法につ​いて

11 Ansichten (letzte 30 Tage)
HY
HY am 8 Sep. 2021
Kommentiert: HY am 9 Sep. 2021
1枚の画像から物体検出器を使用して複数のバウンディングボックスの座標を得た後、その情報をもとに画像の切り抜きを行いたいと思っています。
for i=1:numel(idx)
imgCrop = imcrop(I,bboxes2(i,:));
figure
imshow(imgCrop)
end
このコードで実行すると複数の切り取られた画像が表示されます。
そこで、その切り取られた複数の画像をワークスペースに入れたいのですが、imgCropで代入しているため、最後の画像のみが残ります。
全ての切り取られた画像をワークスペースに残すためには、どのようにすればよいでしょうか。
よろしくお願いいたします。

Akzeptierte Antwort

Atsushi Ueno
Atsushi Ueno am 8 Sep. 2021
Bearbeitet: Atsushi Ueno am 8 Sep. 2021
セル配列で包めば全ての切り取られた画像がワークスペースに残ります。下記コードはその例です。
I = imread('peppers.png');
bboxes2 = [100 100 100 100; 200 200 50 50];
for i = 1:2
imgCrop{i} = imcrop(I,bboxes2(i,:));
%figure; imshow(imgCrop{i});
end
imgCrop
imgCrop = 1×2 cell array
{101×101×3 uint8} {51×51×3 uint8}
  1 Kommentar
HY
HY am 9 Sep. 2021
ご回答ありがとうございます。
うまく実行できました。助かりました。

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing and Computer Vision finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!