Matlab图像二值化

2026-02-14 20:36:04

1、首先读取到一张图片

I = imread('fordebug.bmp');

Matlab图像二值化

2、用graythresh和im2bw命令

thresh = graythresh(I);     %自动确定二值化阈值

I2 = im2bw(I,thresh);       %对图像二值化

--------------------------------------------------

--------------------------------------------------

Matlab图像二值化

3、说明:

  1.graythresh命令为 Matlab 自动确定最佳阈值

  2.im2bw 为二值转换函数

 效果就出来了!

Enjoy!

猜你喜欢