您当前的位置: 首页 >  matlab

星夜孤帆

暂无认证

  • 2浏览

    0关注

    626博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Matlab批量将文件夹内图片进行二值化,并保存

星夜孤帆 发布时间:2018-07-14 14:48:52 ,浏览量:2

files = dir(fullfile('C:\Users\Administrator\Desktop\ttt\原图1\','*.jpg'));
lengthFiles = length(files);
for i = 1:lengthFiles;
    Img = imread(strcat('C:\Users\Administrator\Desktop\ttt\原图1\',files(i).name));%文件所在路径
    Img = rgb2gray(Img);%将RGB图变为灰度图
    thresh = graythresh(Img); %自动确定阈值
    Img = im2bw(Img,thresh); %对图像二值化
%     Img = medfilt2(Img); %中值滤波
    imshow(Img);
    imwrite(Img,strcat('C:\\Users\\Administrator\\Desktop\\ttt\\原始二值图1\\a',num2str(i),'.jpg'));
    close all;
end
关注
打赏
1636984416
查看更多评论
立即登录/注册

微信扫码登录

0.0410s