how to save an image dataset into a specific folder

2 次查看(过去 30 天)
Hello everyone, I'm trying to read from a folder and apply pre-processing techniques on an images dataset and then save the dataset to another folder, but it's not working for me,
here is my code and thanks in advance for your help
clear
close all;
Source = "my_dataset_source";
imds = imageDatastore(Source,"IncludeSubfolders",true,"FileExtensions",".jpg");
for i= 1 :size(imds.Files,1)
I = readimage(imds,i);
%*************************processing images
FileName = fullfile('D:\targetfolder',sprintf('%d.jpg',i));
imwrite(I,sprintf('%d.jpg',i),'jpg');
end

采纳的回答

Voss
Voss 2022-3-14
FileName = fullfile('D:\targetfolder',sprintf('%d.jpg',i));
imwrite(I,FileName,'jpg');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by