图片大小批量处理代码(MATLAB)

%author:coplin
%time:2016-10-10
%function:change the size of Image.
addpath('dealImg');
addpath('Img');
ListName=dir('Img\*.jpg');
[Pm,Pn]=size(ListName);
for iPm=1:1:Pm %读取文件夹所有图片循环    
oriImg=imread(ListName(iPm).name);    %readImg
cutImg=imcrop(oriImg,[50,50,255,255]);
%bi=imresize(oriImg,0.6);        %bi缩放为ai的0.6倍
%endImg=imresize(cutImg,[256,256]);         %把ai转成256x256的大小
iDealName=ListName(iPm).name;
iDealAddress='dealImg\';
iDealAll=strcat(iDealAddress,iDealName);
ID=imresize(cutImg,1);
imwrite(ID,iDealAll);
end

你可能感兴趣的:(图片大小批量处理代码(MATLAB))