Paso 7: El código
img1=imread('Lines.jpg');
imshow(img1)
img1=rgb2gray(img1);
imshow(img1)
img2=im2bw(img1,graythresh(img1));
imshow(img2)
img2 = ~ img2;
imshow(img2)
B = bwboundaries(img2);
imshow(img2)
texto (10,10, strcat ('\color {verde} objetos encontrados:', num2str(length(B)))
Espera
para k = 1:length(B)
límite = B {k};
Plot(Boundary(:,2), boundary(:,1), 'g', 'LineWidth', 0.2)
final