diff scripts/image/imagesc.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 3470f1e25a79
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/imagesc.m	Mon Jul 25 22:19:05 1994 +0000
@@ -0,0 +1,47 @@
+function x = imagesc(x, zoom)
+#Scale and display a matrix as an image.
+#
+#imagesc(x) displays a scaled version of the matrix x.  The matrix is
+#scaled so that its entries are indices into the current colormap.
+#The scaled matrix is returned.
+#
+#imagesc(x,zoom) sets the magnification, the default value is 4.
+#
+#SEE ALSO: image, imshow
+
+#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.)
+
+  if (nargin < 1 || nargin > 2)
+    error("usage: image (matrix, [zoom])");
+  endif
+
+  if (nargin == 1)
+    zoom = 4;
+  endif
+
+  [ high, wide ] = size(x);
+
+  maxval = max(max(x));
+  minval = min(min(x));
+
+  # Rescale matrix so that all values are in the range 0 to
+  # length(colormap) inclusive
+  if (maxval == minval)
+    x = ones(high, wide);
+  else
+    # Rescale values to between 1 and length(colormap) inclusive.
+    x = fix((x - minval)/(maxval - minval) * (length(colormap)-1)) + 1;
+  endif
+
+  image(x,zoom);
+
+endfunction