function [lvl T] = prah_iteracni(obr);

% 
% obr=obr*1/max(max(obr));
% obr=obrxcc;

T2=obr(ceil(end/2),ceil(end/2));
% T2 = mean(mean(obr))*1.3;
T=4;


while abs(T-T2)>0.0005
    T = T2;
    G1 = obr(obr>T);
    G2 = obr(obr<=T);
    m1 = mean(G1);
    m2 = mean(G2);
    T2 = (m1 + m2)/2;
end


lvl=T2;


