function sourad = globalni(obr)

obr_gr = obr;

op_kirch = [3 3 -5;3 0 -5;3 3 -5];

obr_kirch = abs(conv2(obr,op_kirch,'same')) + abs(conv2(obr,op_kirch','same'));

figure(8)
imshow(obr_kirch,[])
obr_kirch=obr_kirch*1/max(max(obr_kirch));
figure(9)
imhist(obr_kirch)
hold on
lvl = 0.9*graythresh(obr_kirch);
plot([lvl lvl],[0 3000],'Color','red')
hold off
obr_p = im2bw(obr_kirch, lvl);

figure(15)
imshow(obr_p)

obr_p = bwmorph(obr_p,'clean');
obr_p = bwmorph(obr_p,'bridge',12);
obr_p = bwmorph(obr_p,'clean');
obr_p = bwmorph(obr_p,'dilate',3);

figure(10)
imshow(obr_p)
obr_gr=obr_gr*1/max(max(obr_gr));
obr = obr_gr.*obr_p;
figure(11)
imshow(obr,[])
figure(12)
imhist(obr)
his = imhist(obr);
hold on
lvl = find(his==max(his(5:end)))/256;
plot([lvl lvl],[0 6000],'Color','red')
hold off
obr_p = im2bw(obr, lvl);
figure(13)
imshow(obr_p,[])
obr_p = bwmorph(obr_p,'bridge',12);
obr_p = bwmorph(obr_p,'clean');
obr_p = bwmorph(obr_p,'dilate',3);
        obr_p = bwmorph(obr_p,'thin',40);

%         obr_p = bwmorph(obr_p,'spur',4);
        obr_p = bwmorph(obr_p,'clean');
figure(14)
imshow(obr_p,[])

[sourad count] = krizeni3(obr_p);

pause