Use imwrite to save processed images to different folder.
    조회 수: 9 (최근 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!

