码迷,mamicode.com
首页 > 其他好文 > 详细

批量处理图像并保存

时间:2016-08-08 14:25:48      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

批量处理“处理前”文件夹中的jpg图像,并以原文件名自动保存到“处理后”文件夹中

clear all;
close all
clc
file=dir(‘C:\Users\Administrator\Desktop\处理前\*.jpg‘);
for i=1:length(file)
     I=imread([‘C:\Users\Administrator\Desktop\处理前\‘,file(i).name]);
     I_Gray=rgb2gray(I);
     I_Bw=im2bw(I,graythresh(I));
     I_R=I(:,:,1);
     I_G=I(:,:,2);
     I_B=I(:,:,3);
     %R-B
     I_RB=I_R-I_B;
     I_Bw2=im2bw(I_RB,graythresh(I_RB));
     I_Bw2Fill=imfill(I_Bw2,‘holes‘);
     I_R1=uint8(I_Bw2Fill).*I_R;
     I_G1=uint8(I_Bw2Fill).*I_G;
     I_B1=uint8(I_Bw2Fill).*I_B;
     I_Final=cat(3,I_R1,I_G1,I_B1);
     imwrite(I_Final,[‘C:\Users\Administrator\Desktop\处理后\‘,file(i).name,‘.jpg‘]);
end

  

批量处理图像并保存

标签:

原文地址:http://www.cnblogs.com/xixixing/p/5748956.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!