How to run all the image with format jpg in folder? and save into folder?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dayangku Nur Faizah Pengiran Mohamad
am 22 Apr. 2024
Kommentiert: Dayangku Nur Faizah Pengiran Mohamad
am 22 Apr. 2024
Hello. Anyone know how to run a folder with thousand images instead of run one by one the image? and save into folder?
I=imread('11_285.jpg');
imshow(I)
magnificationFactor = 1.2;
J=imresize(I,magnificationFactor, 'bilinear');
imshowpair(I,J,method="montage")
imwrite(J,'11_285_rescale.jpg');
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 22 Apr. 2024
dinfo = dir('*.jpg');
filenames = fullfile({dinfo.folder}, {dinfo.name});
nfiles = length(filenames);
magnificationFactor = 1.2;
for K = 1 : nfiles
thisfile = filenames{K};
[folder, basename, ext] = fileparts(thisfile);
outfile = fullfile(folder, basename + "_rescale" + ext);
I = imread(thisfile);
J = imresize(I, magnificationFactor, 'bilinear');
imwrite(J, outfile);
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Import, Export, and Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!