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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
1024
|
19 |
3381
|
20 ## -*- texinfo -*- |
3373
|
21 ## @deftypefn {Function File} {} image (@var{x}, @var{zoom}) |
3651
|
22 ## @deftypefnx {Function File} {} image (@var{x}, @var{y}, @var{A}, @var{zoom}) |
3373
|
23 ## Display a matrix as a color image. The elements of @var{x} are indices |
|
24 ## into the current colormap and should have values between 1 and the |
3651
|
25 ## length of the colormap. If @var{zoom} is omitted, the image will be |
|
26 ## scaled to fit within 600x350 (to a max of 4). |
|
27 ## |
6164
|
28 ## It first tries to use @code{gnuplot}, then @code{display} from |
|
29 ## @code{ImageMagick}, then @code{xv}, and then @code{xloadimage}. |
|
30 ## The actual program used can be changed using the @code{image_viewer} |
|
31 ## function. |
3714
|
32 ## |
3651
|
33 ## The axis values corresponding to the matrix elements are specified in |
6164
|
34 ## @var{x} and @var{y}. If you're not using gnuplot 4.2 or later, these |
|
35 ## variables are ignored. |
|
36 ## @seealso{imshow, imagesc, colormap, image_viewer} |
3373
|
37 ## @end deftypefn |
559
|
38 |
3202
|
39 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312
|
40 ## Created: July 1994 |
|
41 ## Adapted-By: jwe |
904
|
42 |
3651
|
43 function image (x, y, A, zoom) |
559
|
44 |
|
45 if (nargin == 0) |
2303
|
46 ## Load Bobbie Jo Richardson (Born 3/16/94) |
3714
|
47 A = loadimage ("default.img"); |
559
|
48 zoom = 2; |
6088
|
49 x = y = []; |
1024
|
50 elseif (nargin == 1) |
3651
|
51 A = x; |
|
52 zoom = []; |
|
53 x = y = []; |
|
54 elseif (nargin == 2) |
|
55 A = x; |
|
56 zoom = y; |
|
57 x = y = []; |
|
58 elseif (nargin == 3) |
|
59 zoom = []; |
|
60 elseif (nargin > 4) |
6164
|
61 usage ("image (matrix, zoom) or image (x, y, matrix, zoom)"); |
559
|
62 endif |
|
63 |
6164
|
64 if (isempty (zoom)) |
|
65 ## Find an integer scale factor which sets the image to |
|
66 ## approximately the size of the screen. |
|
67 zoom = min ([350/rows(A), 600/columns(A), 4]); |
|
68 if (zoom >= 1) |
|
69 zoom = floor (zoom); |
|
70 else |
|
71 zoom = 1 / ceil (1/zoom); |
3651
|
72 endif |
6088
|
73 endif |
559
|
74 |
6164
|
75 ## Get the image viewer. |
|
76 [view_cmd, view_fcn, view_zoom] = image_viewer (); |
|
77 |
|
78 ## Show the image. |
|
79 view_fcn (x, y, A, zoom*view_zoom, view_cmd); |
|
80 |
559
|
81 endfunction |