www.gusucode.com > images 案例代码 matlab源码程序 > images/DisplayObjectBoundariesInRedAndHoleBoundariesInGreenExample.m
%% Display Object Boundaries in Red and Hole Boundaries in Green % %% % Read binary image into workspace. BW = imread('blobs.png'); %% % Calculate boundaries. [B,L,N] = bwboundaries(BW); %% % Display object boundaries in red and hole boundaries in green. imshow(BW); hold on; for k=1:length(B), boundary = B{k}; if(k > N) plot(boundary(:,2), boundary(:,1), 'g','LineWidth',2); else plot(boundary(:,2), boundary(:,1), 'r','LineWidth',2); end end