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讀取文件夾里所有文件的文件名

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM