MATLAB中均值法图像阈值分割的实现代码如下:im = imread('图片路径'); [m, n] = size(im); t = mean(mean(im)); bw = zeros(m,n); for i=1:m for j=1:n if (im(i, j) > t) bw(i, j) = 1; else bw(i, j) = 0; end end end imshow(bw);
MATLAB中均值法图像阈值分割的实现代码如下:im = imread('图片路径'); [m, n] = size(im); t = mean(mean(im)); bw = zeros(m,n); for i=1:m for j=1:n if (im(i, j) > t) bw(i, j) = 1; else bw(i, j) = 0; end end end imshow(bw);