function out = maxfilt(in,repeat)
% MAXFILT
% out = maxfilt(in);
% returns maximum value in a 3 x 3 neighborhood
%
% out = maxfilt(in,n) repeats the operation n times
%
% Author: John S. Loomis (17 March 2000)
if nargin<2
repeat=1;
end
sp = size(in);
sm = sp-1;
out = in;
for k=1:repeat
out(1:sm(1),:) = max(out(1:sm(1),:),out(2:sp(1),:));
out(2:sp(1),:) = max(out(1:sm(1),:),out(2:sp(1),:));
out(:,1:sm(2)) = max(out(:,1:sm(2)),out(:,2:sp(2)));
out(:,2:sp(2)) = max(out(:,1:sm(2)),out(:,2:sp(2)));
end
Maintained by John
Loomis, last updated 17 March 2000