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

    %% Remove Objects in Image Containing Fewer Than 50 Pixels
% 
%%
% Read binary image.

% Copyright 2015 The MathWorks, Inc.

BW = imread('text.png');
%%
% Remove objects containing fewer than 50 pixels using |bwareaopen|
% function.
BW2 = bwareaopen(BW, 50);
%%
% Display original image next to morphologically opened image.
imshowpair(BW,BW2,'montage')