Skimage.io.read读取一个PIL对象

问题描述

因此,我正在使用skimage进行一些图像预处理(我对此很陌生)。我有一个PIL图像对象,并想使用skimage.io.imread()转换为skimage图像。我知道我可以保存图像,然后在该文件上运行imread,但是我想知道是否有一种方法可以从代码本身读取PIL Image对象。我尝试在PIL Image对象本身上运行imread,但最终出现错误。

OSError: Cannot understand given URI: <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=192....

任何人都知道如何在skimage中解决这个问题。

解决方法

Scikit-Image 将图像存储为Numpy数组,因此您只需要从 PIL图像制作一个Numpy数组:

[OperationContract(Name = "Messages",IsOneWay = true)]
[WebInvoke(Method = "GET",UriTemplate = "/Messages?id={id}&fileId={fileId}",ResponseFormat = WebMessageFormat.Xml,BodyStyle = WebMessageBodyStyle.Wrapped)]
[Description("Inbound Message")]
void Messages(string id,int fileId);
,

您可以查看与函数 imageio documentation 相关的 imread 以将属性格式和代码包含在您的代码中,以防图像格式为 PNG:imageio.imread(filename,format = 'PNG')

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...