url = 'http://geo.fsv.cvut.cz/user/gin/git1/matlab/img/';
D = double(imread(strcat(url,'kucharky.tiff')));

[R,C] = size(D);
S = zeros([R,C], 'uint8');    
a = 0.2;
for r=2:R-1        % pro zjednuseni ignorujeme okraje snimku
    for c=2:C-1    % a vstupni rastr ulozime jako tridu double
        x = 0;
        if c >= C/2
            x = 1/(1+a)*( ...
            D(r-1,c-1)*a + D(r-1,c)*(1-a) + D(r-1,c+1)*a + ...
            D(r,c-1)*(1-a) - D(r,c)*4 + D(r,c+1)*(1-a) + ...
            D(r+1,c-1)*a + D(r+1,c)*(1-a) + D(r+1,c+1)*a ...
        );
        end  
        S(r,c) = uint8(D(r,c) - x);
    end
end
S(:,C/2:C/2) = 180;

figure(1), imshow(S);
imwrite(S, 'kucharky-unsharp-m.png', 'png');

