MATLAB图像处理:底帽变换和二值化
% 读取图片 img = imread('4-1.bmp');
% 底帽变换 se = strel('disk', 2); % 创建2个像素的磁盘元素结构 img_c = imtophat(img, se);
% 二值化 level = graythresh(img_c); % 使用Otsu的方法自动确定阈值 bw = imbinarize(img_c, level); % 二值化
% 显示结果 subplot(1,2,1); imshow(img); subplot(1,2,2); imshow(bw, 'DisplayRange', [0 1]); % 添加 'DisplayRange' 参数,显示二值化图像的灰度级。
原文地址: https://www.cveoy.top/t/topic/mYKR 著作权归作者所有。请勿转载和采集!