diff scripts/image/image.m @ 559:4e826edfbc56

[project @ 1994-07-25 22:18:28 by jwe] Initial revision
author jwe
date Mon, 25 Jul 1994 22:19:05 +0000
parents
children 0faebdd7df57
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/image.m	Mon Jul 25 22:19:05 1994 +0000
@@ -0,0 +1,53 @@
+function image(x, zoom)
+#Display an octave image matrix.
+#
+#image(x) displays a matrix as a color image. The elements of x are indices
+#into the current colormap and should have values between 1 and the length
+#of the colormap.
+#
+#image(x,zoom) changes the zoom factor.  The default value is 4.
+#
+#SEE ALSO: imshow, imagesc, colormap.
+
+#Author:
+# Tony Richardson
+# amr@mpl.ucsd.edu
+# July 1994
+#
+#Modified:
+# Tony Richardson
+# amr@mpl.ucsd.edu
+# July 1994
+# (Modifications based on suggestions from John Eaton.)
+
+  global IMAGEDIR
+ 
+  if (nargin == 0)
+    # Load Bobbie Jo Richardson (Born 3/16/94)
+    x = loadimage([IMAGEDIR,"/default.img"]);
+    zoom = 2;
+  elseif(nargin == 1)
+    zoom = 4;
+  elseif(nargin > 2)
+    error("usage: image (matrix, [zoom])");
+  endif
+
+  # Generate random file name
+  rnd_str = num2str(fix(rand*10000));
+  ppm_name = ["image.", rnd_str, ".ppm" ];
+
+  saveimage(ppm_name,x,"ppm");
+
+  # Start the viewer
+  # Try xv, then xloadimage.
+
+  xv = sprintf("xv -expand %f %s",zoom,ppm_name);
+  xloadimage = sprintf("xloadimage -zoom %f %s",zoom*100, ppm_name);
+  rm = sprintf("rm -f %s",ppm_name);
+
+  command = sprintf("( %s || %s && %s ) > /dev/null 2>&1 &", ...
+                    xv, xloadimage, rm);
+
+  shell_cmd(command);
+
+endfunction