gusucode.com > 《matlab图像处理与界面编程宝典》秦襄培 编著,每章的MATLAB源代码程序 > 第24章/代码24-5.txt
BW = imread('blobs.png'); % 读入图像 [B,L,N] = bwboundaries(BW); % 描绘边界 figure; 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