How can I load multiple images and save in a subfolders in the same path?

1 次查看(过去 30 天)
I want to load multiple images from a folder path (''C:\Users\Subrata\Desktop\New folder\robin'') and I want to save in a sub folder ("C:\Users\Subrata\Desktop\New folder\robin\exmimg"). Where to set my original code between loading and saving code?

回答(1 个)

Walter Roberson
Walter Roberson 2018-12-29
srcdir = 'C:\Users\Subrata\Desktop\New folder\robin';
destdir = 'C:\Users\Subrata\Desktop\New folder\robin\exmimg';
srcext = '.png';
dstext = '.tif';
dinfo = dir( fullfile(srcdir, ['*' srcext]) );
numfiles = length(dinfo);
srcnames = fullfile(srcdir, {dinfo.name});
for K = 1 : numfiles
thissrcfile = srcnames{K};
[~, basename, ~] = fileparts(thissrcfile);
thisdstfile = fullfile( destdir, [basename dstext] );
thisimage = imread(thissrcfile);
....
modifiedimage = ...
imwrite(modifiedimage, thisdstfile);
end

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by