How to save the output of a loop with sequential file numbers.

2 ビュー (過去 30 日間)
pldr-bny
pldr-bny 2019 年 2 月 18 日
回答済み: Thorsten 2019 年 2 月 18 日
I am trying to save the output of a simple face detector. I have a group image with multiple faces and want to store cropped images of each face individually, as well as a rotated version of the image. This is a simplified version of the code I am implementing and would be very grateful if someone could help me write the two output images (face_crop and imrotate) to one folder. The file names do not matter. Thank you!
I = imread('my group image')
% bounding_box is size 50
bounding_box = step(vision.CascadeObjectDetector(), I)
for i:size(bounding_box, 1)
% Save this image as 01.jpg (then 03, 05, 07 .... 99)
face_crop = imcrop(I, [227,227])
>>>
% Save this image as 02.jpg (then 04, 06, 08 .... 100)
imrotate = (face_crop, 5, 'bilinear')
>>>
end

採用された回答

Thorsten
Thorsten 2019 年 2 月 18 日
for i:size(bounding_box, 1)
face_crop = imcrop(I, [227,227])
filename = sprintf('%02d.jpg', 2*i - 1);
imwrite(face_crop, filename);
face_rot = imrotate(face_crop, 5, 'bilinear');
filename = sprintf('%02d.jpg', 2*i);
imwrite(face_rot, filename);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by