% showgimg.m % show a matrix as a grey level image % usage: showgimg(A,numcol,rng,X,Y) % X = image matrix, numcol = # greylevels % rng = range of matrix entries to show, % matrix entries below and above the range are clipped % to black and white respectively % X,Y two element vectors showing the X and Y ranges respectively. function y=showgimg(A,numcol,rng,X,Y) mn = min(min(A)); mx = max(max(A)); Xl = [0.5, 0.5+size(A,2)]; Yl = [0.5, 0.5+size(A,1)]; if (nargin > 2) if (length(rng) > 1) mn = rng(1); mx = rng(2); end; end; if (nargin >3) if length(X) > 1 Xl=X; end; if length(Y) > 1 Yl=Y; end; end; s = numcol-1; colormap(((0:s)/s)'*[1,1,1]); axis('image') img = ((numcol+1)/(mx-mn))*(A-mn*ones(size(A))); image(Xl,Yl,img);