Matlab 文件夹遍历并更改图片尺寸
2015-08-29 16:26
357 查看
关键词
dircode
function imageReshape() % reshape objects to 384 x 256 or 256 x 384 so can be use in ImageRetrieval src='D:\Program\matlab\bgslibrary_mfc\dataset\objects'; des='D:\Program\matlab\ImageRetrieval\objects'; % layernum=3; len1=384; len2=256; pathlist1=dir(src); filenum1=length(pathlist1); filenamelist1={pathlist1.name}; filenum1=min(filenum1,1000); for i=3:filenum1 imgsrcpath=[src,'\',filenamelist1{i}]; % imgdespath=[des,'\',int2str(i),'.png']; imgdespath=[des,'\',filenamelist1{i}]; imgsrc=imread(imgsrcpath); [width,height]=size(imgsrc); if(width>height) %row=width=len1, col=height [row,col]=[width,height] imgdes=imresize(imgsrc,[len1,len2]); imwrite(imgdes,imgdespath); else imgdes=imresize(imgsrc,[len2,len1]); imwrite(imgdes,imgdespath); end end
相关文章推荐
- matlab mod()&rem()
- matlab常用小函数(一)
- matlab函数之diag
- matlab 数组 乱序
- MATLAB求解线性规划(含整数规划和0-1规划)问题
- python 深度模仿 matlab 矩阵语法
- Matlab自定义函数的几种方法
- Matlab中如何将(自定义)函数作为参数传递给另一个函数
- 牛顿方法的简单MATLAB编程示意
- 牛顿方法的简单MATLAB编程示意
- logistic 回归Matlab代码
- logistic 回归Matlab代码
- matlab中中图像PSNR和SSIM的计算
- 下载matlab2014a的安装程序
- Platform Road Map for the MATLAB and Simulink Product Families
- Matlab: Support Vector Machine (SVM 支持向量机)
- Matlab.NET混合编程技巧之直接调用Matlab内置函数
- WPF调用Matlab函数方法
- 在Matlab中使用WPF
- 在matlab中提取线性方程组的系数矩阵