function c_m = kontrast_12_2(vstup)
[sx, sy] = size(vstup);
c_m = zeros(sx-4,sy-4);

for x = 1:sx-4
    for y = 1:sy-4
        b = vstup(x:x+4, y:y+4); % matica veľkosti 3x3
        c = b;
        c(b < b(13))=0;
        c(b >= b(13))=1;
        c(13) = 0; % centrálny pixel
        c([1, 5, 7, 8, 9, 12, 14, 17, 18, 19, 21, 25]) = 0;
        c_n = ones(5,5);
        c_n = c_n - c; % negatív
        c_n(13) = 0; % centrálny pixel
        c_n([1, 5, 7, 8, 9, 12, 14, 17, 18, 19, 21, 25]) = 0;
        % priemer hodôt pod pozíciami s 1
        N1 = sum(sum(c));
        if N1 == 0
            c_m(x,y) = 0;
            continue
        end
        % priemer hodôt pod pozíciami s 0
        N2 = sum(sum(c_n));
        if N2 == 0
            c_m(x,y) = 0;
            continue
        end
        C1 = sum(sum(b.*c))/N1;
        C2 = sum(sum(b.*c_n))/N2;
        % Contrast
%         C = abs(C1-C2);
        c_m(x,y) = C1-C2;
    end
end
end