Use imwrite to save processed images to different folder.
Mostrar comentarios más antiguos
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!
Respuestas (1)
Image Analyst
el 12 de Oct. de 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 comentarios
Guan-Lin Chen
el 12 de Oct. de 2020
Guan-Lin Chen
el 13 de Oct. de 2020
Guan-Lin Chen
el 13 de Oct. de 2020
Image Analyst
el 13 de Oct. de 2020
Either use double backslashes, or use forward slashes. If you're using Windows, Windows handles forward slashes just fine.
Guan-Lin Chen
el 13 de Oct. de 2020
Guan-Lin Chen
el 13 de Oct. de 2020
Guan-Lin Chen
el 13 de Oct. de 2020
Categorías
Más información sobre Image Preview and Device Configuration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!