
im = imread('test.jpg');
im = rgb2gray(im);

im = double(im)/256 ;
% im = medfilt2(im,[3 3]); %Median filtering the image to remove noise%
BW = edge(im, 'sobel', 0.05); %finding edges using sobel algorithm
% BW = bwareaopen(BW,20);
[r,c]=size(BW);
msk=[0 0 0 0 0;
     0 1 1 1 0;
     0 1 1 1 0;
     0 1 1 1 0;
     0 0 0 0 0;];
% BW = conv2(double(BW),double(msk)); %Smoothing  image to reduce the number of connected components

figure,imshow(BW)



