clear all, clc;

img = imread('q.jpg');
im = rgb2gray(img);
img = im2bw(im, graythresh(im));

% g = imcomplement(im);

%% watershed
imgLabel = watershed(im);    
bgm = imgLabel == 0;
figure, imshow(bgm,'InitialMagnification','fit')
im(bgm) = 0;
figure, imshow(im);

colorimg = bwlabel(im);
figure,imshow(label2rgb(colorimg,'jet','k','shuffle'));











