Mercurial > hg > octave-nkf
comparison scripts/image/image.m @ 1024:56520a75b5b3
[project @ 1995-01-11 20:30:04 by jwe]
author | jwe |
---|---|
date | Wed, 11 Jan 1995 20:30:04 +0000 |
parents | 3470f1e25a79 |
children | 611d403c7f3d |
comparison
equal
deleted
inserted
replaced
1023:914348f891f0 | 1024:56520a75b5b3 |
---|---|
1 function image(x, zoom) | 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) | |
2 | 20 |
3 # Display an octave image matrix. | 21 # Display an octave image matrix. |
4 # | 22 # |
5 # image(x) displays a matrix as a color image. The elements of x are indices | 23 # image (x) displays a matrix as a color image. The elements of x are |
6 # into the current colormap and should have values between 1 and the length | 24 # indices into the current colormap and should have values between 1 |
7 # of the colormap. | 25 # and the length of the colormap. |
8 # | 26 # |
9 # image(x,zoom) changes the zoom factor. The default value is 4. | 27 # image (x, zoom) changes the zoom factor. The default value is 4. |
10 # | 28 # |
11 # SEE ALSO: imshow, imagesc, colormap. | 29 # SEE ALSO: imshow, imagesc, colormap. |
12 | 30 |
13 # Author: | 31 # Written by Tony Richardson (amr@mpl.ucsd.edu) July 1994. |
14 # Tony Richardson | |
15 # amr@mpl.ucsd.edu | |
16 # July 1994 | |
17 | 32 |
18 if (nargin == 0) | 33 if (nargin == 0) |
19 # Load Bobbie Jo Richardson (Born 3/16/94) | 34 # Load Bobbie Jo Richardson (Born 3/16/94) |
20 x = loadimage("default.img"); | 35 x = loadimage ("default.img"); |
21 zoom = 2; | 36 zoom = 2; |
22 elseif(nargin == 1) | 37 elseif (nargin == 1) |
23 zoom = 4; | 38 zoom = 4; |
24 elseif(nargin > 2) | 39 elseif (nargin > 2) |
25 usage ("image (matrix, [zoom])"); | 40 usage ("image (matrix, [zoom])"); |
26 endif | 41 endif |
27 | 42 |
28 # Generate random file name | 43 # XXX FIXME XXX -- we should use octave_tmp_file_name. |
29 rnd_str = num2str(fix(rand*10000)); | 44 |
45 rnd_str = num2str (fix (rand * 10000)); | |
30 ppm_name = ["image.", rnd_str, ".ppm" ]; | 46 ppm_name = ["image.", rnd_str, ".ppm" ]; |
31 | 47 |
32 saveimage(ppm_name,x,"ppm"); | 48 saveimage (ppm_name, x, "ppm"); |
33 | 49 |
34 # Start the viewer | 50 # Start the viewer. Try xv, then xloadimage. |
35 # Try xv, then xloadimage. | |
36 | 51 |
37 xv = sprintf("xv -expand %f %s",zoom,ppm_name); | 52 xv = sprintf ("xv -expand %f %s", zoom, ppm_name); |
38 xloadimage = sprintf("xloadimage -zoom %f %s",zoom*100, ppm_name); | 53 xloadimage = sprintf ("xloadimage -zoom %f %s", zoom*100, ppm_name); |
39 rm = sprintf("rm -f %s",ppm_name); | 54 rm = sprintf ("rm -f %s", ppm_name); |
40 | 55 |
41 command = sprintf("( %s || %s && %s ) > /dev/null 2>&1 &", ... | 56 command = sprintf ("( %s || %s && %s ) > /dev/null 2>&1 &", ... |
42 xv, xloadimage, rm); | 57 xv, xloadimage, rm); |
43 | 58 |
44 shell_cmd(command); | 59 system (command); |
45 | 60 |
46 endfunction | 61 endfunction |