轉自https://blog.csdn.net/weixin_42211203/article/details/88188573#commentBox
從上述文章中學習到了如何批量存儲到一個文件夾中
附上我自己的代碼:
str='C:\Users\25400\Desktop\截取\2\'; %我的圖像放在C盤,Users\25400\Desktop\截取下,0文件夾下
img_path_list=dir(strcat(str,'*.bmp'));%獲取該文件夾下所有bmp格式的圖像,是一個結構體
for i=1:6
image_name=img_path_list(i).name;%獲取圖像名
I=imread([str,num2str(i),'.bmp']); %依次讀取每一幅圖像
n = imresize(I,[42,24]);%改變圖像大小爲42*24
imwrite(n,fullfile('C:\Users\25400\Desktop\2', image_name),'bmp');%將處理後的圖片保存到目標文件夾
end