www.gusucode.com > images 案例代码 matlab源码程序 > images/FindRegionsWithoutHolesExample.m

    %% Find Regions Without Holes
% 
%%
% Read image and display it.

% Copyright 2015 The MathWorks, Inc.

BW = imread('text.png');
figure
imshow(BW)
title('Original Image')
%%
% Use filtering to create a second image that contains only those regions
% in the original image that do not have holes.  For these regions, the
% Euler number property is equal to 1. Display filtered image.
BW2 = bwpropfilt(BW,'EulerNumber',[1 1]);
figure
imshow(BW2)
title('Regions with Euler Number == 1')