% imDisplay.m % ----------- % % function im=imDisplay(pic,cb) % % % AUTHOR: P. Belhumeur and A.S. Georghiades % DATE: September 25, 1996 % PURPOSE: % Display an image defined in matrix pic. The image undergoes % contrast enhancement and gray-256 colormap is used to display it. % % ARGUMENTS: % pic: Matrix of size (n x m) to be displayed. % cb: If it equals to 1 them a colorbar is also drawn. % The default value is 1. % % RETURNS: % im: Image handle. % % (No dependancies) % function im=imDisplay(pic, cb) %% If 'cb' is not defined then set to 1. % if (nargin<2), cb=1; end %% Create colormap and do contrast enhancement. % mn=min(min(pic)); mx=max(max(pic)); maxc=mx; minc=mn; if ((mn~=0) | (mx~=0)), pic=round((255*(pic-mn))/(mx-mn)); end cmap=gray(256); %% Display image. % im=image(pic); %% Set color limits for colomap. % set(im,'UserData',[minc,maxc]); %% Set axis and grid. % axis('image'); grid on; %% Remove tics from x- and y-axes. % set(gca,'XtickLabels',[],'YtickLabels',[]); %% Modify colormap. % colormap(cmap); %% Put colorbar. % if (cb), cb=colorbar; end %%%%