Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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?

Respuestas (1)

Walter Roberson
Walter Roberson el 29 de Dic. de 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

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by