559
|
1 function image(x, zoom) |
|
2 #Display an octave image matrix. |
|
3 # |
|
4 #image(x) displays a matrix as a color image. The elements of x are indices |
|
5 #into the current colormap and should have values between 1 and the length |
|
6 #of the colormap. |
|
7 # |
|
8 #image(x,zoom) changes the zoom factor. The default value is 4. |
|
9 # |
|
10 #SEE ALSO: imshow, imagesc, colormap. |
|
11 |
|
12 #Author: |
|
13 # Tony Richardson |
|
14 # amr@mpl.ucsd.edu |
|
15 # July 1994 |
|
16 # |
|
17 #Modified: |
|
18 # Tony Richardson |
|
19 # amr@mpl.ucsd.edu |
|
20 # July 1994 |
|
21 # (Modifications based on suggestions from John Eaton.) |
|
22 |
|
23 if (nargin == 0) |
|
24 # Load Bobbie Jo Richardson (Born 3/16/94) |
686
|
25 x = loadimage("default.img"); |
559
|
26 zoom = 2; |
|
27 elseif(nargin == 1) |
|
28 zoom = 4; |
|
29 elseif(nargin > 2) |
|
30 error("usage: image (matrix, [zoom])"); |
|
31 endif |
|
32 |
|
33 # Generate random file name |
|
34 rnd_str = num2str(fix(rand*10000)); |
|
35 ppm_name = ["image.", rnd_str, ".ppm" ]; |
|
36 |
|
37 saveimage(ppm_name,x,"ppm"); |
|
38 |
|
39 # Start the viewer |
|
40 # Try xv, then xloadimage. |
|
41 |
|
42 xv = sprintf("xv -expand %f %s",zoom,ppm_name); |
|
43 xloadimage = sprintf("xloadimage -zoom %f %s",zoom*100, ppm_name); |
|
44 rm = sprintf("rm -f %s",ppm_name); |
|
45 |
|
46 command = sprintf("( %s || %s && %s ) > /dev/null 2>&1 &", ... |
|
47 xv, xloadimage, rm); |
|
48 |
|
49 shell_cmd(command); |
|
50 |
|
51 endfunction |