matlab imfill孔洞填充

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/caomin1hao/article/details/81673709

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('孔洞被填充的图像');

 

 

 

猜你喜欢

转载自blog.csdn.net/caomin1hao/article/details/81673709