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} {} image (@var{x}, @var{zoom}) |
|
22 ## Display a matrix as a color image. The elements of @var{x} are indices |
|
23 ## into the current colormap and should have values between 1 and the |
|
24 ## length of the colormap. If @var{zoom} is omitted, a value of 4 is |
3426
|
25 ## assumed. |
3373
|
26 ## @end deftypefn |
3457
|
27 ## @seealso{imshow, imagesc, and colormap} |
559
|
28 |
3202
|
29 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312
|
30 ## Created: July 1994 |
|
31 ## Adapted-By: jwe |
904
|
32 |
2312
|
33 function image (x, zoom) |
559
|
34 |
|
35 if (nargin == 0) |
2303
|
36 ## Load Bobbie Jo Richardson (Born 3/16/94) |
1024
|
37 x = loadimage ("default.img"); |
559
|
38 zoom = 2; |
1024
|
39 elseif (nargin == 1) |
559
|
40 zoom = 4; |
1024
|
41 elseif (nargin > 2) |
904
|
42 usage ("image (matrix, [zoom])"); |
559
|
43 endif |
|
44 |
2458
|
45 ppm_name = tmpnam (); |
559
|
46 |
1024
|
47 saveimage (ppm_name, x, "ppm"); |
559
|
48 |
2303
|
49 ## Start the viewer. Try xv, then xloadimage. |
559
|
50 |
1024
|
51 xv = sprintf ("xv -expand %f %s", zoom, ppm_name); |
2458
|
52 |
1024
|
53 xloadimage = sprintf ("xloadimage -zoom %f %s", zoom*100, ppm_name); |
2458
|
54 |
1024
|
55 rm = sprintf ("rm -f %s", ppm_name); |
559
|
56 |
2458
|
57 ## Need to let the shell clean up the tmp file because we are putting |
|
58 ## the viewer in the background. |
|
59 |
|
60 command = sprintf ("( %s || %s && %s ) > /dev/null 2>&1 &", |
3426
|
61 xv, xloadimage, rm); |
559
|
62 |
1024
|
63 system (command); |
559
|
64 |
|
65 endfunction |