img = imread('LinesAndCircles.gif');
%Structuring element 12 pixels in diameter
sel = strel('disk',6,0);
imgn = imopen(img, sel);
imshow(img, []), title('Original Image'), figure, imshow(imgn,[]), title('Segmented Image')
[~, NumofCircles] = bwlabel(imgn,8);
NumofCircles
%img = imread('Circles.gif');
%Structuring element 22 pixels in diameter
%sel = strel('disk',11,0);
%imgn = imclose(img, sel);
%imshow(img, []), title('Image with large and small holes'), figure, imshow(imgn,[]),
%title('Image after filling of small holes');