changeset 10817:d9147775da54

image.m: Always reverse 'ydir' property when displaying images.
author Rik <octave@nomad.inbox5.com>
date Sun, 25 Jul 2010 22:27:08 -0700
parents 7fa044155982
children 947adebb1336
files scripts/ChangeLog scripts/image/image.m
diffstat 2 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Fri Jul 23 08:36:31 2010 +0200
+++ b/scripts/ChangeLog	Sun Jul 25 22:27:08 2010 -0700
@@ -1,3 +1,7 @@
+2010-07-25  Rik <octave@nomad.inbox5.com>
+
+	* image/image.m: Always reverse 'ydir' property when displaying images.
+
 2010-07-19  Rik <octave@nomad.inbox5.com>
 
 	* help/__makeinfo__.m: Add support to process @nopsell macro.
--- a/scripts/image/image.m	Fri Jul 23 08:36:31 2010 +0200
+++ b/scripts/image/image.m	Sun Jul 25 22:27:08 2010 -0700
@@ -32,6 +32,15 @@
 ## The axis values corresponding to the matrix elements are specified in
 ## @var{x} and @var{y}.  If you're not using gnuplot 4.2 or later, these
 ## variables are ignored.
+##
+## Implementation Note: The origin (0, 0) for images is located in the 
+## upper left.  For ordinary plots, the origin is located in the lower
+## left.  Octave handles this inversion by plotting the data normally,
+## and then reversing the direction of the y-axis by setting the
+## @code{ydir) property to "reverse".  This has implications whenever
+## an image and an ordinary plot need to be overlaid.  The recommended
+## solution is to display the image and then plot the reversed ydata
+## using, for example, @code{flipud (ydata,1)}.
 ## @seealso{imshow, imagesc, colormap, image_viewer}
 ## @end deftypefn
 
@@ -115,8 +124,7 @@
 
   ca = gca ();
 
-  tmp = __go_image__ (ca, "cdata", flipdim (img, 1), 
-                      "xdata", xdata, "ydata", ydata,
+  tmp = __go_image__ (ca, "cdata", img, "xdata", xdata, "ydata", ydata,
                       "cdatamapping", "direct", varargin {:});
 
   ## FIXME -- how can we do this and also get the {x,y}limmode
@@ -138,6 +146,9 @@
 
   set (ca, "view", [0, 90]);
 
+  # Always reverse y-axis for images, even on existing plots
+  set (ca, "ydir", "reverse");
+
   if (nargout > 0)
     h = tmp;
   endif