comparison scripts/image/imagesc.m @ 1024:56520a75b5b3

[project @ 1995-01-11 20:30:04 by jwe]
author jwe
date Wed, 11 Jan 1995 20:30:04 +0000
parents 3470f1e25a79
children 611d403c7f3d
comparison
equal deleted inserted replaced
1023:914348f891f0 1024:56520a75b5b3
1 function x = imagesc(x, zoom) 1 # Copyright (C) 1995 John W. Eaton
2 #
3 # This file is part of Octave.
4 #
5 # Octave is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
9 #
10 # Octave is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Octave; see the file COPYING. If not, write to the Free
17 # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 function x = imagesc (x, zoom)
2 20
3 # Scale and display a matrix as an image. 21 # Scale and display a matrix as an image.
4 # 22 #
5 # imagesc(x) displays a scaled version of the matrix x. The matrix is 23 # imagesc(x) displays a scaled version of the matrix x. The matrix is
6 # scaled so that its entries are indices into the current colormap. 24 # scaled so that its entries are indices into the current colormap.
7 # The scaled matrix is returned. 25 # The scaled matrix is returned.
8 # 26 #
9 # imagesc(x,zoom) sets the magnification, the default value is 4. 27 # imagesc (x, zoom) sets the magnification, the default value is 4.
10 # 28 #
11 # SEE ALSO: image, imshow 29 # SEE ALSO: image, imshow
12 30
13 # Author: 31 # Written by Tony Richardson (amr@mpl.ucsd.edu) July 1994.
14 # Tony Richardson
15 # amr@mpl.ucsd.edu
16 # July 1994
17 32
18 if (nargin < 1 || nargin > 2) 33 if (nargin < 1 || nargin > 2)
19 usage ("image (matrix, [zoom])"); 34 usage ("image (matrix, [zoom])");
20 endif 35 elseif (nargin == 1)
21
22 if (nargin == 1)
23 zoom = 4; 36 zoom = 4;
24 endif 37 endif
25 38
26 [ high, wide ] = size(x); 39 [ high, wide ] = size (x);
27 40
28 maxval = max(max(x)); 41 maxval = max (max (x));
29 minval = min(min(x)); 42 minval = min (min (x));
30 43
31 # Rescale matrix so that all values are in the range 0 to 44 # Rescale matrix so that all values are in the range 0 to
32 # length(colormap) inclusive 45 # length (colormap) inclusive.
46
33 if (maxval == minval) 47 if (maxval == minval)
34 x = ones(high, wide); 48 x = ones (high, wide);
35 else 49 else
36 # Rescale values to between 1 and length(colormap) inclusive. 50 # Rescale values to between 1 and length (colormap) inclusive.
37 x = fix((x - minval)/(maxval - minval) * (length(colormap)-1)) + 1; 51 x = fix ((x - minval) / (maxval - minval) * (length (colormap) - 1)) + 1;
38 endif 52 endif
39 53
40 image(x,zoom); 54 image (x, zoom);
41 55
42 endfunction 56 endfunction