function M = display_image(V,m,n,scale) % usage: M = display_image(V,m,n,scale) % M - matrix form of image returned by function % note that returned image will have original values % even if image is scaled for display. % V - lexicographically ordered vector form on image % m - number of rows % n - number of columns % scale [0,1] - scale pixel values for display % 0 - no scaling, image is assumed to be between 0 and 255 % 1 - linear scaling, image is scled between 0 and 255 % error(nargchk(4,4,nargin)); M = reshape(V,m,n); if (scale==1) mx = max(max(M)); mn = min(min(M)); else mx = 255; mn = 0; end nM = 255*(M-mn)/(mx-mn); mp = linspace(0,1,256); mp = [mp' mp' mp']; image(nM); colormap(mp); end