function y = simage(u,levels)
%SIMAGE displays scaled image.
%	Y = SIMAGE(U) scales the the image contained in the matrix U
%	so that when displayed it takes advantage the full dynamic range
%	of the IMAGE function.  In other words, the components of Y 
%	lie between 0.5 and 64.5.

% Courtesy of Kenneth R. Crounse, crounse@fred.EECS.Berkeley.EDU.
% One can use Matlab's imagesc(...) to achieve similar purpose as well.

if (nargin == 1)
	levels = 64;
end;

mini = min(min(u));
maxi = max(max(u));
y = (levels*u + 0.5*maxi - (levels+0.5)*mini)/(maxi-mini); 
