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



补充读取所有的图像文件
  1. ext = {'*.jpeg','*.jpg','*.png','*.pgm'};  
  2.   
  3. images = [];  
  4. for i = 1:length(ext)  
  5.     images = [images dir([path ext{i}])];  
  6. end  
  7.   
  8. % images are returned with absolute path  
  9. for i = 1:length(images)  
  10.     images(i).name = [path images(i).name];  
  11. end 

 

matlab读取文件夹里所有文件的文件名

 

posted on 2015-11-10 10:00  Maddock  阅读(3898)  评论(0编辑  收藏  举报

导航