Reducing the size of images by a loop
7 ビュー (過去 30 日間)
古いコメントを表示
Here I reduced the size of an image. But I want to reduce the size of all the images of my folder. Images are : abc_20190304_0001 to abc_20190304_0095. How can I make the loop?
I=imread('abc_20190304_0001.png');
imshow abc_20190304_0001.png
L = imresize(I,.25,'bilinear');
figure, imshow(L);
0 件のコメント
採用された回答
KSSV
2021 年 9 月 8 日
imgNames = dir('*.png') ; % give your exntenion of images in the folder
N = length(imgNames) ; % toal number of images
% loop for each image
for i = 1:N
thisImg = imgNames(i).name ;
I=imread(thisImg);
figure(1)
imshow(I) ;
L = imresize(I,.25,'bilinear');
figure(2)
imshow(L);
end
7 件のコメント
Image Analyst
2021 年 9 月 8 日
You can use sprintf()
baseFileName = sprintf('%4.4d.png', i); % 0001.png for example.
fullOutputFileName = fullfile(outputFolder, baseFileName);
imwrite(L, fullOutputFileName);
その他の回答 (1 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!