Matlab 读取文件夹中所有的bmp文件
将srcimg文件下的bmp文件转为jpg图像,存放在dstimg文件夹下
str = 'srcimg'; dst = 'dstimg'; file=dir([str,'\*.bmp']); for i=1:length(file) img = imread( [str,'\',file(i).name]); imwrite(img, [dst,'\',file(i).name(1:end-4),'.jpg']); end
补充读取所有的图像文件
- ext = {'*.jpeg','*.jpg','*.png','*.pgm'};
- images = [];
- for i = 1:length(ext)
- images = [images dir([path ext{i}])];
- end
- % images are returned with absolute path
- for i = 1:length(images)
- images(i).name = [path images(i).name];
- end