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