Mercurial > octave-antonio
diff scripts/image/ind2rgb.m @ 16707:4c11e9bcb796
ind2rgb: add support for multidimensional indexed images.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Fri, 31 May 2013 13:27:04 +0100 |
parents | aa81cfa5c359 |
children | 12005245b645 |
line wrap: on
line diff
--- a/scripts/image/ind2rgb.m Thu May 30 14:19:59 2013 -0400 +++ b/scripts/image/ind2rgb.m Fri May 31 13:27:04 2013 +0100 @@ -31,6 +31,8 @@ ## channels). Alternatively, the individual red, green, and blue color matrices ## of size MxN may be returned. ## +## Multidimensional indexed images (of size MxNx1xK) are also supported. +## ## @seealso{rgb2ind, ind2gray, hsv2rgb, ntsc2rgb} ## @end deftypefn @@ -53,7 +55,14 @@ ## Use ND array if only one output is requested. if (nargout <= 1) - R = reshape ([R(:); G(:); B(:)], [sz, 3]); + if (ndims (x) == 2) + R = reshape ([R(:); G(:); B(:)], [sz, 3]); + elseif (ndims (x) == 4) + R = permute (reshape ([R(:); G(:); B(:)], [sz(1) sz(2) sz(4) 3]), [1 2 4 3]); + else + ## we should never reach here since ind2x() should filter them out + error ("ind2rgb: an indexed image must have 2 or 4 dimensions."); + endif endif endfunction