BW2 = imfill(BW)

作用填充二值图像BW中的空洞

 

clear all; clc; close all;

img = imread('test1.png');

if ndims(img)==3

    img = rgb2gray(img);

end

img_bw = im2bw(img);

img_fill = imfill(img_bw, 'holes');

figure;

subplot(1,2,1),imshow(img_bw), title('有空洞的图像');

subplot(1,2,2),imshow(img_fill), title('孔洞被填充的图像');

 

 

 

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐