a=imread('3.jpg');
b=rgb2gray(a);
[i,j]=find(b>=200);
e=zeros(size(b));
for n=1:length(i)
e(i(n),j(n))=b(i(n),j(n));
end
imshow(e);
BW2 = bwmorph(e,'remove');
BW3 = bwmorph(e,'skel',Inf);
figure; imshow(BW2);
figure; imshow(BW3);
f=sum(BW3);
imshow(e);
plot(f);
[y,i]=max(f);
g(i)=255;
hold on;
h=plot(g);
set(h,'Color',[1 1 1]);