2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
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 |
3381
|
20 ## -*- texinfo -*- |
3373
|
21 ## @deftypefn {Function File} {} imagesc (@var{x}, @var{zoom}) |
|
22 ## Display a scaled version of the matrix @var{x} as a color image. The |
|
23 ## 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 ## value of 4 is assumed. |
|
26 ## @end deftypefn |
3457
|
27 ## @seealso{image and imshow} |
559
|
28 |
3202
|
29 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312
|
30 ## Created: July 1994 |
|
31 ## Adapted-By: jwe |
904
|
32 |
3225
|
33 function y = imagesc (x, zoom) |
559
|
34 |
|
35 if (nargin < 1 || nargin > 2) |
3225
|
36 usage ("imagesc (matrix, [zoom])"); |
1024
|
37 elseif (nargin == 1) |
559
|
38 zoom = 4; |
|
39 endif |
|
40 |
1024
|
41 [ high, wide ] = size (x); |
559
|
42 |
1024
|
43 maxval = max (max (x)); |
|
44 minval = min (min (x)); |
559
|
45 |
2303
|
46 ## Rescale matrix so that all values are in the range 0 to |
|
47 ## length (colormap) inclusive. |
1024
|
48 |
559
|
49 if (maxval == minval) |
3225
|
50 y = ones (high, wide); |
559
|
51 else |
2303
|
52 ## Rescale values to between 1 and length (colormap) inclusive. |
3225
|
53 y = round ((x - minval) / (maxval - minval) * (rows (colormap) - 1)) + 1; |
559
|
54 endif |
|
55 |
3225
|
56 image (y, zoom); |
559
|
57 |
|
58 endfunction |