我想创建一个16位图像。所以我写了一个代码。TypeError:图像数据无法转换为浮点数
import skimage
import random
from random import randint
xrow=raw_input("Enter the number of rows to be present in image.=>")
row=int(xrow)
ycolumn=raw_input("Enter the number of columns to be present in image.=>")
column=int(ycolumn)
A={}
for x in xrange(1,row):
for y in xrange(1,column):
a=randint(0,65535)
A[x,y]=a
imshow(A)
但每当我运行这段代码,我得到显示错误“类型错误:图像数据无法转换为浮动”。就是有这方面的任何解决方案。
我对自己写的错误表示歉意,因为这是我上面提到的第一个问题。
'A'是一本字典,但我们假定你是,它是用于显示的图像类型。这就是你得到'TypeError'的原因。不过,我很困惑,因为我不知道你使用的是哪个图像库。你已经导入了'scikit-image',但是你使用PIL标记了你的文章。另外,'imshow'调用是不明确的,因为我不知道哪个包是从哪里来的。没有任何“进口”声明对我来说很明显。请编辑您的问题,以解决'imshow'包的来源以及您想要用于发布的图像库。顺便说一句,图像索引从'0'开始。 – rayryeng