轉自:http://blog.csdn.net/cike0cop/article/details/53087995
html
%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轉自:http://blog.csdn.net/wuzuyu365/article/details/78215268
%把一個目錄下的圖片縮放到指定大小 dpath = 'D:\tst測試工做\測試文件\清晰照片庫1300張'; lst = dir(dpath); cnt = 0; for i=1:length(lst) if isdir(lst(i).name) continue; end tpath = [lst(i).folder,'\', lst(i).name]; im=imread(tpath); [m,n,c]=size(im); if m < 1 || n < 1 fprintf('bad image, %s\n', tpath); continue; end if m<500 || n<500 cnt = cnt+1; fprintf('%d, small image,(%d,%d), %s\n', cnt, m,n, tpath); x= min(m,n); ratio = 505 / x; im=imresize(im, ratio); imwrite(im, tpath); end end
轉自:http://www.cnblogs.com/rong86/p/3558344.html算法
matlab中函數imresize簡介:函數
函數功能:該函數用於對圖像作縮放處理。測試
調用格式:spa