Clear Filters
Clear Filters

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

1 view (last 30 days)
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?

Answers (1)

Walter Roberson
Walter Roberson on 29 Dec 2018
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

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!