使用matlab修改单张或多张图像大小
版权声明:本文为CSDN博主「berlinpand」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/berlinpand/article/details/80082341
(1)处理单张图像
[filename,pathname]=uigetfile('*','choose a picture');%选择一张图像
path=[pathname,filename];
Origimg=imread(path);
Img=imresize(Origimg,[1000 1500]);%改变图像尺寸的大小为1500*1000
path='E:';%设定存储的文件夹
pathfile=fullfile(path,filename);
imwrite(Img,pathfile,'bmp');
参考博客:https://blog.csdn.net/feelingjun/article/details/53262058
(2)批量处理多张图像
addpath('dstImg'); %存放文件夹
addpath('Img'); %原始图像文件夹
ListName=dir('Img\*.bmp'); %图像格式
[m,n]=size(ListName);
for i=1:1:m %读取文件夹所有图像循环
origImg=imread(ListName(i).name); %readImg
Img=imresize(origImg,[1000 1500]);%改变图像尺寸的大小为1500*1000
dstName=ListName(i).name;
dstAddress='dstImg\';
All=strcat(dstAddress,dstName);
AllImg=imresize(Img,1);
imwrite(AllImg,All);
end
参考博客:https://www.cnblogs.com/alan666/p/8311811.html
————————————————