comparison scripts/image/imagesc.m @ 3651:c2305b99fbd7

[project @ 2000-03-31 07:12:29 by jwe]
author jwe
date Fri, 31 Mar 2000 07:12:30 +0000
parents e031284eea27
children c8c1ead8474f
comparison
equal deleted inserted replaced
3650:b3a57a1369f8 3651:c2305b99fbd7
16 ## along with Octave; see the file COPYING. If not, write to the Free 16 ## along with Octave; see the file COPYING. If not, write to the Free
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
18 ## 02111-1307, USA. 18 ## 02111-1307, USA.
19 19
20 ## -*- texinfo -*- 20 ## -*- texinfo -*-
21 ## @deftypefn {Function File} {} imagesc (@var{x}, @var{zoom}) 21 ## @deftypefn {Function File} {} imagesc (@var{A}, @var{zoom})
22 ## Display a scaled version of the matrix @var{x} as a color image. The 22 ## @deftypefnx {Function File} {} imagesc (@var{x}, @var{y}, @var{A}, @var{zoom})
23 ## Display a scaled version of the matrix @var{A} as a color image. The
23 ## matrix is scaled so that its entries are indices into the current 24 ## matrix is scaled so that its entries are indices into the current
24 ## colormap. The scaled matrix is returned. If @var{zoom} is omitted, a 25 ## colormap. The scaled matrix is returned. If @var{zoom} is omitted, a
25 ## value of 4 is assumed. 26 ## comfortable size is chosen.
27 ##
28 ## The axis values corresponding to the matrix elements are specified in
29 ## @var{x} and @var{y}. At present they are ignored.
26 ## @end deftypefn 30 ## @end deftypefn
27 ## @seealso{image and imshow} 31 ## @seealso{image and imshow}
28 32
29 ## Author: Tony Richardson <arichard@stark.cc.oh.us> 33 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
30 ## Created: July 1994 34 ## Created: July 1994
31 ## Adapted-By: jwe 35 ## Adapted-By: jwe
32 36
33 function y = imagesc (x, zoom) 37 function B = imagesc (x, y, A, zoom)
34 38
35 if (nargin < 1 || nargin > 2) 39 if (nargin < 1 || nargin > 4)
36 usage ("imagesc (matrix, [zoom])"); 40 usage ("imagesc (matrix, zoom) or imagesc (x, y, matrix, zoom)");
37 elseif (nargin == 1) 41 elseif (nargin == 1)
38 zoom = 4; 42 A = x;
43 zoom = [];
44 x = y = [];
45 elseif (nargin == 2)
46 A = x;
47 zoom = y;
48 x = y = [];
49 elseif (nargin == 3)
50 zoom = [];
39 endif 51 endif
40 52
41 [ high, wide ] = size (x); 53 [high, wide] = size (A);
42 54
43 maxval = max (max (x)); 55 maxval = max (max (A));
44 minval = min (min (x)); 56 minval = min (min (A));
45 57
46 ## Rescale matrix so that all values are in the range 0 to 58 ## Rescale matrix so that all values are in the range 0 to
47 ## length (colormap) inclusive. 59 ## length (colormap) inclusive.
48 60
49 if (maxval == minval) 61 if (maxval == minval)
50 y = ones (high, wide); 62 B = ones (high, wide);
51 else 63 else
52 ## Rescale values to between 1 and length (colormap) inclusive. 64 ## Rescale values to between 1 and length (colormap) inclusive.
53 y = round ((x - minval) / (maxval - minval) * (rows (colormap) - 1)) + 1; 65 B = round ((A - minval) / (maxval - minval) * (rows (colormap) - 1)) + 1;
54 endif 66 endif
55 67
56 image (y, zoom); 68 image (x, y, B, zoom);
57 69
58 endfunction 70 endfunction