www.gusucode.com > images 案例代码 matlab源码程序 > images/VisualizeSegmentationResultExample.m
%% Visualize Segmentation Result % %% % Read image and display it. I = imread('toyobjects.png'); imshow(I) hold on %% % Segment the image using active contour. First, specify the initial % contour location close to the object that is to be segmented. mask = false(size(I)); mask(50:150,40:170) = true; %% % Display the initial contour on the original image in blue. visboundaries(mask,'Color','b'); %% % Segment the image using the |'edge'| method using 200 iterations. bw = activecontour(I, mask, 200, 'edge'); %% % Display the final contour on the original image in red. visboundaries(bw,'Color','r'); title('Blue - Initial Contour, Red - Final Contour');