Use imwrite to save processed images to different folder.
    7 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (1)
  Image Analyst
      
      
 on 12 Oct 2020
        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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!