标签:
[name,path]=uigetfile(‘*.jpg;*.png;*.bmp‘,‘选择一张图片‘);
f=imread([path name]);
count = 0;
T = mean2(f);
done = false;
while ~done
countcount = count + 1;
g = f > T;
Tnext = 0.5*(mean(f(g)) + mean(f(~g)));
done = abs(T - Tnext) < 0.5;
T = Tnext;
end
g = im2bw(f, T/255);
subplot(121);
imshow(f)
subplot(122);
imshow(g);
标签:
原文地址:http://www.cnblogs.com/douyamv/p/4239960.html