octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ind2rgb problem


From: Carnë Draug
Subject: Re: ind2rgb problem
Date: Fri, 31 May 2013 16:03:11 +0100

On 31 May 2013 15:28, adama <address@hidden> wrote:
> I noticed that Carnë applied a patch to ind2rgb / ind2x today, but it seems
> to break ind2rgb for N-dimensional images.  There might be something I'm
> missing, but what is the patch meant to do?
>
> http://hg.savannah.gnu.org/hgweb/octave/rev/4c11e9bcb796
>
> The old version of ind2rgb / ind2x worked for all ND images.  For example, a
> 5x5x5 rgb image can be converted to and from an indexed image without any
> problems.
>
> a = rand(5,5,5,3);
> [x,m] = rgb2ind(a);
> b = ind2rgb(x,m);

Actually that was a bug. There was a test there and should give an
error if the input image had more than 2 dimensions, but it was
reversed and was instead checking if it had *less* than 2. That's why
it was working.

> With the patched version this is no longer the case.  It now only works for
> either 2D images, or 4D images where the 3D dimension is a singleton, but
> not for the general case of ND images.  Is there some reason to limit the
> functionality here?  3D images are common in medical imaging, so it's a
> shame to break this.

A 5x5x5 image is an invalid image. Isn't the third dimension reserved
for colours channels? A 3D image is not read as a matrix with 3
dimensions, it's read as a 4 dimension matrix, the space being on the
4th dimension. If the image is indexed, the third dimension will be a
singleton. I do not have any multipage indexed image for testing (if
you do, please send me one, I need it for testing purposes, specially
multipage indexed image with different colormaps in each page), but
imread should read those images as 4D matrices.

Carnë


reply via email to

[Prev in Thread] Current Thread [Next in Thread]