, bwboundaries.
1: . 2: . 3: . 4: . 5: . 1: . pills_etc.png. RGB=imread('pillsetc.png');imshow(RGB); 2: . bwboundaries, . I=rgb2gray(RGB);threshold=graythresh(I);bw=im2bw(I, threshold);imshow(bw) 3: . , , .. . % , 30 bw=bwareaopen(bw,30);% se=strel('disk', 2);bw=imclose(bw, se);bw=imfill(bw,'holes');imshow(bw) 4: . . 'noholes' bwboundaries . [B, L]=bwboundaries(bw, 'noholes');% imshow(label2rgb(L, @jet, [.5.5.5]))hold onfor k=1:length(B) boundary=B{k}; plot(boundary(:, 2), boundary(:, 1), 'w', 'LineWidth', 2)end