changeset 7930:1f6eb3de1c4e

__img__.m, imshow.m, __go_draw_axes__.m: improve handling of truecolor images
author John W. Eaton <jwe@octave.org>
date Wed, 16 Jul 2008 11:24:48 -0400
parents 30b952e90c29
children de26beacb20f
files scripts/ChangeLog scripts/image/__img__.m scripts/image/imshow.m scripts/plot/__go_draw_axes__.m
diffstat 4 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Tue Jul 15 13:34:22 2008 -0400
+++ b/scripts/ChangeLog	Wed Jul 16 11:24:48 2008 -0400
@@ -1,3 +1,11 @@
+2008-07-16  John W. Eaton  <jwe@octave.org>
+
+	* image/__img__.m: Set clim for true-color integer data.
+
+	* image/imshow.m: Don't convert integer true-color data to double.
+
+	* plot/__go_draw_axes__.m: Recognize 3-d cdata as a true-color image.
+
 2008-07-14  John W. Eaton  <jwe@octave.org>
 
 	* image/Makefile.in (SOURCES): Add imread.m to the list.
--- a/scripts/image/__img__.m	Tue Jul 15 13:34:22 2008 -0400
+++ b/scripts/image/__img__.m	Wed Jul 16 11:24:48 2008 -0400
@@ -56,6 +56,15 @@
   tmp = __go_image__ (ca, "cdata", img, "xdata", xlim, "ydata", ylim, 
 		      "cdatamapping", "direct", varargin {:});
 
+  if (ndims (img) == 3)
+    if (isinteger (img))
+      c = class (img);
+      mn = intmin (c);
+      mx = intmax (c);
+      set (ca, "clim", double ([mn, mx]));
+    endif
+  endif
+
   set (ca, "view", [0, 90]);
 
   if (strcmp (get (ca, "nextplot"), "replace"))
--- a/scripts/image/imshow.m	Tue Jul 15 13:34:22 2008 -0400
+++ b/scripts/image/imshow.m	Wed Jul 16 11:24:48 2008 -0400
@@ -147,7 +147,7 @@
   endif
 
   ## This is for compatibility.
-  if (! indexed || islogical (im))
+  if (! (indexed || (true_color && isinteger (im))) || islogical (im))
     im = double (im);
   endif
 
--- a/scripts/plot/__go_draw_axes__.m	Tue Jul 15 13:34:22 2008 -0400
+++ b/scripts/plot/__go_draw_axes__.m	Wed Jul 16 11:24:48 2008 -0400
@@ -291,6 +291,7 @@
     zautoscale = strcmpi (axis_obj.zlimmode, "auto");
     cautoscale = strcmpi (axis_obj.climmode, "auto");
     cdatadirect = false;
+    truecolor = false;
 
     kids = axis_obj.children;
 
@@ -338,7 +339,9 @@
 
 	  if (use_gnuplot_for_images)
 
-	    if (strcmpi (obj.cdatamapping, "direct"))
+	    if (ndims (img_data) == 3)
+	      truecolor = true;
+	    elseif (strcmpi (obj.cdatamapping, "direct"))
 	      cdatadirect = true;
 	    endif
 	    fputs (plot_stream, "set border front;\n");
@@ -1056,11 +1059,12 @@
 
     cmap = parent_figure_obj.colormap;    
     cmap_sz = rows(cmap);
+
     if (! any (isinf (clim)))
-      if (cdatadirect)
+      if (truecolor || ! cdatadirect)
+	fprintf (plot_stream, "set cbrange [%g:%g];\n", clim);
+      else
 	fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz);
-      else
-	fprintf (plot_stream, "set cbrange [%g:%g];\n", clim);
       endif
     endif