Mercurial > hg > octave-lyh
changeset 16633:8d32a887754a
rgb2ind.m: Fix handling ND images.
* rgb2ind.m: Fix handling of ND images.
author | Adam H Aitkenhead <adamhaitkenhead@gmail.com> |
---|---|
date | Wed, 08 May 2013 20:48:11 +0100 |
parents | ace0f60672ec |
children | 2510fffc05e1 |
files | scripts/image/rgb2ind.m |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/rgb2ind.m +++ b/scripts/image/rgb2ind.m @@ -108,6 +108,8 @@ endif endif + sz = size (rgb); + ## Apply a limited colormap if required if (exist ("option","var")) @@ -138,6 +140,12 @@ endif + ## If image is an ND array, convert it to a tiled 2D image + ## before processing it with Graphicsmagick + if numel (sz)>3 + rgb = reshape (rgb, [prod(sz(1:end-2)), sz(end-1), 3]); + end + ## Prepare the Graphicsmagick dithering option if strcmp (dither_option, "nodither") ditherstr = "+dither"; @@ -156,7 +164,6 @@ endif ## Conversion of rgb image to x,map - sz = size (rgb); pr = prod (sz(1:end-1)); x = zeros (sz(1:end-1)); [map,~,x(:)] = unique (reshape(rgb, [pr, 3]), "rows");