# HG changeset patch # User Adam H Aitkenhead # Date 1365103134 -3600 # Node ID aa81cfa5c3599afa6891ea2d0d2334159a141a7f # Parent 28136851099a13f78663b30949a858ff0a88dd09 ind2x.m and ind2rgb.m: Enable handling of ND images * scripts/image/private/ind2x.m: Allow input image to have >= 2 dimensions * scripts/image/ind2rgb.m: Enable handling of ND images diff -r 28136851099a -r aa81cfa5c359 scripts/image/ind2rgb.m --- a/scripts/image/ind2rgb.m Wed Apr 03 00:10:56 2013 -0400 +++ b/scripts/image/ind2rgb.m Thu Apr 04 20:18:54 2013 +0100 @@ -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 diff -r 28136851099a -r aa81cfa5c359 scripts/image/private/ind2x.m --- a/scripts/image/private/ind2x.m Wed Apr 03 00:10:56 2013 -0400 +++ b/scripts/image/private/ind2x.m Thu Apr 04 20:18:54 2013 +0100 @@ -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