function img = scaleContrast(img,contrastScale,gray);
% imgOut = scaleContrast(img,contrastScale,[gray])
% scales contrast of image or images
% can do several images at once if img is a cell-of-images
% 'gray' defaults to value of 127; images scaled around this value
% 03/03 by ras
if ~exist('gray','var')	gray = 127;	end
if iscell(img) & isnumeric(img{1})
	for i = 1:length(img)
		img{i} = scaleContrast(img{i},contrastScale,gray);
	end
else
	img = uint8(floor( (double(img) - gray) *contrastScale ) + gray);   % scale the image
end
return
