function imsharp=sharpen(imw,strength);

% imsharp=SHARPEN(imw,strength);
%
% 		Sharpens the image file IMW
%
%		Strength: Sharpening strength, 0..1
%
%		e.g.: imsharp=sharpen(imw,0.5);
%
%
% University of Rhode Island
% Dept. of Electrical Engineering
% Roger Meier, May '99

if or(strength < 0,strength > 1)
	disp('strength must be within [0..1]')
	break
end

filt=-ones(3,3);
filt(5)=9;
HPF=double(imw);
HPF(:,:,1)=filter2(filt,double(imw(:,:,1)),'same');
HPF(:,:,2)=filter2(filt,double(imw(:,:,2)),'same');
HPF(:,:,3)=filter2(filt,double(imw(:,:,3)),'same');
imsharp = (1-strength)*double(imw) + strength*HPF;
under=imsharp < 0;  % setting all elements < 0 to zero
under=find(under);
imsharp(under)=0;
over=imsharp > 255; % setting all elements > 255 in new blue channel to 255
over=find(over);
imsharp(over)=255;
imsharp=uint8(imsharp);
