1024
|
1 # Copyright (C) 1995 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 the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # 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, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
18 |
|
19 function image (x, zoom) |
559
|
20 |
904
|
21 # Display an octave image matrix. |
|
22 # |
1024
|
23 # image (x) displays a matrix as a color image. The elements of x are |
|
24 # indices into the current colormap and should have values between 1 |
|
25 # and the length of the colormap. |
559
|
26 # |
1024
|
27 # image (x, zoom) changes the zoom factor. The default value is 4. |
904
|
28 # |
|
29 # SEE ALSO: imshow, imagesc, colormap. |
|
30 |
1024
|
31 # Written by Tony Richardson (amr@mpl.ucsd.edu) July 1994. |
559
|
32 |
|
33 if (nargin == 0) |
1024
|
34 # Load Bobbie Jo Richardson (Born 3/16/94) |
|
35 x = loadimage ("default.img"); |
559
|
36 zoom = 2; |
1024
|
37 elseif (nargin == 1) |
559
|
38 zoom = 4; |
1024
|
39 elseif (nargin > 2) |
904
|
40 usage ("image (matrix, [zoom])"); |
559
|
41 endif |
|
42 |
1024
|
43 # XXX FIXME XXX -- we should use octave_tmp_file_name. |
|
44 |
|
45 rnd_str = num2str (fix (rand * 10000)); |
559
|
46 ppm_name = ["image.", rnd_str, ".ppm" ]; |
|
47 |
1024
|
48 saveimage (ppm_name, x, "ppm"); |
559
|
49 |
1024
|
50 # Start the viewer. Try xv, then xloadimage. |
559
|
51 |
1024
|
52 xv = sprintf ("xv -expand %f %s", zoom, ppm_name); |
|
53 xloadimage = sprintf ("xloadimage -zoom %f %s", zoom*100, ppm_name); |
|
54 rm = sprintf ("rm -f %s", ppm_name); |
559
|
55 |
1024
|
56 command = sprintf ("( %s || %s && %s ) > /dev/null 2>&1 &", ... |
|
57 xv, xloadimage, rm); |
559
|
58 |
1024
|
59 system (command); |
559
|
60 |
|
61 endfunction |