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 global IMAGEDIR |
|
24 |
|
25 if (nargin == 0) |
|
26 # Load Bobbie Jo Richardson (Born 3/16/94) |
|
27 x = loadimage([IMAGEDIR,"/default.img"]); |
|
28 zoom = 2; |
|
29 elseif(nargin == 1) |
|
30 zoom = 4; |
|
31 elseif(nargin > 2) |
|
32 error("usage: image (matrix, [zoom])"); |
|
33 endif |
|
34 |
|
35 # Generate random file name |
|
36 rnd_str = num2str(fix(rand*10000)); |
|
37 ppm_name = ["image.", rnd_str, ".ppm" ]; |
|
38 |
|
39 saveimage(ppm_name,x,"ppm"); |
|
40 |
|
41 # Start the viewer |
|
42 # Try xv, then xloadimage. |
|
43 |
|
44 xv = sprintf("xv -expand %f %s",zoom,ppm_name); |
|
45 xloadimage = sprintf("xloadimage -zoom %f %s",zoom*100, ppm_name); |
|
46 rm = sprintf("rm -f %s",ppm_name); |
|
47 |
|
48 command = sprintf("( %s || %s && %s ) > /dev/null 2>&1 &", ... |
|
49 xv, xloadimage, rm); |
|
50 |
|
51 shell_cmd(command); |
|
52 |
|
53 endfunction |