0

我对python不太了解。试图学习它。但我需要让代码从别人构建的项目中运行。

figure()
im = imread('Input.jpg')
x = []
y = []

def ext(a,b,i):
    a,b=np.round(a),np.round(b)
    x.extend(arange(a,b,1).tolist())
    y.extend((ones(int(b-a))*i).tolist())

val = color.rgb2lab((im[x,y]/255.).reshape(len(x),1,3)).reshape(len(x),3)

我在上面的最后一行收到以下错误。

Traceback (most recent call last):
File "C:\Users\John\Downloads\test.py", line 58, in <module>

val = color.rgb2lab((im[x,y]/255.).reshape(len(x),1,3)).reshape(len(x),3)

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis(`None`) and integer or boolean arrays are valid indices

我尝试了很多事情,从使用 map(int,x) 尝试将列表 x 和 y 转换为数组,从而导致更多不同的错误。我无法列出我尝试过的所有不同的东西。任何帮助表示赞赏。谢谢

编辑:解决。我想显示完整的代码文件,所以我试图找到一个 python 文件主机。幸运的是,我找到了 www.pythonanywhere.com。我在 www.pythonanywhere.com 上执行了 test.py 文件,它提到一些代码已被弃用,但它仍然正确执行了文件,我得到了我想要的结果。谢谢您的帮助。

4

0 回答 0