function [souradnice pocet] = krizeni(obr_skelet)

%% detekovana krizeni
a = [0 1 0;1 1 1;0 0 0];
% b = [0 1 0;1 1 1;0 1 0];
c = [1 0 0;0 1 0;1 0 1];
d = [1 0 1;0 1 0;0 0 1];
e = [0 0 0;1 1 1;0 1 0];
f = [0 0 1;0 1 0;1 0 1];
% g = [1 0 1;0 1 0;1 0 1];
h = [1 0 1;0 1 0;1 0 0];
ch= [1 0 1;0 1 0;0 1 0];
n = [1 0 0;0 1 1;0 1 0];
k = [0 0 1;1 1 0;0 1 0];
l = [1 0 0;0 1 1;1 0 0];
m = [0 1 0;0 1 1;1 0 0];
o = [0 1 0;0 1 0;1 0 1];
p = [0 0 1;1 1 0;0 0 1];
q = [0 1 0;1 1 0;0 0 1];
r = [0 1 0;0 1 1;0 1 0];
s = [0 1 0;1 1 0;0 1 0];

%% hledani souhlasu ve vyskytu jedne z masek v obraze
vel = size(obr_skelet);         % promenna vel ma dve hodnoty: pocet radku a sloupcu matice obr_skelet
souradnice = zeros(2,300);      % vytvoreni matice
pocet = 0;
matice = zeros(3,3);

for i = 2:1: vel(1)-1           % od dvou pro napasovani masky i na prvni hodnotu
    for j = 2:1: vel(2)-1
        matice = obr_skelet(i-1:i+1,j-1:j+1);
        if obr_skelet(i,j)==1
            % hledani souhlasu s maskami
           if floor(sum(sum(matice == a))/9)... %|| floor(sum(sum(matice == b))/9)
                   || floor(sum(sum(matice == c))/9)||floor(sum(sum(matice == d))/9)...
                   || floor(sum(sum(matice == e))/9) || floor(sum(sum(matice == f))/9)... %    floor(sum(sum(matice == g))/9) 
                   || floor(sum(sum(matice == h))/9) || floor(sum(sum(matice == ch))/9)||...
                   floor(sum(sum(matice == n))/9) || floor(sum(sum(matice == k))/9)|| floor(sum(sum(matice == l))/9) ||...
                   floor(sum(sum(matice == m))/9)|| floor(sum(sum(matice == o))/9)|| floor(sum(sum(matice == p))/9) ||...
                   floor(sum(sum(matice == q))/9) || floor(sum(sum(matice == r))/9) || floor(sum(sum(matice == s))/9)
                              
                   pocet = pocet + 1;               % pocet nalezenych shod
                   souradnice(:,pocet) = [i,j];     % souradnice nalezene shody
            end
        end
    end
end

%% vymazani druhe souradnice z paru pri jejich nahrazeni
[x,y] = find(souradnice==0);
while y > 0
    y = y(1:2:end);
    souradnice(:,y(1))=[];
    [x,y] = find(souradnice==0);
end
