2303
|
1 ### Copyright (C) 1996 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 |
|
7 ### the Free Software Foundation; either version 2, or (at your option) |
|
8 ### any later version. |
|
9 ### |
|
10 ### Octave is distributed in the hope that it will be useful, but |
|
11 ### WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ### General Public License 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, 59 Temple Place - Suite 330, Boston, MA |
|
18 ### 02111-1307, USA. |
1024
|
19 |
2311
|
20 ## Scale and display a matrix as an image. |
|
21 ## |
|
22 ## imagesc(x) displays a scaled version of the matrix x. The matrix is |
|
23 ## scaled so that its entries are indices into the current colormap. |
|
24 ## The scaled matrix is returned. |
|
25 ## |
|
26 ## imagesc (x, zoom) sets the magnification, the default value is 4. |
|
27 ## |
|
28 ## SEE ALSO: image, imshow |
559
|
29 |
2311
|
30 function x = imagesc (x, zoom) |
904
|
31 |
2303
|
32 ## Written by Tony Richardson (amr@mpl.ucsd.edu) July 1994. |
559
|
33 |
|
34 if (nargin < 1 || nargin > 2) |
904
|
35 usage ("image (matrix, [zoom])"); |
1024
|
36 elseif (nargin == 1) |
559
|
37 zoom = 4; |
|
38 endif |
|
39 |
1024
|
40 [ high, wide ] = size (x); |
559
|
41 |
1024
|
42 maxval = max (max (x)); |
|
43 minval = min (min (x)); |
559
|
44 |
2303
|
45 ## Rescale matrix so that all values are in the range 0 to |
|
46 ## length (colormap) inclusive. |
1024
|
47 |
559
|
48 if (maxval == minval) |
1024
|
49 x = ones (high, wide); |
559
|
50 else |
2303
|
51 ## Rescale values to between 1 and length (colormap) inclusive. |
1024
|
52 x = fix ((x - minval) / (maxval - minval) * (length (colormap) - 1)) + 1; |
559
|
53 endif |
|
54 |
1024
|
55 image (x, zoom); |
559
|
56 |
|
57 endfunction |