f=imread(‘test1.png’);
subplot(1,3,1);
imshow(f);
title(‘原图’);
bw=im2bw(f);
subplot(1,3,2);
imshow(bw);
title(‘二值图像’);
level=graythresh(f);
bw2=im2bw(f,level);
subplot(1,3,3);
imshow(bw2);
title(‘通过graythresh计算门槛值后得到二值图像’);
本文展示了如何使用MATLAB进行图像二值化处理,包括读取原始图像,转换为灰度图像,利用固定阈值和自动计算阈值进行二值化,并展示处理后的效果。
f=imread(‘test1.png’);
subplot(1,3,1);
imshow(f);
title(‘原图’);
bw=im2bw(f);
subplot(1,3,2);
imshow(bw);
title(‘二值图像’);
level=graythresh(f);
bw2=im2bw(f,level);
subplot(1,3,3);
imshow(bw2);
title(‘通过graythresh计算门槛值后得到二值图像’);

被折叠的 条评论
为什么被折叠?