% 2-d convolution laplacian enhancement filter
clear
x=[1 -1 3 2;
    2 1 2 4;
    1 -1 2 -2;
    3 1 2 2]; % input
% choose one of the border extensions, lines 8 or 9
xe = padarray(x,[1 1],'replicate') % replicated
%xe = padarray(x,[1 1]) % zero-padded
[R C]=size(x)
for r=1:R
  for c=1:C 
    x(r,c)= -xe(r+1,c)-xe(r+1,c+2) +5*xe(r+1,c+1)...
        -xe(r,c+1)-xe(r+2,c+1); 
  end
end
x % output
 

