我决定只使用该方法提供给我的数组来制作一个图像编辑程序matplotlib.pyplot.imread,但是当我尝试将一个像素的内容分配给另一个像素时,它告诉我:can't assign to function call.import matplotlib.pyplot as pltf = plt.imread("GreenScreen.png")x1 = 250y1 = 350x2 = 750xCount = x2xCount2 = xCountxCountStart = x2xSet = 0for xCount in range(xCountStart, x1): xCount2 = (x1 + xCount) / 2 xSet = xCount2 for y1 in range(350, 360): for xCount2 in range(xSet, xCount): f(xCount2, y1) = f(xSet, y1) f(xCount2, y1) = f(xSet, y1) f(xCount2, y1) = f(xSet, y1) f(xCount2, y1) = f(xSet, y1) xCount2 = xSet y1 = 350plt.imshow(f)plt.show()
2 回答
catspeake
TA贡献1111条经验 获得超0个赞
将括号更改为用于索引()的方括号。[]像这样的东西应该工作:
for xCount in range(xCountStart, x1):
xCount2 = (x1 + xCount) / 2
xSet = xCount2
for y1 in range(350, 360):
for xCount2 in range(xSet, xCount):
f[xCount2, y1] = f[xSet, y1]
f[xCount2, y1] = f[xSet, y1]
f[xCount2, y1] = f[xSet, y1]
f[xCount2, y1] = f[xSet, y1]
xCount2 = xSet
y1 = 350
...
鸿蒙传说
TA贡献1865条经验 获得超7个赞
f(xCount2, y1) = f(xSet, y1)
f(xCount2, y1) = f(xSet, y1)
f(xCount2, y1) = f(xSet, y1)
f(xCount2, y1) = f(xSet, y1)
要在 中设置字段f,请使用f[xCount2, y1]。括号用于调用函数,方括号用于索引。
添加回答
举报
0/150
提交
取消