我对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文件并且它提到了一些代码已被弃用,但它仍然正确执行了文件,我得到了我想要的结果。谢谢你的帮助。