2303
|
1 ### Copyright (C) 1996 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. |
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 |
2311
|
30 function image (x, zoom) |
904
|
31 |
2303
|
32 ## Written by Tony Richardson (amr@mpl.ucsd.edu) July 1994. |
559
|
33 |
|
34 if (nargin == 0) |
2303
|
35 ## Load Bobbie Jo Richardson (Born 3/16/94) |
1024
|
36 x = loadimage ("default.img"); |
559
|
37 zoom = 2; |
1024
|
38 elseif (nargin == 1) |
559
|
39 zoom = 4; |
1024
|
40 elseif (nargin > 2) |
904
|
41 usage ("image (matrix, [zoom])"); |
559
|
42 endif |
|
43 |
2303
|
44 ## XXX FIXME XXX -- we should use octave_tmp_file_name. |
1024
|
45 |
|
46 rnd_str = num2str (fix (rand * 10000)); |
559
|
47 ppm_name = ["image.", rnd_str, ".ppm" ]; |
|
48 |
1024
|
49 saveimage (ppm_name, x, "ppm"); |
559
|
50 |
2303
|
51 ## Start the viewer. Try xv, then xloadimage. |
559
|
52 |
1024
|
53 xv = sprintf ("xv -expand %f %s", zoom, ppm_name); |
|
54 xloadimage = sprintf ("xloadimage -zoom %f %s", zoom*100, ppm_name); |
|
55 rm = sprintf ("rm -f %s", ppm_name); |
559
|
56 |
1024
|
57 command = sprintf ("( %s || %s && %s ) > /dev/null 2>&1 &", ... |
|
58 xv, xloadimage, rm); |
559
|
59 |
1024
|
60 system (command); |
559
|
61 |
|
62 endfunction |