0
|
1 ## Copyright (C) 1996, 1997 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. |
|
19 |
|
20 ## -*- texinfo -*- |
|
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 |
|
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 |
|
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. |
|
30 ## @end deftypefn |
|
31 ## @seealso{image and imshow} |
|
32 |
|
33 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
|
34 ## Created: July 1994 |
|
35 ## Adapted-By: jwe |
|
36 |
|
37 function ret = imagesc (x, y, A, zoom) |
|
38 |
|
39 if (nargin < 1 || nargin > 4) |
|
40 usage ("imagesc (matrix, zoom) or imagesc (x, y, matrix, zoom)"); |
|
41 elseif (nargin == 1) |
|
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 = []; |
|
51 endif |
|
52 |
|
53 ## Rescale values to between 1 and length (colormap) inclusive. |
|
54 maxval = max (A (:)); |
|
55 minval = min (A (:)); |
|
56 if (maxval == minval) |
|
57 B = ones ( size (A) ); |
|
58 else |
|
59 B = round ((A - minval) / (maxval - minval) * (rows (colormap) - 1)) + 1; |
|
60 endif |
|
61 |
|
62 if ( nargout > 0 ) |
|
63 ret = B; |
|
64 else |
|
65 image (x, y, B, zoom); |
|
66 endif |
|
67 |
|
68 endfunction |