reading images in palette mode

Ralf Gommers ralf.gommers at googlemail.com
Fri Oct 30 11:31:50 EDT 2009


Hi Tony,

On Wed, Oct 28, 2009 at 10:36 PM, Tony S Yu <tsyu80 at gmail.com> wrote:

>
> Hi,
>
> Currently, imread doesn't properly handle palette images since PIL palette
> images can't be converted directly to numpy arrays. Well, you can convert
> it, but the output is garbage since the array values correspond to the image
> palette, which you don't have access.
>
> Flattening the image seems to be an OK work around, but if the image had a
> color palette, this information is lost. Also, this work around requires you
> to know that an image is in palette mode before calling imread.
>
> Below is a short patch that checks if an image is in palette mode; if it
> is, grayscale images are converted to luminance mode and color images are
> converted to RGB. I'm not sure if these conversions are appropriate, but at
> least it's an improvement.
>
> I hope this is helpful to somebody. Cheers,
>

This looks like a useful addition to me.

The images on the page you linked to can not be included I think
(copyright), so could you generate two small palette images (one rgb, one
grey, 10x10 pixels) for use in a test? (or ideally, write the test:))

Also, I see you are already using git, so next time could you push your
changes to github as described here
http://stefanv.github.com/scikits.image/contribute.html#development-process,
that would make it a bit faster to test.

Thanks,
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20091030/8a260045/attachment.html>


More information about the scikit-image mailing list