www.gusucode.com > images 案例代码 matlab源码程序 > images/OverlayRegionBoundariesOnImageExample.m
%% Overlay Region Boundaries on Image % %% % Read grayscale image into the workspace. I = imread('rice.png'); %% % Convert grayscale image to binary image using local adaptive % thresholding. BW = imbinarize(I); %% % Calculate boundaries of regions in image and overlay the boundaries on % the image. [B,L] = bwboundaries(BW,'noholes'); imshow(label2rgb(L, @jet, [.5 .5 .5])) hold on for k = 1:length(B) boundary = B{k}; plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2) end