# HG changeset patch # User John W. Eaton # Date 1216221888 14400 # Node ID 1f6eb3de1c4ef4726e14cb4a7f945f059b5fd087 # Parent 30b952e90c294c6601e8f812e8a746024f91fd5a __img__.m, imshow.m, __go_draw_axes__.m: improve handling of truecolor images diff -r 30b952e90c29 -r 1f6eb3de1c4e scripts/ChangeLog --- 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 + + * 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 * image/Makefile.in (SOURCES): Add imread.m to the list. diff -r 30b952e90c29 -r 1f6eb3de1c4e scripts/image/__img__.m --- 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")) diff -r 30b952e90c29 -r 1f6eb3de1c4e scripts/image/imshow.m --- 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 diff -r 30b952e90c29 -r 1f6eb3de1c4e scripts/plot/__go_draw_axes__.m --- 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