changeset 16435:22c0e0df1dbc

Merge in Adam's changes
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 04 Apr 2013 15:45:58 -0400
parents aa81cfa5c359 (diff) 2c8860d563e5 (current diff)
children 39847dcd2568
files libgui/src/octave-adapter/octave-event-listener.h libgui/src/octave-adapter/octave-link.cc libgui/src/octave-adapter/octave-link.h libgui/src/octave-adapter/octave-main-thread.cc libgui/src/octave-adapter/octave-main-thread.h libinterp/corefcn/__execute_edit_hook__.cc
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/image/ind2rgb.m	Thu Apr 04 13:30:17 2013 -0400
+++ b/scripts/image/ind2rgb.m	Thu Apr 04 15:45:58 2013 -0400
@@ -46,15 +46,14 @@
   [x, map] = ind2x ("ind2rgb", x, map);
 
   ## Compute result
-  [row, col] = size (x);
-  R = reshape (map(x(:), 1), row, col);
-  G = reshape (map(x(:), 2), row, col);
-  B = reshape (map(x(:), 3), row, col);
+  sz = size (x);
+  R = reshape (map(x(:), 1), sz);
+  G = reshape (map(x(:), 2), sz);
+  B = reshape (map(x(:), 3), sz);
 
-  ## Use 3D array if only one output is requested.
+  ## Use ND array if only one output is requested.
   if (nargout <= 1)
-    R(:,:,2) = G;
-    R(:,:,3) = B;
+    R = reshape ([R(:); G(:); B(:)], [sz, 3]);
   endif
 
 endfunction
--- a/scripts/image/private/ind2x.m	Thu Apr 04 13:30:17 2013 -0400
+++ b/scripts/image/private/ind2x.m	Thu Apr 04 15:45:58 2013 -0400
@@ -22,7 +22,7 @@
 function [x, map] = ind2x (caller, x, map)
 
   ## Check if X is an indexed image.
-  if (ndims (x) != 2 || issparse (x) || (isfloat (x) && ! isindex (x)) ||
+  if (ndims (x) < 2 || issparse (x) || (isfloat (x) && ! isindex (x)) ||
       ! any (strcmp (class (x), {"uint8", "uint16", "single", "double"})))
     error ("%s: X must be an indexed image", caller);
   endif