您的位置:首页 > 其它

关于调色板的记录

2013-11-19 13:01 134 查看
今天在使用Python的Pillow模块:

from PIL import Image
im=Image.open("google-logo.bmp")
out=im.filter(ImageFilter.DETAIL)


出现错误:

ValueError: cannot filter palette images

print (im.format, im.size,im.mode)

GIF (150, 55) P


P代表是调色板。

在StackOverflow上搜索了下,找到了该问题:

http://stackoverflow.com/questions/10323692/cannot-filter-palette-images-error-when-doing-a-imageenhance-sharpness

It's quite common for algorithms to be unable to work with a palette based image. The
convert
in
the above changes it to have a full RGB value at each pixel location.

大致翻译如下:在算法中,不能处理一个调色板图像很正常。这种“转换”需要在每一个像素点有全RGB值。

本例子中,改为:

out=im.convert('RGB').filter(ImageFilter.DETAIL)


即可。

这里面提到了一个关于真彩色和调色板的问题,为此找了两篇关于调色板的介绍

http://www.360doc.com/content/10/0928/15/2790922_57060786.shtml

http://blog.chinaunix.net/uid-22028680-id-3962996.html

Mark下,晚点总结看看
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: