function c_m = kontrast_8_1(vstup)
    [sx, sy] = size(vstup);
    c_m = zeros(sx-2,sy-2);
    
    for x = 1:sx-2
        for y = 1:sy-2
            b = vstup(x:x+2, y:y+2); % matica veľkosti 3x3
            c = b;
            c(b < b(5))=0;
            c(b >= b(5))=1;
            c(2,2) = 0; % centrálny pixel
            c_n = ones(3,3);
            c_n = c_n - c; % negatív
            c_n(2,2) = 0; % centrálny pixel
            % priemer hodôt pod pozíciami s 1
            N1 = sum(sum(c));
            if N1 == 0
%                N1 = 1; 
                c_m(x,y) = 0;
                continue
            end
            C1 = sum(sum(b.*c))/N1;
            % priemer hodôt pod pozíciami s 0
            N2 = sum(sum(c_n));
            if N2 == 0
%                 N2 = 1;
                c_m(x,y) = 0;
                continue
            end
            C2 = sum(sum(b.*c_n))/N2;
            % Contrast
%             C = abs(C1-C2);
            c_m(x,y) = C1-C2;
        end
    end
end