www.gusucode.com > images 案例代码 matlab源码程序 > images/LabelComponentsUsing4connectedObjectsExample.m
%% Label Components Using 4-connected Objects % %% % Create a small binary image. % Copyright 2015 The MathWorks, Inc. BW = logical ([1 1 1 0 0 0 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 0 0 0 0]); %% % Create the label matrix using 4-connected objects. L = bwlabel(BW,4) %% % Use the |find| command to get the row and column coordinates of the % object labeled "2". [r, c] = find(L==2); rc = [r c]