www.gusucode.com > images 案例代码 matlab源码程序 > images/CreateBinaryMaskFromConnectedPixelsExample.m
%% Create Binary Mask from Connected Pixels % %% % Create small sample image. % Copyright 2015 The MathWorks, Inc. I = uint8([20 22 24 23 25 20 100 21 10 12 13 12 30 6 22 11 13 12 13 25 5 23 13 13 13 13 20 5 24 13 13 12 12 13 5 25 26 5 28 29 50 6]); %% % Create mask image, specifying the seed location by row and column and the % tolerance. Since the seed location specifies the pixel with the value % |23| and the tolerance is |3| , the range of grayscale values is % |[20,26]|. seedrow = 4 seedcol = 1 tol = 3 BW = grayconnected(I,seedrow,seedcol,tol)