gpt4 book ai didi

python - 类型错误 : Image data can not convert to float

转载 作者:IT老高 更新时间:2023-10-28 20:51:19 24 4
gpt4 key购买 nike

我正在尝试像这样创建一个 16 位图像:

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)

但我得到错误 TypeError: Image data can not convert to float.

最佳答案

此问题在 Google 搜索此类型错误时首先出现,但没有关于错误原因的一般答案。张贴者的独特问题是使用了不合适的对象类型作为 plt.imshow() 的主要参数。一个更一般的答案是 plt.imshow() 想要一个 float 组,如果你不指定 float、numpy、pandas 或其他任何东西,可能会推断沿线某处的不同数据类型。您可以通过为 dtype 参数指定一个 float 来避免这种情况,该参数是对象的构造函数。

Numpy documentation here .

Pandas documentation here

关于python - 类型错误 : Image data can not convert to float,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32302180/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com