How to run all the image with format jpg in folder? and save into folder?
2 次查看(过去 30 天)
显示 更早的评论
Dayangku Nur Faizah Pengiran Mohamad
2024-4-22
评论: Dayangku Nur Faizah Pengiran Mohamad
2024-4-22
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 个评论
采纳的回答
Walter Roberson
2024-4-22
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Import, Export, and Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!