%11. Boundary tracking (bwtraceboundary function) CLC; Clear I=imread (' e:\role0\003i.bmp '); figure;imshow (i); title (' Original image '); I1=rgb2gray (i) ; % Convert color image to grayscale image Threshold=graythresh (I1); % calculates the threshold BW=IM2BW (I1, threshold) required to convert a grayscale image to a two-value image; % convert grayscale image to two value image Figure imshow (BW); title (' Binary image ');d im=size (BW); Col=round (Dim (2)/2) -90; % calculates the starting point column coordinates row=find (BW (:, col), 1); % calculates the starting point line coordinate connectivity=8; Num_points=180;contour=bwtraceboundary (Bw,[row,col], ' N ', connectivity,num_points); % extraction Boundary Figure imshow (I1); hold On;plot (Contour (:, 2), Contour (:, 1), ' G ', ' linewidth ', 2); title (' Boundary tracking image ');
Boundary Tracking (bwtraceboundary function). m