Use imwrite to save processed images to different folder.
12 次查看(过去 30 天)
显示 更早的评论
Dear all,
I need help with saving processed images to different folder with imwrite.
Currently, I can save all processed images to a single folder.
Img_filename=ls('C:\Users\User\Desktop\Guanlin_CNN1D\CNN1D\GF_BSIF\*.jpg');
imageSize = size(Img_filename);
Img_filenum = size(Img_filename,1);
for img=1:Img_filenum
img_temp=double((rgb2gray(imread(Img_filename(img,:)))));
-----------processing--------
count = count+1;
FileName = fullfile('C:\Users\User\Desktop\Guanlin_CNN1D\CNN1D\GF_BSIF\folder_1',sprintf('%03d_circle_cropped.jpg',count));
imwrite(MM, FileName)
end
However, I have 1000 different images in 1 folder and after processing, it will generate 500 images and wanted to save the first 500 processed images into folder_1. And the second 500 processed images to folder_2 and the third 500 images to folder_3 and so on...
How to re-write the imwrite function?
Thank you!
0 个评论
回答(1 个)
Image Analyst
2020-10-12
folder = sprintf('C:\Users\User\Desktop\Guanlin_CNN1D\CNN1D\GF_BSIF\folder_%3.3d', img);
baseFileName = sprintf('%03d_circle_cropped.jpg', img);
FileName = fullfile(folder, baseFileName);
7 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!