function immed=medfilt(imw,filtersize);

% immed=MEDFILT(imw,filtersize);
%
% 		Median filters the image file IMW
%
%		filtersize: size of quadratic pixel neighborhood
%
%		e.g.: immed=medfilt(imw,3);
%
%
% University of Rhode Island
% Dept. of Electrical Engineering
% Roger Meier, May '99


if filtersize < 2
	disp('filter size too small')
	break
end

immed=ordfilt2(imw,ceil(filtersize^2/2),ones(filtersize,filtersize));
