changeset 11080:36ceff79607b

image.m: Allow x/ydata to imply a flip of the image. Modify demos.
author Ben Abbott <bpabbott@mac.com>
date Wed, 06 Oct 2010 18:13:11 -0400
parents dc4f8dfe5325
children f9284142a060
files scripts/ChangeLog scripts/image/image.m
diffstat 2 files changed, 38 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Tue Oct 05 14:43:15 2010 -0400
+++ b/scripts/ChangeLog	Wed Oct 06 18:13:11 2010 -0400
@@ -1,3 +1,8 @@
+2010-10-06  Ben Abbott <bpabbott@mac.com>
+
+	* image/image.m: Allow x/ydata to imply a flip of the image.
+	Modify demos.
+
 2010-10-05  Carlo de Falco  <kingcrimson@tiscali.it>
 
 	* general/quadv.m: Fix help string and add a test for vector
--- a/scripts/image/image.m	Tue Oct 05 14:43:15 2010 -0400
+++ b/scripts/image/image.m	Wed Oct 06 18:13:11 2010 -0400
@@ -119,6 +119,19 @@
   xdata = [x(1), x(end)];
   ydata = [y(1), y(end)];
 
+  if (diff (xdata) < 0)
+    xdata = fliplr (xdata);
+    img = fliplr (img);
+  elseif (diff (xdata) == 0)
+    xdata = xdata(1) + [0, size(img,2)-1];
+  endif
+  if (diff (ydata) < 0)
+    ydata = fliplr (ydata);
+    img = flipud (img);
+  elseif (diff (ydata) == 0)
+    ydata = ydata(1) + [0, size(img,1)-1];
+  endif
+
   ca = gca ();
 
   tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata,
@@ -157,17 +170,26 @@
 endfunction
 
 %!demo
-%! img = 1 ./ hilb (10);
-%! x = 20 * rand (1, 41) - 20;
-%! y = -1:1;
-%! h = image (x, y, img);
+%! img = 1 ./ hilb (11);
+%! x = -5:5;
+%! y = x;
+%! subplot (2,2,1)
+%! h = image (abs(x), abs(y), img);
+%! set (h, "cdatamapping", "scaled")
+%! ylabel ("limits = [4.5, 15.5]")
+%! title ('image (abs(x), abs(y), img)')
+%! subplot (2,2,2)
+%! h = image (-x, y, img);
 %! set (h, "cdatamapping", "scaled")
+%! title ('image (-x, y, img)')
+%! subplot (2,2,3)
+%! h = image (x, -y, img);
+%! set (h, "cdatamapping", "scaled")
+%! title ('image (x, -y, img)')
+%! ylabel ("limits = [-5.5, 5.5]")
+%! subplot (2,2,4)
+%! h = image (-x, -y, img);
+%! set (h, "cdatamapping", "scaled")
+%! title ('image (-x, -y, img)')
 
-%!demo
-%! M = 25;
-%! img = 1 ./ rand (5, 11) - 1;
-%! x = 10 * sort (rand (1, 9));
-%! y = sort (rand (1, 8));
-%! clf
-%! image (x, y, img);