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 -*- |
3651
|
21 ## @deftypefn {Function File} {} imagesc (@var{A}, @var{zoom}) |
|
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 |
3373
|
24 ## matrix is scaled so that its entries are indices into the current |
|
25 ## colormap. The scaled matrix is returned. If @var{zoom} is omitted, a |
3651
|
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. |
3373
|
30 ## @end deftypefn |
3457
|
31 ## @seealso{image and imshow} |
559
|
32 |
3202
|
33 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312
|
34 ## Created: July 1994 |
|
35 ## Adapted-By: jwe |
904
|
36 |
3882
|
37 function ret = imagesc (x, y, A, zoom) |
559
|
38 |
3651
|
39 if (nargin < 1 || nargin > 4) |
|
40 usage ("imagesc (matrix, zoom) or imagesc (x, y, matrix, zoom)"); |
1024
|
41 elseif (nargin == 1) |
3651
|
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 = []; |
559
|
51 endif |
|
52 |
3882
|
53 maxval = max (A(:)); |
|
54 minval = min (A(:)); |
1024
|
55 |
559
|
56 if (maxval == minval) |
3882
|
57 B = ones (size (A)); |
559
|
58 else |
2303
|
59 ## Rescale values to between 1 and length (colormap) inclusive. |
3651
|
60 B = round ((A - minval) / (maxval - minval) * (rows (colormap) - 1)) + 1; |
559
|
61 endif |
|
62 |
3882
|
63 if (nargout == 0) |
|
64 image (x, y, B, zoom); |
|
65 else |
|
66 ret = B; |
|
67 endif |
559
|
68 |
|
69 endfunction |