function t = immed(x,k)
%
[m,n] = size(x);
t = zeros(m,n);
k2 = (k-1)/2;

for i1 = k2+1:m-k2
  for j1 = k2+1:n-k2
    t(i1,j1) = median(median(x(i1-k2:i1+k2,j1-k2:j1+k2)));
  end;
end;
 
