annotate core/tools/uimagesc.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function h = uimagesc(varargin)
wolffd@0 2 %UIMAGESC Display scaled image with uneven axis.
wolffd@0 3 % UIMAGESC(...) is the same as UIMAGE(...) except the data is scaled
wolffd@0 4 % to use the full colormap. See UIMAGE for details.
wolffd@0 5 %
wolffd@0 6 % Note: UIMAGESC is based on Matlab's original IMAGESC, Revision 5.11.4.5.
wolffd@0 7 % UIMAGESC simply calls UIMAGE with a scaled colormap.
wolffd@0 8 %
wolffd@0 9 % F. Moisy - adapted from TMW
wolffd@0 10 % Revision: 1.01, Date: 2006/06/13.
wolffd@0 11 %
wolffd@0 12 % See also IMAGE, IMAGESC, UIMAGE.
wolffd@0 13
wolffd@0 14 % History:
wolffd@0 15 % 2006/06/12: v1.00, first version.
wolffd@0 16
wolffd@0 17 clim = [];
wolffd@0 18 switch (nargin),
wolffd@0 19 case 0,
wolffd@0 20 hh = uimage('CDataMapping','scaled');
wolffd@0 21 case 1,
wolffd@0 22 hh = uimage(varargin{1},'CDataMapping','scaled');
wolffd@0 23 case 3,
wolffd@0 24 hh = uimage(varargin{:},'CDataMapping','scaled');
wolffd@0 25 otherwise,
wolffd@0 26
wolffd@0 27 % Determine if last input is clim
wolffd@0 28 if isequal(size(varargin{end}),[1 2])
wolffd@0 29 str = false(length(varargin),1);
wolffd@0 30 for n=1:length(varargin)
wolffd@0 31 str(n) = ischar(varargin{n});
wolffd@0 32 end
wolffd@0 33 str = find(str);
wolffd@0 34 if isempty(str) || (rem(length(varargin)-min(str),2)==0),
wolffd@0 35 clim = varargin{end};
wolffd@0 36 varargin(end) = []; % Remove last cell
wolffd@0 37 else
wolffd@0 38 clim = [];
wolffd@0 39 end
wolffd@0 40 else
wolffd@0 41 clim = [];
wolffd@0 42 end
wolffd@0 43 hh = uimage(varargin{:},'CDataMapping','scaled');
wolffd@0 44 end
wolffd@0 45
wolffd@0 46 % Get the parent Axes of the image
wolffd@0 47 cax = ancestor(hh,'axes');
wolffd@0 48
wolffd@0 49 if ~isempty(clim),
wolffd@0 50 set(cax,'CLim',clim)
wolffd@0 51 elseif ~ishold(cax),
wolffd@0 52 set(cax,'CLimMode','auto')
wolffd@0 53 end
wolffd@0 54
wolffd@0 55 if nargout > 0
wolffd@0 56 h = hh;
wolffd@0 57 end